antelope 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +25 -25
  3. data/.rspec +3 -3
  4. data/.travis.yml +10 -10
  5. data/.yardopts +7 -7
  6. data/CONTRIBUTING.md +50 -38
  7. data/GENERATORS.md +180 -124
  8. data/Gemfile +7 -7
  9. data/LICENSE.txt +22 -22
  10. data/README.md +240 -104
  11. data/Rakefile +2 -2
  12. data/TODO.md +58 -58
  13. data/antelope.gemspec +29 -28
  14. data/bin/antelope +7 -7
  15. data/examples/deterministic.ace +35 -35
  16. data/examples/example.ace +52 -51
  17. data/examples/example.ace.err +192 -192
  18. data/examples/example.ace.inf +432 -432
  19. data/examples/example.ate +70 -70
  20. data/examples/example.ate.err +192 -192
  21. data/examples/example.ate.inf +432 -432
  22. data/examples/liquidscript.ace +233 -233
  23. data/examples/simple.ace +22 -22
  24. data/lib/antelope/ace/compiler.rb +334 -334
  25. data/lib/antelope/ace/errors.rb +30 -30
  26. data/lib/antelope/ace/scanner/argument.rb +57 -57
  27. data/lib/antelope/ace/scanner/first.rb +89 -89
  28. data/lib/antelope/ace/scanner/second.rb +178 -178
  29. data/lib/antelope/ace/scanner/third.rb +27 -27
  30. data/lib/antelope/ace/scanner.rb +144 -144
  31. data/lib/antelope/ace.rb +47 -47
  32. data/lib/antelope/cli.rb +60 -60
  33. data/lib/antelope/errors.rb +25 -25
  34. data/lib/antelope/generation/constructor/first.rb +86 -86
  35. data/lib/antelope/generation/constructor/follow.rb +105 -105
  36. data/lib/antelope/generation/constructor/nullable.rb +64 -64
  37. data/lib/antelope/generation/constructor.rb +127 -127
  38. data/lib/antelope/generation/errors.rb +17 -17
  39. data/lib/antelope/generation/null.rb +13 -13
  40. data/lib/antelope/generation/recognizer/rule.rb +216 -216
  41. data/lib/antelope/generation/recognizer/state.rb +129 -129
  42. data/lib/antelope/generation/recognizer.rb +177 -177
  43. data/lib/antelope/generation/tableizer.rb +176 -176
  44. data/lib/antelope/generation.rb +15 -15
  45. data/lib/antelope/generator/base/coerce.rb +115 -0
  46. data/lib/antelope/generator/base/extra.rb +50 -0
  47. data/lib/antelope/generator/base.rb +134 -264
  48. data/lib/antelope/generator/c.rb +11 -11
  49. data/lib/antelope/generator/c_header.rb +105 -105
  50. data/lib/antelope/generator/c_source.rb +39 -39
  51. data/lib/antelope/generator/error.rb +34 -34
  52. data/lib/antelope/generator/group.rb +60 -57
  53. data/lib/antelope/generator/html.rb +51 -51
  54. data/lib/antelope/generator/info.rb +47 -47
  55. data/lib/antelope/generator/null.rb +18 -18
  56. data/lib/antelope/generator/output.rb +17 -17
  57. data/lib/antelope/generator/ruby.rb +112 -79
  58. data/lib/antelope/generator/templates/c_header.ant +36 -36
  59. data/lib/antelope/generator/templates/c_source.ant +202 -202
  60. data/lib/antelope/generator/templates/error.erb +40 -0
  61. data/lib/antelope/generator/templates/html/antelope.css +53 -1
  62. data/lib/antelope/generator/templates/html/antelope.html +82 -1
  63. data/lib/antelope/generator/templates/html/antelope.js +9 -1
  64. data/lib/antelope/generator/templates/html/css.ant +53 -53
  65. data/lib/antelope/generator/templates/html/html.ant +82 -82
  66. data/lib/antelope/generator/templates/html/js.ant +9 -9
  67. data/lib/antelope/generator/templates/info.erb +61 -0
  68. data/lib/antelope/generator/templates/{ruby.ant → ruby.erb} +171 -178
  69. data/lib/antelope/generator.rb +62 -66
  70. data/lib/antelope/grammar/generation.rb +76 -76
  71. data/lib/antelope/grammar/loading.rb +84 -84
  72. data/lib/antelope/grammar/precedence.rb +59 -59
  73. data/lib/antelope/grammar/precedences.rb +64 -64
  74. data/lib/antelope/grammar/production.rb +56 -56
  75. data/lib/antelope/grammar/productions.rb +154 -154
  76. data/lib/antelope/grammar/symbols.rb +64 -64
  77. data/lib/antelope/grammar/token/epsilon.rb +23 -23
  78. data/lib/antelope/grammar/token/error.rb +24 -24
  79. data/lib/antelope/grammar/token/nonterminal.rb +15 -15
  80. data/lib/antelope/grammar/token/terminal.rb +15 -15
  81. data/lib/antelope/grammar/token.rb +231 -231
  82. data/lib/antelope/grammar.rb +68 -68
  83. data/lib/antelope/version.rb +6 -6
  84. data/lib/antelope.rb +18 -19
  85. data/optimizations.txt +42 -42
  86. data/spec/antelope/ace/compiler_spec.rb +60 -60
  87. data/spec/antelope/ace/scanner_spec.rb +27 -27
  88. data/spec/antelope/generation/constructor_spec.rb +131 -131
  89. data/spec/fixtures/simple.ace +22 -22
  90. data/spec/spec_helper.rb +39 -39
  91. data/spec/support/benchmark_helper.rb +5 -5
  92. data/spec/support/grammar_helper.rb +14 -14
  93. data/subl/Ace (Ruby).JSON-tmLanguage +94 -94
  94. data/subl/Ace (Ruby).tmLanguage +153 -153
  95. metadata +22 -11
  96. data/lib/antelope/generator/templates/error.ant +0 -34
  97. data/lib/antelope/generator/templates/info.ant +0 -53
  98. data/lib/antelope/template/compiler.rb +0 -78
  99. data/lib/antelope/template/errors.rb +0 -9
  100. data/lib/antelope/template/scanner.rb +0 -109
  101. data/lib/antelope/template.rb +0 -64
  102. data/spec/antelope/template_spec.rb +0 -50
@@ -1,233 +1,233 @@
1
- %require "~> 0.1"
2
- %generator "ruby"
3
-
4
- %define api.push-pull pull
5
- %define panic-mode true
6
- %define ruby.error-class {SyntaxError}
7
-
8
- %terminal REGEX
9
- %terminal DIRECTIVE
10
- %terminal IDENTIFIER
11
- %terminal KEYWORD
12
- %terminal NUMBER
13
- %terminal SSTRING
14
- %terminal ACTION
15
- %terminal BINOP
16
- %terminal PREUNOP
17
- %terminal UNOP
18
- %terminal HEREDOC
19
- %terminal HEREDOC_REF
20
- %terminal IHEREDOC
21
- %terminal IHEREDOC_REF
22
- %terminal IHEREDOC_BEGIN
23
- %terminal ISTRING
24
- %terminal ISTRING_BEGIN
25
- %terminal CLASS "class"
26
- %terminal MODULE "module"
27
- %terminal IF "if"
28
- %terminal UNLESS "unless"
29
- %terminal ELSIF "elsif"
30
- %terminal ELSE "else"
31
- %terminal FOR "for"
32
- %terminal WHILE "while"
33
- %terminal TRY "try"
34
- %terminal CATCH "catch"
35
- %terminal FINALLY "finally"
36
- %terminal RETURN "return"
37
- %terminal IN "in"
38
- %terminal ARROW "->"
39
- %terminal EQUAL "="
40
- %terminal LBRACE "{"
41
- %terminal LPAREN "("
42
- %terminal LBRACK "["
43
- %terminal RBRACE "}"
44
- %terminal RPAREN ")"
45
- %terminal RBRACK "]"
46
- %terminal COLON ":"
47
- %terminal RANGE ".."
48
- %terminal ERANGE "..."
49
- %terminal PROP "."
50
- %terminal COMMA ","
51
- %terminal MINUS "-"
52
- %terminal PLUS "+"
53
- %terminal NEWLINE "\n"
54
-
55
- %nonassoc FIX
56
- %nonassoc LBRACK LPAREN
57
- %right UNOP PROP
58
- %left RANGE ERANGE
59
- %left BINOP PLUS MINUS
60
- %right EQUAL
61
-
62
- %null.data left LPAREN LBRACK BINOP MINUS PLUS
63
- %null.data right EQUAL PROP RANGE ERANGE UNOP
64
-
65
- %%
66
-
67
- main: expressions.maybe
68
-
69
- expressions.maybe: expressions
70
- | %empty { nil }
71
-
72
- expressions: expressions expression { |a, b| a << b }
73
- | expression { |a| [a] }
74
-
75
- block: LBRACE expressions.maybe RBRACE { |_, a, _| [:block, a] }
76
-
77
- block_or_vexpression: block
78
- | vexpression
79
-
80
- expression: conditional
81
- | class
82
- | module
83
- | loop
84
- | action
85
- | exception
86
- | directive
87
- | vexpression
88
- | NEWLINE { nil }
89
- | vvexpression EQUAL vexpression { |a, _, b| [:set, a, b] }
90
-
91
- vexpression: NUMBER
92
- | ISTRING
93
- | SSTRING
94
- | KEYWORD
95
- | REGEX
96
- | interpolation
97
- | PLUS vexpression { |_, a| [:pos, a] }
98
- | MINUS vexpression { |_, a| [:neg, a] }
99
- | object
100
- | array
101
- | function
102
- | PREUNOP vexpression { |a, b| [:unop, a, b] }
103
- | UNOP vexpression { |a, b| [:unop, a, b] }
104
- | HEREDOC_REF
105
- | IHEREDOC_REF
106
- | LPAREN vexpression RPAREN { |_, a, _| a }
107
- | heredoc
108
- | vexpression LPAREN vexpression.parameters.maybe RPAREN
109
- { |a, _, b, _| [:call, a, b] }
110
- | vexpression RANGE vexpression
111
- { |a, _, b| [:range, a, b] }
112
- | vexpression ERANGE vexpression
113
- { |a, _, b| [:erange, a, b] }
114
- | vexpression BINOP vexpression
115
- { |a, b, c| [:binop, a, b, c] }
116
- | vexpression MINUS vexpression
117
- { |a, b, c| [:binop, a, b, c] }
118
- | vexpression PLUS vexpression
119
- { |a, b, c| [:plus, a, b, c] }
120
- | vexpression UNOP
121
- { |a, b| [:unop, a, b] }
122
- | vvexpression
123
-
124
- vvexpression: vexpression PROP IDENTIFIER
125
- { |a, _, b| [:prop, a, b] }
126
- | vexpression LBRACK vexpression RBRACK
127
- { |a, _, b| [:access, a, b] }
128
- | IDENTIFIER
129
-
130
- vexpression.parameters.maybe: vexpression.parameters
131
- | %empty
132
-
133
- vexpression.parameters: vexpression.parameters COMMA vexpression
134
- { |a, _, b| a << b }
135
- | vexpression { |*a| a }
136
-
137
- object: LBRACE RBRACE { [:object] }
138
- array: LBRACK RBRACK { [:array] }
139
- function: ARROW function.arguments.maybe block
140
- { |_, a, b| [:func, a, b] }
141
- heredoc: HEREDOC
142
- | IHEREDOC
143
-
144
- function.arguments.maybe: LPAREN function.arguments.body.maybe RPAREN
145
- { |_, a, _| a }
146
- | %empty { nil }
147
-
148
- function.arguments.body.maybe: function.arguments.body
149
- | %empty { nil }
150
- function.arguments.body: function.arguments.body COMMA IDENTIFIER
151
- { |a, _, b| a << b }
152
- | IDENTIFIER { |a| [a] }
153
-
154
- interpolation: interpolation.string
155
- | interpolation.heredoc
156
-
157
- interpolation.heredoc: IHEREDOC_BEGIN vexpression interpolation.heredoc.finish
158
- interpolation.heredoc.finish: interpolation.heredoc
159
- | IHEREDOC
160
-
161
- interpolation.string: ISTRING_BEGIN vexpression interpolation.string.finish
162
- interpolation.string.finish: interpolation.string
163
- | ISTRING
164
-
165
- conditional: IF LPAREN vexpression RPAREN block
166
- conditional.continue.maybe
167
- { |_, _, a, _, b, c| [:if, a, b, c] }
168
- | UNLESS LPAREN vexpression RPAREN block
169
- { |_, _, a, _, b| [:unless, a, b] }
170
-
171
- conditional.continue.maybe: conditional.continue
172
- | %empty { nil }
173
-
174
- conditional.continue: ELSIF LPAREN vexpression RPAREN block
175
- conditional.continue.maybe
176
- { |_, _, a, _, b, c| [:elsif, a, b, c] }
177
- | ELSE block { |_, a| [:else, a] }
178
-
179
- class: CLASS IDENTIFIER LBRACE class.definition.parts.maybe RBRACE
180
- { |_, a, _, b, _| [:class, a, b] }
181
- module: MODULE IDENTIFIER LBRACE module.definition.parts.maybe RBRACE
182
- { |_, a, _, b, _| [:module, a, b] }
183
-
184
- class.definition.parts.maybe: class.definition.parts
185
- | %empty { nil }
186
- class.definition.parts: class.definition.parts class.definition.part
187
- { |a, b| a << b }
188
- | class.definition.part { |a| [a] }
189
- class.definition.part: IDENTIFIER COLON vexpression
190
- { |a, _, b| [:inst, a, b] }
191
- | IDENTIFIER PROP IDENTIFIER COLON vexpression
192
- { |a, _, b, _, c| [:class, a, b, c] }
193
- | module
194
- | class
195
-
196
- module.definition.parts.maybe: module.definition.parts
197
- | %empty { nil }
198
- module.definition.parts: module.definition.parts
199
- module.definition.part
200
- { |a, b| a << b }
201
- | module.definition.part { |a| [a] }
202
- module.definition.part: IDENTIFIER COLON vexpression
203
- { |a, _, b| [:inst, a, b] }
204
-
205
- loop: WHILE LPAREN vexpression RPAREN block
206
- { |_, _, a, _, b| [:while, a, b] }
207
- | FOR LPAREN IDENTIFIER IN vexpression RPAREN block
208
- { |_, _, a, _, b, _, c| [:forin, a, b, c] }
209
- | FOR LPAREN vexpression RPAREN block
210
- { |_, _, a, _, b| [:for, a, b] }
211
-
212
- action: RETURN vexpression { |_, a| [:return, a] }
213
- | ACTION
214
-
215
- exception: TRY LBRACE expressions.maybe RBRACE exception.catch.maybe
216
- exception.finally.maybe
217
- { |_, _, a, _, b, c| [:try, a, b, c] }
218
- exception.catch.maybe: exception.catch
219
- | %empty { nil }
220
- exception.finally.maybe: exception.finally
221
- | %empty { nil }
222
- exception.catch: CATCH exception.catch.possible block
223
- { |_, a, b| [:catch, a, b] }
224
- exception.catch.possible: LPAREN IDENTIFIER RPAREN { |_, a, _| a }
225
- | LPAREN RPAREN { nil }
226
- | %empty { nil }
227
-
228
- exception.finally: FINALLY block { |_, a| [:finally, a ] }
229
-
230
- directive: COLON LBRACK expressions RBRACK
231
- { |_, _, a, _| [:directive, a] }
232
-
233
- %%
1
+ %require "~> 0.1"
2
+ %generator "ruby"
3
+
4
+ %define api.push-pull pull
5
+ %define panic-mode true
6
+ %define ruby.error-class {SyntaxError}
7
+
8
+ %terminal REGEX
9
+ %terminal DIRECTIVE
10
+ %terminal IDENTIFIER
11
+ %terminal KEYWORD
12
+ %terminal NUMBER
13
+ %terminal SSTRING
14
+ %terminal ACTION
15
+ %terminal BINOP
16
+ %terminal PREUNOP
17
+ %terminal UNOP
18
+ %terminal HEREDOC
19
+ %terminal HEREDOC_REF
20
+ %terminal IHEREDOC
21
+ %terminal IHEREDOC_REF
22
+ %terminal IHEREDOC_BEGIN
23
+ %terminal ISTRING
24
+ %terminal ISTRING_BEGIN
25
+ %terminal CLASS "class"
26
+ %terminal MODULE "module"
27
+ %terminal IF "if"
28
+ %terminal UNLESS "unless"
29
+ %terminal ELSIF "elsif"
30
+ %terminal ELSE "else"
31
+ %terminal FOR "for"
32
+ %terminal WHILE "while"
33
+ %terminal TRY "try"
34
+ %terminal CATCH "catch"
35
+ %terminal FINALLY "finally"
36
+ %terminal RETURN "return"
37
+ %terminal IN "in"
38
+ %terminal ARROW "->"
39
+ %terminal EQUAL "="
40
+ %terminal LBRACE "{"
41
+ %terminal LPAREN "("
42
+ %terminal LBRACK "["
43
+ %terminal RBRACE "}"
44
+ %terminal RPAREN ")"
45
+ %terminal RBRACK "]"
46
+ %terminal COLON ":"
47
+ %terminal RANGE ".."
48
+ %terminal ERANGE "..."
49
+ %terminal PROP "."
50
+ %terminal COMMA ","
51
+ %terminal MINUS "-"
52
+ %terminal PLUS "+"
53
+ %terminal NEWLINE "\n"
54
+
55
+ %nonassoc FIX
56
+ %nonassoc LBRACK LPAREN
57
+ %right UNOP PROP
58
+ %left RANGE ERANGE
59
+ %left BINOP PLUS MINUS
60
+ %right EQUAL
61
+
62
+ %null.data left LPAREN LBRACK BINOP MINUS PLUS
63
+ %null.data right EQUAL PROP RANGE ERANGE UNOP
64
+
65
+ %%
66
+
67
+ main: expressions.maybe
68
+
69
+ expressions.maybe: expressions
70
+ | %empty { nil }
71
+
72
+ expressions: expressions expression { |a, b| a << b }
73
+ | expression { |a| [a] }
74
+
75
+ block: LBRACE expressions.maybe RBRACE { |_, a, _| [:block, a] }
76
+
77
+ block_or_vexpression: block
78
+ | vexpression
79
+
80
+ expression: conditional
81
+ | class
82
+ | module
83
+ | loop
84
+ | action
85
+ | exception
86
+ | directive
87
+ | vexpression
88
+ | NEWLINE { nil }
89
+ | vvexpression EQUAL vexpression { |a, _, b| [:set, a, b] }
90
+
91
+ vexpression: NUMBER
92
+ | ISTRING
93
+ | SSTRING
94
+ | KEYWORD
95
+ | REGEX
96
+ | interpolation
97
+ | PLUS vexpression { |_, a| [:pos, a] }
98
+ | MINUS vexpression { |_, a| [:neg, a] }
99
+ | object
100
+ | array
101
+ | function
102
+ | PREUNOP vexpression { |a, b| [:unop, a, b] }
103
+ | UNOP vexpression { |a, b| [:unop, a, b] }
104
+ | HEREDOC_REF
105
+ | IHEREDOC_REF
106
+ | LPAREN vexpression RPAREN { |_, a, _| a }
107
+ | heredoc
108
+ | vexpression LPAREN vexpression.parameters.maybe RPAREN
109
+ { |a, _, b, _| [:call, a, b] }
110
+ | vexpression RANGE vexpression
111
+ { |a, _, b| [:range, a, b] }
112
+ | vexpression ERANGE vexpression
113
+ { |a, _, b| [:erange, a, b] }
114
+ | vexpression BINOP vexpression
115
+ { |a, b, c| [:binop, a, b, c] }
116
+ | vexpression MINUS vexpression
117
+ { |a, b, c| [:binop, a, b, c] }
118
+ | vexpression PLUS vexpression
119
+ { |a, b, c| [:plus, a, b, c] }
120
+ | vexpression UNOP
121
+ { |a, b| [:unop, a, b] }
122
+ | vvexpression
123
+
124
+ vvexpression: vexpression PROP IDENTIFIER
125
+ { |a, _, b| [:prop, a, b] }
126
+ | vexpression LBRACK vexpression RBRACK
127
+ { |a, _, b| [:access, a, b] }
128
+ | IDENTIFIER
129
+
130
+ vexpression.parameters.maybe: vexpression.parameters
131
+ | %empty
132
+
133
+ vexpression.parameters: vexpression.parameters COMMA vexpression
134
+ { |a, _, b| a << b }
135
+ | vexpression { |*a| a }
136
+
137
+ object: LBRACE RBRACE { [:object] }
138
+ array: LBRACK RBRACK { [:array] }
139
+ function: ARROW function.arguments.maybe block
140
+ { |_, a, b| [:func, a, b] }
141
+ heredoc: HEREDOC
142
+ | IHEREDOC
143
+
144
+ function.arguments.maybe: LPAREN function.arguments.body.maybe RPAREN
145
+ { |_, a, _| a }
146
+ | %empty { nil }
147
+
148
+ function.arguments.body.maybe: function.arguments.body
149
+ | %empty { nil }
150
+ function.arguments.body: function.arguments.body COMMA IDENTIFIER
151
+ { |a, _, b| a << b }
152
+ | IDENTIFIER { |a| [a] }
153
+
154
+ interpolation: interpolation.string
155
+ | interpolation.heredoc
156
+
157
+ interpolation.heredoc: IHEREDOC_BEGIN vexpression interpolation.heredoc.finish
158
+ interpolation.heredoc.finish: interpolation.heredoc
159
+ | IHEREDOC
160
+
161
+ interpolation.string: ISTRING_BEGIN vexpression interpolation.string.finish
162
+ interpolation.string.finish: interpolation.string
163
+ | ISTRING
164
+
165
+ conditional: IF LPAREN vexpression RPAREN block
166
+ conditional.continue.maybe
167
+ { |_, _, a, _, b, c| [:if, a, b, c] }
168
+ | UNLESS LPAREN vexpression RPAREN block
169
+ { |_, _, a, _, b| [:unless, a, b] }
170
+
171
+ conditional.continue.maybe: conditional.continue
172
+ | %empty { nil }
173
+
174
+ conditional.continue: ELSIF LPAREN vexpression RPAREN block
175
+ conditional.continue.maybe
176
+ { |_, _, a, _, b, c| [:elsif, a, b, c] }
177
+ | ELSE block { |_, a| [:else, a] }
178
+
179
+ class: CLASS IDENTIFIER LBRACE class.definition.parts.maybe RBRACE
180
+ { |_, a, _, b, _| [:class, a, b] }
181
+ module: MODULE IDENTIFIER LBRACE module.definition.parts.maybe RBRACE
182
+ { |_, a, _, b, _| [:module, a, b] }
183
+
184
+ class.definition.parts.maybe: class.definition.parts
185
+ | %empty { nil }
186
+ class.definition.parts: class.definition.parts class.definition.part
187
+ { |a, b| a << b }
188
+ | class.definition.part { |a| [a] }
189
+ class.definition.part: IDENTIFIER COLON vexpression
190
+ { |a, _, b| [:inst, a, b] }
191
+ | IDENTIFIER PROP IDENTIFIER COLON vexpression
192
+ { |a, _, b, _, c| [:class, a, b, c] }
193
+ | module
194
+ | class
195
+
196
+ module.definition.parts.maybe: module.definition.parts
197
+ | %empty { nil }
198
+ module.definition.parts: module.definition.parts
199
+ module.definition.part
200
+ { |a, b| a << b }
201
+ | module.definition.part { |a| [a] }
202
+ module.definition.part: IDENTIFIER COLON vexpression
203
+ { |a, _, b| [:inst, a, b] }
204
+
205
+ loop: WHILE LPAREN vexpression RPAREN block
206
+ { |_, _, a, _, b| [:while, a, b] }
207
+ | FOR LPAREN IDENTIFIER IN vexpression RPAREN block
208
+ { |_, _, a, _, b, _, c| [:forin, a, b, c] }
209
+ | FOR LPAREN vexpression RPAREN block
210
+ { |_, _, a, _, b| [:for, a, b] }
211
+
212
+ action: RETURN vexpression { |_, a| [:return, a] }
213
+ | ACTION
214
+
215
+ exception: TRY LBRACE expressions.maybe RBRACE exception.catch.maybe
216
+ exception.finally.maybe
217
+ { |_, _, a, _, b, c| [:try, a, b, c] }
218
+ exception.catch.maybe: exception.catch
219
+ | %empty { nil }
220
+ exception.finally.maybe: exception.finally
221
+ | %empty { nil }
222
+ exception.catch: CATCH exception.catch.possible block
223
+ { |_, a, b| [:catch, a, b] }
224
+ exception.catch.possible: LPAREN IDENTIFIER RPAREN { |_, a, _| a }
225
+ | LPAREN RPAREN { nil }
226
+ | %empty { nil }
227
+
228
+ exception.finally: FINALLY block { |_, a| [:finally, a ] }
229
+
230
+ directive: COLON LBRACK expressions RBRACK
231
+ { |_, _, a, _| [:directive, a] }
232
+
233
+ %%
data/examples/simple.ace CHANGED
@@ -1,22 +1,22 @@
1
- %require "~> 0.1"
2
- %generator "ruby"
3
-
4
- %terminal IDENT
5
- %terminal STAR "*"
6
- %terminal EQUALS "="
7
-
8
- %%
9
-
10
- e: l EQUALS r
11
- | r
12
-
13
- l: IDENT
14
- | STAR r
15
-
16
- r: l
17
-
18
- %%
19
-
20
- class SimpleParser < Antelope::Parser
21
- %{write}
22
- end
1
+ %require "~> 0.1"
2
+ %generator "ruby"
3
+
4
+ %terminal IDENT
5
+ %terminal STAR "*"
6
+ %terminal EQUALS "="
7
+
8
+ %%
9
+
10
+ e: l EQUALS r
11
+ | r
12
+
13
+ l: IDENT
14
+ | STAR r
15
+
16
+ r: l
17
+
18
+ %%
19
+
20
+ class SimpleParser < Antelope::Parser
21
+ %{write}
22
+ end