Sha256: fb2ee7956c531ffc341aeee781880296971807956ab7fbe84870e3549b1d3c1a
Contents?: true
Size: 1.07 KB
Versions: 4
Compression:
Stored size: 1.07 KB
Contents
%require "~> 0.1" %generator "ruby" %null.data ruby.error-class { SyntaxError } %panic-mode true %terminal NUMBER %terminal MULTIPLY "*" %terminal EXPONENTIATE "^" %terminal DIVIDE "/" %terminal ADD "+" %terminal SUBTRACT "-" %terminal LPAREN "(" %terminal RPAREN ")" %right EXPONENTIATE %left MULTIPLY DIVIDE %left ADD SUBTRACT %% expression: NUMBER { |a| a[1] } | expression EXPONENTIATE expression { |a, _, b| a** b } | expression ADD expression { |a, _, b| a + b } | expression SUBTRACT expression { |a, _, b| a - b } | expression MULTIPLY expression { |a, _, b| a * b } | expression DIVIDE expression { |a, _, b| a / b } | LPAREN expression RPAREN { |_, a, _| a } | LPAREN error RPAREN { |_, e, _| e[1] } %% class ExampleParser %{write} def type(token) token[0] end end input = [ [:LPAREN], [:NUMBER, 2], [:ADD], [:ADD, 2], [:RPAREN], [:MULTIPLY], [:NUMBER, 3] ] p ExampleParser.new.parse(input)
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
antelope-0.2.0 | examples/example.ace |
antelope-0.1.11 | examples/example.ace |
antelope-0.1.10 | examples/example.ace |
antelope-0.1.9 | examples/example.ace |