antelope 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rspec +3 -0
- data/.yardopts +4 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/antelope.gemspec +30 -0
- data/bin/antelope +24 -0
- data/examples/deterministic.ace +27 -0
- data/examples/deterministic.output +229 -0
- data/examples/example.ace +45 -0
- data/examples/example.output +610 -0
- data/examples/simple.ace +26 -0
- data/examples/simple.output +194 -0
- data/lib/antelope/ace/compiler.rb +290 -0
- data/lib/antelope/ace/errors.rb +27 -0
- data/lib/antelope/ace/grammar/generation.rb +47 -0
- data/lib/antelope/ace/grammar/loading.rb +51 -0
- data/lib/antelope/ace/grammar/presidence.rb +59 -0
- data/lib/antelope/ace/grammar/production.rb +47 -0
- data/lib/antelope/ace/grammar/productions.rb +119 -0
- data/lib/antelope/ace/grammar/terminals.rb +41 -0
- data/lib/antelope/ace/grammar.rb +59 -0
- data/lib/antelope/ace/presidence.rb +51 -0
- data/lib/antelope/ace/scanner/first.rb +61 -0
- data/lib/antelope/ace/scanner/second.rb +160 -0
- data/lib/antelope/ace/scanner/third.rb +25 -0
- data/lib/antelope/ace/scanner.rb +110 -0
- data/lib/antelope/ace/token/epsilon.rb +22 -0
- data/lib/antelope/ace/token/error.rb +24 -0
- data/lib/antelope/ace/token/nonterminal.rb +15 -0
- data/lib/antelope/ace/token/terminal.rb +15 -0
- data/lib/antelope/ace/token.rb +171 -0
- data/lib/antelope/ace.rb +50 -0
- data/lib/antelope/automaton.rb +36 -0
- data/lib/antelope/generation/conflictor/conflict.rb +7 -0
- data/lib/antelope/generation/conflictor.rb +45 -0
- data/lib/antelope/generation/constructor/first.rb +52 -0
- data/lib/antelope/generation/constructor/follow.rb +46 -0
- data/lib/antelope/generation/constructor/lookahead.rb +42 -0
- data/lib/antelope/generation/constructor/nullable.rb +40 -0
- data/lib/antelope/generation/constructor.rb +81 -0
- data/lib/antelope/generation/recognizer/rule.rb +93 -0
- data/lib/antelope/generation/recognizer/state.rb +56 -0
- data/lib/antelope/generation/recognizer.rb +152 -0
- data/lib/antelope/generation/tableizer.rb +80 -0
- data/lib/antelope/generation.rb +12 -0
- data/lib/antelope/generator/output.rb +30 -0
- data/lib/antelope/generator/ruby.rb +57 -0
- data/lib/antelope/generator/templates/output.erb +49 -0
- data/lib/antelope/generator/templates/ruby.erb +62 -0
- data/lib/antelope/generator.rb +84 -0
- data/lib/antelope/version.rb +4 -0
- data/lib/antelope.rb +9 -0
- data/spec/antelope/ace/compiler_spec.rb +50 -0
- data/spec/antelope/ace/scanner_spec.rb +27 -0
- data/spec/antelope/automaton_spec.rb +29 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/support/benchmark_helper.rb +5 -0
- metadata +223 -0
@@ -0,0 +1,610 @@
|
|
1
|
+
Productions:
|
2
|
+
0/n0: $start(0) → expression(0:1) $
|
3
|
+
1/n1: expression(13:19) → NUMBER
|
4
|
+
2/l2: expression(13:19) → expression(0:1) "+" expression(10:16)
|
5
|
+
3/l2: expression(13:19) → expression(0:1) "-" expression(11:17)
|
6
|
+
4/l3: expression(13:19) → expression(0:1) "*" expression(12:18)
|
7
|
+
5/l3: expression(13:19) → expression(0:1) "/" expression(13:19)
|
8
|
+
6/n4: expression(13:19) → "(" expression(7:14) ")"
|
9
|
+
7/n4: expression(13:19) → "(" $error ")"
|
10
|
+
20/l2: expression(13:19) → expression(7:14) "+" expression(10:16)
|
11
|
+
21/l2: expression(13:19) → expression(7:14) "-" expression(11:17)
|
12
|
+
22/l3: expression(13:19) → expression(7:14) "*" expression(12:18)
|
13
|
+
23/l3: expression(13:19) → expression(7:14) "/" expression(13:19)
|
14
|
+
31/l2: expression(13:19) → expression(10:16) "+" expression(10:16)
|
15
|
+
32/l2: expression(13:19) → expression(10:16) "-" expression(11:17)
|
16
|
+
33/l3: expression(13:19) → expression(10:16) "*" expression(12:18)
|
17
|
+
34/l3: expression(13:19) → expression(10:16) "/" expression(13:19)
|
18
|
+
39/l2: expression(13:19) → expression(11:17) "+" expression(10:16)
|
19
|
+
40/l2: expression(13:19) → expression(11:17) "-" expression(11:17)
|
20
|
+
41/l3: expression(13:19) → expression(11:17) "*" expression(12:18)
|
21
|
+
42/l3: expression(13:19) → expression(11:17) "/" expression(13:19)
|
22
|
+
47/l2: expression(13:19) → expression(12:18) "+" expression(10:16)
|
23
|
+
48/l2: expression(13:19) → expression(12:18) "-" expression(11:17)
|
24
|
+
49/l3: expression(13:19) → expression(12:18) "*" expression(12:18)
|
25
|
+
50/l3: expression(13:19) → expression(12:18) "/" expression(13:19)
|
26
|
+
55/l2: expression(13:19) → expression(13:19) "+" expression(10:16)
|
27
|
+
56/l2: expression(13:19) → expression(13:19) "-" expression(11:17)
|
28
|
+
57/l3: expression(13:19) → expression(13:19) "*" expression(12:18)
|
29
|
+
58/l3: expression(13:19) → expression(13:19) "/" expression(13:19)
|
30
|
+
|
31
|
+
Original Productions:
|
32
|
+
expression → NUMBER
|
33
|
+
{ |a| a[1] }
|
34
|
+
expression → expression "+" expression
|
35
|
+
{ |a, _, b| a + b }
|
36
|
+
expression → expression "-" expression
|
37
|
+
{ |a, _, b| a - b }
|
38
|
+
expression → expression "*" expression
|
39
|
+
{ |a, _, b| a * b }
|
40
|
+
expression → expression "/" expression
|
41
|
+
{ |a, _, b| a / b }
|
42
|
+
expression → "(" expression ")"
|
43
|
+
{ |_, a, _| a }
|
44
|
+
expression → "(" $error ")"
|
45
|
+
|
46
|
+
$start → expression $
|
47
|
+
|
48
|
+
|
49
|
+
Conflicts:
|
50
|
+
State 16:
|
51
|
+
rules : 68
|
52
|
+
type : shift_reduce
|
53
|
+
tokens: {"+", "-", "*", "/", ")", $}
|
54
|
+
State 17:
|
55
|
+
rules : 74
|
56
|
+
type : shift_reduce
|
57
|
+
tokens: {"+", "-", "*", "/", ")", $}
|
58
|
+
State 18:
|
59
|
+
rules : 80
|
60
|
+
type : shift_reduce
|
61
|
+
tokens: {"+", "-", "*", "/", ")", $}
|
62
|
+
State 19:
|
63
|
+
rules : 86
|
64
|
+
type : shift_reduce
|
65
|
+
tokens: {"+", "-", "*", "/", ")", $}
|
66
|
+
|
67
|
+
Presidence:
|
68
|
+
--- highest
|
69
|
+
nonassoc 4:
|
70
|
+
{LPAREN, RPAREN}
|
71
|
+
left 3:
|
72
|
+
{MULTIPLY, DIVIDE}
|
73
|
+
left 2:
|
74
|
+
{ADD, SUBTRACT}
|
75
|
+
nonassoc 1:
|
76
|
+
{_}
|
77
|
+
nonassoc 0:
|
78
|
+
{$}
|
79
|
+
--- lowest
|
80
|
+
|
81
|
+
Table:
|
82
|
+
{0=>{:expression=>[:state, 1], :NUMBER=>[:state, 2], :LPAREN=>[:state, 7]},
|
83
|
+
1=>
|
84
|
+
{:"$"=>[:state, 9],
|
85
|
+
:ADD=>[:state, 10],
|
86
|
+
:SUBTRACT=>[:state, 11],
|
87
|
+
:MULTIPLY=>[:state, 12],
|
88
|
+
:DIVIDE=>[:state, 13]},
|
89
|
+
2=>
|
90
|
+
{:ADD=>[:reduce, 1],
|
91
|
+
:SUBTRACT=>[:reduce, 1],
|
92
|
+
:MULTIPLY=>[:reduce, 1],
|
93
|
+
:DIVIDE=>[:reduce, 1],
|
94
|
+
:RPAREN=>[:reduce, 1],
|
95
|
+
:"$"=>[:reduce, 1]},
|
96
|
+
3=>{:ADD=>[:state, 10]},
|
97
|
+
4=>{:SUBTRACT=>[:state, 11]},
|
98
|
+
5=>{:MULTIPLY=>[:state, 12]},
|
99
|
+
6=>{:DIVIDE=>[:state, 13]},
|
100
|
+
7=>
|
101
|
+
{:expression=>[:state, 14],
|
102
|
+
:NUMBER=>[:state, 2],
|
103
|
+
:LPAREN=>[:state, 7],
|
104
|
+
:$error=>[:state, 15]},
|
105
|
+
8=>{:$error=>[:state, 15]},
|
106
|
+
9=>{:"$"=>[:accept, 0]},
|
107
|
+
10=>{:expression=>[:state, 16], :NUMBER=>[:state, 2], :LPAREN=>[:state, 7]},
|
108
|
+
11=>{:expression=>[:state, 17], :NUMBER=>[:state, 2], :LPAREN=>[:state, 7]},
|
109
|
+
12=>{:expression=>[:state, 18], :NUMBER=>[:state, 2], :LPAREN=>[:state, 7]},
|
110
|
+
13=>{:expression=>[:state, 19], :NUMBER=>[:state, 2], :LPAREN=>[:state, 7]},
|
111
|
+
14=>
|
112
|
+
{:"$"=>[:state, 9],
|
113
|
+
:ADD=>[:state, 10],
|
114
|
+
:SUBTRACT=>[:state, 11],
|
115
|
+
:MULTIPLY=>[:state, 12],
|
116
|
+
:DIVIDE=>[:state, 13],
|
117
|
+
:RPAREN=>[:state, 20]},
|
118
|
+
15=>{:RPAREN=>[:state, 21]},
|
119
|
+
16=>
|
120
|
+
{:"$"=>[:reduce, 2],
|
121
|
+
:ADD=>[:reduce, 2],
|
122
|
+
:SUBTRACT=>[:reduce, 2],
|
123
|
+
:MULTIPLY=>[:state, 12],
|
124
|
+
:DIVIDE=>[:state, 13],
|
125
|
+
:RPAREN=>[:reduce, 2]},
|
126
|
+
17=>
|
127
|
+
{:"$"=>[:reduce, 3],
|
128
|
+
:ADD=>[:reduce, 3],
|
129
|
+
:SUBTRACT=>[:reduce, 3],
|
130
|
+
:MULTIPLY=>[:state, 12],
|
131
|
+
:DIVIDE=>[:state, 13],
|
132
|
+
:RPAREN=>[:reduce, 3]},
|
133
|
+
18=>
|
134
|
+
{:"$"=>[:reduce, 4],
|
135
|
+
:ADD=>[:reduce, 4],
|
136
|
+
:SUBTRACT=>[:reduce, 4],
|
137
|
+
:MULTIPLY=>[:reduce, 4],
|
138
|
+
:DIVIDE=>[:reduce, 4],
|
139
|
+
:RPAREN=>[:reduce, 4]},
|
140
|
+
19=>
|
141
|
+
{:"$"=>[:reduce, 5],
|
142
|
+
:ADD=>[:reduce, 5],
|
143
|
+
:SUBTRACT=>[:reduce, 5],
|
144
|
+
:MULTIPLY=>[:reduce, 5],
|
145
|
+
:DIVIDE=>[:reduce, 5],
|
146
|
+
:RPAREN=>[:reduce, 5]},
|
147
|
+
20=>
|
148
|
+
{:ADD=>[:reduce, 6],
|
149
|
+
:SUBTRACT=>[:reduce, 6],
|
150
|
+
:MULTIPLY=>[:reduce, 6],
|
151
|
+
:DIVIDE=>[:reduce, 6],
|
152
|
+
:RPAREN=>[:reduce, 6],
|
153
|
+
:"$"=>[:reduce, 6]},
|
154
|
+
21=>
|
155
|
+
{:ADD=>[:reduce, 7],
|
156
|
+
:SUBTRACT=>[:reduce, 7],
|
157
|
+
:MULTIPLY=>[:reduce, 7],
|
158
|
+
:DIVIDE=>[:reduce, 7],
|
159
|
+
:RPAREN=>[:reduce, 7],
|
160
|
+
:"$"=>[:reduce, 7]}}
|
161
|
+
|
162
|
+
[#<Antelope::Generation::Recognizer::Rule id=0 left=$start(0) right=[expression(0:1) $] position=0>,
|
163
|
+
#<Antelope::Generation::Recognizer::Rule id=1 left=expression(13:19) right=[NUMBER] position=0>,
|
164
|
+
#<Antelope::Generation::Recognizer::Rule id=2 left=expression(13:19) right=[expression(0:1) "+" expression(10:16)] position=0>,
|
165
|
+
#<Antelope::Generation::Recognizer::Rule id=3 left=expression(13:19) right=[expression(0:1) "-" expression(11:17)] position=0>,
|
166
|
+
#<Antelope::Generation::Recognizer::Rule id=4 left=expression(13:19) right=[expression(0:1) "*" expression(12:18)] position=0>,
|
167
|
+
#<Antelope::Generation::Recognizer::Rule id=5 left=expression(13:19) right=[expression(0:1) "/" expression(13:19)] position=0>,
|
168
|
+
#<Antelope::Generation::Recognizer::Rule id=6 left=expression(13:19) right=["(" expression(7:14) ")"] position=0>,
|
169
|
+
#<Antelope::Generation::Recognizer::Rule id=7 left=expression(13:19) right=["(" $error ")"] position=0>,
|
170
|
+
nil,
|
171
|
+
nil,
|
172
|
+
nil,
|
173
|
+
nil,
|
174
|
+
nil,
|
175
|
+
#<Antelope::Generation::Recognizer::Rule id=13 left=expression(13:19) right=[NUMBER] position=1>,
|
176
|
+
nil,
|
177
|
+
nil,
|
178
|
+
nil,
|
179
|
+
nil,
|
180
|
+
#<Antelope::Generation::Recognizer::Rule id=18 left=expression(13:19) right=["(" expression ")"] position=1>,
|
181
|
+
#<Antelope::Generation::Recognizer::Rule id=19 left=expression(13:19) right=[NUMBER] position=0>,
|
182
|
+
#<Antelope::Generation::Recognizer::Rule id=20 left=expression(13:19) right=[expression(7:14) "+" expression(10:16)] position=0>,
|
183
|
+
#<Antelope::Generation::Recognizer::Rule id=21 left=expression(13:19) right=[expression(7:14) "-" expression(11:17)] position=0>,
|
184
|
+
#<Antelope::Generation::Recognizer::Rule id=22 left=expression(13:19) right=[expression(7:14) "*" expression(12:18)] position=0>,
|
185
|
+
#<Antelope::Generation::Recognizer::Rule id=23 left=expression(13:19) right=[expression(7:14) "/" expression(13:19)] position=0>,
|
186
|
+
#<Antelope::Generation::Recognizer::Rule id=24 left=expression(13:19) right=["(" expression(7:14) ")"] position=0>,
|
187
|
+
#<Antelope::Generation::Recognizer::Rule id=25 left=expression(13:19) right=["(" $error ")"] position=0>,
|
188
|
+
nil,
|
189
|
+
#<Antelope::Generation::Recognizer::Rule id=27 left=expression(13:19) right=["(" $error ")"] position=1>,
|
190
|
+
#<Antelope::Generation::Recognizer::Rule id=28 left=$start(0) right=[expression $] position=2>,
|
191
|
+
#<Antelope::Generation::Recognizer::Rule id=29 left=expression(13:19) right=[expression "+" expression] position=2>,
|
192
|
+
#<Antelope::Generation::Recognizer::Rule id=30 left=expression(13:19) right=[NUMBER] position=0>,
|
193
|
+
#<Antelope::Generation::Recognizer::Rule id=31 left=expression(13:19) right=[expression(10:16) "+" expression(10:16)] position=0>,
|
194
|
+
#<Antelope::Generation::Recognizer::Rule id=32 left=expression(13:19) right=[expression(10:16) "-" expression(11:17)] position=0>,
|
195
|
+
#<Antelope::Generation::Recognizer::Rule id=33 left=expression(13:19) right=[expression(10:16) "*" expression(12:18)] position=0>,
|
196
|
+
#<Antelope::Generation::Recognizer::Rule id=34 left=expression(13:19) right=[expression(10:16) "/" expression(13:19)] position=0>,
|
197
|
+
#<Antelope::Generation::Recognizer::Rule id=35 left=expression(13:19) right=["(" expression(7:14) ")"] position=0>,
|
198
|
+
#<Antelope::Generation::Recognizer::Rule id=36 left=expression(13:19) right=["(" $error ")"] position=0>,
|
199
|
+
#<Antelope::Generation::Recognizer::Rule id=37 left=expression(13:19) right=[expression "-" expression] position=2>,
|
200
|
+
#<Antelope::Generation::Recognizer::Rule id=38 left=expression(13:19) right=[NUMBER] position=0>,
|
201
|
+
#<Antelope::Generation::Recognizer::Rule id=39 left=expression(13:19) right=[expression(11:17) "+" expression(10:16)] position=0>,
|
202
|
+
#<Antelope::Generation::Recognizer::Rule id=40 left=expression(13:19) right=[expression(11:17) "-" expression(11:17)] position=0>,
|
203
|
+
#<Antelope::Generation::Recognizer::Rule id=41 left=expression(13:19) right=[expression(11:17) "*" expression(12:18)] position=0>,
|
204
|
+
#<Antelope::Generation::Recognizer::Rule id=42 left=expression(13:19) right=[expression(11:17) "/" expression(13:19)] position=0>,
|
205
|
+
#<Antelope::Generation::Recognizer::Rule id=43 left=expression(13:19) right=["(" expression(7:14) ")"] position=0>,
|
206
|
+
#<Antelope::Generation::Recognizer::Rule id=44 left=expression(13:19) right=["(" $error ")"] position=0>,
|
207
|
+
#<Antelope::Generation::Recognizer::Rule id=45 left=expression(13:19) right=[expression "*" expression] position=2>,
|
208
|
+
#<Antelope::Generation::Recognizer::Rule id=46 left=expression(13:19) right=[NUMBER] position=0>,
|
209
|
+
#<Antelope::Generation::Recognizer::Rule id=47 left=expression(13:19) right=[expression(12:18) "+" expression(10:16)] position=0>,
|
210
|
+
#<Antelope::Generation::Recognizer::Rule id=48 left=expression(13:19) right=[expression(12:18) "-" expression(11:17)] position=0>,
|
211
|
+
#<Antelope::Generation::Recognizer::Rule id=49 left=expression(13:19) right=[expression(12:18) "*" expression(12:18)] position=0>,
|
212
|
+
#<Antelope::Generation::Recognizer::Rule id=50 left=expression(13:19) right=[expression(12:18) "/" expression(13:19)] position=0>,
|
213
|
+
#<Antelope::Generation::Recognizer::Rule id=51 left=expression(13:19) right=["(" expression(7:14) ")"] position=0>,
|
214
|
+
#<Antelope::Generation::Recognizer::Rule id=52 left=expression(13:19) right=["(" $error ")"] position=0>,
|
215
|
+
#<Antelope::Generation::Recognizer::Rule id=53 left=expression(13:19) right=[expression "/" expression] position=2>,
|
216
|
+
#<Antelope::Generation::Recognizer::Rule id=54 left=expression(13:19) right=[NUMBER] position=0>,
|
217
|
+
#<Antelope::Generation::Recognizer::Rule id=55 left=expression(13:19) right=[expression(13:19) "+" expression(10:16)] position=0>,
|
218
|
+
#<Antelope::Generation::Recognizer::Rule id=56 left=expression(13:19) right=[expression(13:19) "-" expression(11:17)] position=0>,
|
219
|
+
#<Antelope::Generation::Recognizer::Rule id=57 left=expression(13:19) right=[expression(13:19) "*" expression(12:18)] position=0>,
|
220
|
+
#<Antelope::Generation::Recognizer::Rule id=58 left=expression(13:19) right=[expression(13:19) "/" expression(13:19)] position=0>,
|
221
|
+
#<Antelope::Generation::Recognizer::Rule id=59 left=expression(13:19) right=["(" expression(7:14) ")"] position=0>,
|
222
|
+
#<Antelope::Generation::Recognizer::Rule id=60 left=expression(13:19) right=["(" $error ")"] position=0>,
|
223
|
+
#<Antelope::Generation::Recognizer::Rule id=61 left=expression(13:19) right=["(" expression ")"] position=2>,
|
224
|
+
nil,
|
225
|
+
nil,
|
226
|
+
nil,
|
227
|
+
nil,
|
228
|
+
nil,
|
229
|
+
#<Antelope::Generation::Recognizer::Rule id=67 left=expression(13:19) right=["(" $error ")"] position=2>,
|
230
|
+
#<Antelope::Generation::Recognizer::Rule id=68 left=expression(13:19) right=[expression "+" expression] position=3>,
|
231
|
+
nil,
|
232
|
+
nil,
|
233
|
+
nil,
|
234
|
+
nil,
|
235
|
+
nil,
|
236
|
+
#<Antelope::Generation::Recognizer::Rule id=74 left=expression(13:19) right=[expression "-" expression] position=3>,
|
237
|
+
nil,
|
238
|
+
nil,
|
239
|
+
nil,
|
240
|
+
nil,
|
241
|
+
nil,
|
242
|
+
#<Antelope::Generation::Recognizer::Rule id=80 left=expression(13:19) right=[expression "*" expression] position=3>,
|
243
|
+
nil,
|
244
|
+
nil,
|
245
|
+
nil,
|
246
|
+
nil,
|
247
|
+
nil,
|
248
|
+
#<Antelope::Generation::Recognizer::Rule id=86 left=expression(13:19) right=[expression "/" expression] position=3>,
|
249
|
+
#<Antelope::Generation::Recognizer::Rule id=87 left=$start(0) right=[expression $] position=1>,
|
250
|
+
#<Antelope::Generation::Recognizer::Rule id=88 left=expression(13:19) right=[expression "+" expression] position=1>,
|
251
|
+
#<Antelope::Generation::Recognizer::Rule id=89 left=expression(13:19) right=[expression "-" expression] position=1>,
|
252
|
+
#<Antelope::Generation::Recognizer::Rule id=90 left=expression(13:19) right=[expression "*" expression] position=1>,
|
253
|
+
#<Antelope::Generation::Recognizer::Rule id=91 left=expression(13:19) right=[expression "/" expression] position=1>,
|
254
|
+
#<Antelope::Generation::Recognizer::Rule id=92 left=expression(13:19) right=["(" expression ")"] position=3>,
|
255
|
+
#<Antelope::Generation::Recognizer::Rule id=93 left=expression(13:19) right=["(" $error ")"] position=3>]
|
256
|
+
|
257
|
+
State 0:
|
258
|
+
rules:
|
259
|
+
0/n0: $start(0) → • expression(0:1) $
|
260
|
+
{}
|
261
|
+
1/n1: expression(13:19) → • NUMBER
|
262
|
+
{}
|
263
|
+
2/l2: expression(13:19) → • expression(0:1) "+" expression(10:16)
|
264
|
+
{}
|
265
|
+
3/l2: expression(13:19) → • expression(0:1) "-" expression(11:17)
|
266
|
+
{}
|
267
|
+
4/l3: expression(13:19) → • expression(0:1) "*" expression(12:18)
|
268
|
+
{}
|
269
|
+
5/l3: expression(13:19) → • expression(0:1) "/" expression(13:19)
|
270
|
+
{}
|
271
|
+
6/n4: expression(13:19) → • "(" expression(7:14) ")"
|
272
|
+
{}
|
273
|
+
7/n4: expression(13:19) → • "(" $error ")"
|
274
|
+
{}
|
275
|
+
|
276
|
+
transitions:
|
277
|
+
expression: State 1
|
278
|
+
NUMBER : State 2
|
279
|
+
LPAREN : State 7
|
280
|
+
|
281
|
+
State 1:
|
282
|
+
rules:
|
283
|
+
87/n0: $start(0) → expression • $
|
284
|
+
{}
|
285
|
+
88/l2: expression(13:19) → expression • "+" expression
|
286
|
+
{}
|
287
|
+
89/l2: expression(13:19) → expression • "-" expression
|
288
|
+
{}
|
289
|
+
90/l3: expression(13:19) → expression • "*" expression
|
290
|
+
{}
|
291
|
+
91/l3: expression(13:19) → expression • "/" expression
|
292
|
+
{}
|
293
|
+
|
294
|
+
transitions:
|
295
|
+
$ : State 9
|
296
|
+
ADD : State 10
|
297
|
+
SUBTRACT: State 11
|
298
|
+
MULTIPLY: State 12
|
299
|
+
DIVIDE : State 13
|
300
|
+
|
301
|
+
State 2:
|
302
|
+
rules:
|
303
|
+
13/n1: expression(13:19) → NUMBER •
|
304
|
+
{"+", "-", "*", "/", ")", $}
|
305
|
+
|
306
|
+
transitions:
|
307
|
+
|
308
|
+
State 3:
|
309
|
+
rules:
|
310
|
+
88/l2: expression(13:19) → expression • "+" expression
|
311
|
+
{}
|
312
|
+
|
313
|
+
transitions:
|
314
|
+
ADD: State 10
|
315
|
+
|
316
|
+
State 4:
|
317
|
+
rules:
|
318
|
+
89/l2: expression(13:19) → expression • "-" expression
|
319
|
+
{}
|
320
|
+
|
321
|
+
transitions:
|
322
|
+
SUBTRACT: State 11
|
323
|
+
|
324
|
+
State 5:
|
325
|
+
rules:
|
326
|
+
90/l3: expression(13:19) → expression • "*" expression
|
327
|
+
{}
|
328
|
+
|
329
|
+
transitions:
|
330
|
+
MULTIPLY: State 12
|
331
|
+
|
332
|
+
State 6:
|
333
|
+
rules:
|
334
|
+
91/l3: expression(13:19) → expression • "/" expression
|
335
|
+
{}
|
336
|
+
|
337
|
+
transitions:
|
338
|
+
DIVIDE: State 13
|
339
|
+
|
340
|
+
State 7:
|
341
|
+
rules:
|
342
|
+
18/n4: expression(13:19) → "(" • expression ")"
|
343
|
+
{}
|
344
|
+
19/n1: expression(13:19) → • NUMBER
|
345
|
+
{}
|
346
|
+
20/l2: expression(13:19) → • expression(7:14) "+" expression(10:16)
|
347
|
+
{}
|
348
|
+
21/l2: expression(13:19) → • expression(7:14) "-" expression(11:17)
|
349
|
+
{}
|
350
|
+
22/l3: expression(13:19) → • expression(7:14) "*" expression(12:18)
|
351
|
+
{}
|
352
|
+
23/l3: expression(13:19) → • expression(7:14) "/" expression(13:19)
|
353
|
+
{}
|
354
|
+
24/n4: expression(13:19) → • "(" expression(7:14) ")"
|
355
|
+
{}
|
356
|
+
25/n4: expression(13:19) → • "(" $error ")"
|
357
|
+
{}
|
358
|
+
27/n4: expression(13:19) → "(" • $error ")"
|
359
|
+
{}
|
360
|
+
|
361
|
+
transitions:
|
362
|
+
expression: State 14
|
363
|
+
NUMBER : State 2
|
364
|
+
LPAREN : State 7
|
365
|
+
$error : State 15
|
366
|
+
|
367
|
+
State 8:
|
368
|
+
rules:
|
369
|
+
27/n4: expression(13:19) → "(" • $error ")"
|
370
|
+
{}
|
371
|
+
|
372
|
+
transitions:
|
373
|
+
$error: State 15
|
374
|
+
|
375
|
+
State 9:
|
376
|
+
rules:
|
377
|
+
28/n0: $start(0) → expression $ •
|
378
|
+
{}
|
379
|
+
|
380
|
+
transitions:
|
381
|
+
|
382
|
+
State 10:
|
383
|
+
rules:
|
384
|
+
29/l2: expression(13:19) → expression "+" • expression
|
385
|
+
{}
|
386
|
+
30/n1: expression(13:19) → • NUMBER
|
387
|
+
{}
|
388
|
+
31/l2: expression(13:19) → • expression(10:16) "+" expression(10:16)
|
389
|
+
{}
|
390
|
+
32/l2: expression(13:19) → • expression(10:16) "-" expression(11:17)
|
391
|
+
{}
|
392
|
+
33/l3: expression(13:19) → • expression(10:16) "*" expression(12:18)
|
393
|
+
{}
|
394
|
+
34/l3: expression(13:19) → • expression(10:16) "/" expression(13:19)
|
395
|
+
{}
|
396
|
+
35/n4: expression(13:19) → • "(" expression(7:14) ")"
|
397
|
+
{}
|
398
|
+
36/n4: expression(13:19) → • "(" $error ")"
|
399
|
+
{}
|
400
|
+
|
401
|
+
transitions:
|
402
|
+
expression: State 16
|
403
|
+
NUMBER : State 2
|
404
|
+
LPAREN : State 7
|
405
|
+
|
406
|
+
State 11:
|
407
|
+
rules:
|
408
|
+
37/l2: expression(13:19) → expression "-" • expression
|
409
|
+
{}
|
410
|
+
38/n1: expression(13:19) → • NUMBER
|
411
|
+
{}
|
412
|
+
39/l2: expression(13:19) → • expression(11:17) "+" expression(10:16)
|
413
|
+
{}
|
414
|
+
40/l2: expression(13:19) → • expression(11:17) "-" expression(11:17)
|
415
|
+
{}
|
416
|
+
41/l3: expression(13:19) → • expression(11:17) "*" expression(12:18)
|
417
|
+
{}
|
418
|
+
42/l3: expression(13:19) → • expression(11:17) "/" expression(13:19)
|
419
|
+
{}
|
420
|
+
43/n4: expression(13:19) → • "(" expression(7:14) ")"
|
421
|
+
{}
|
422
|
+
44/n4: expression(13:19) → • "(" $error ")"
|
423
|
+
{}
|
424
|
+
|
425
|
+
transitions:
|
426
|
+
expression: State 17
|
427
|
+
NUMBER : State 2
|
428
|
+
LPAREN : State 7
|
429
|
+
|
430
|
+
State 12:
|
431
|
+
rules:
|
432
|
+
45/l3: expression(13:19) → expression "*" • expression
|
433
|
+
{}
|
434
|
+
46/n1: expression(13:19) → • NUMBER
|
435
|
+
{}
|
436
|
+
47/l2: expression(13:19) → • expression(12:18) "+" expression(10:16)
|
437
|
+
{}
|
438
|
+
48/l2: expression(13:19) → • expression(12:18) "-" expression(11:17)
|
439
|
+
{}
|
440
|
+
49/l3: expression(13:19) → • expression(12:18) "*" expression(12:18)
|
441
|
+
{}
|
442
|
+
50/l3: expression(13:19) → • expression(12:18) "/" expression(13:19)
|
443
|
+
{}
|
444
|
+
51/n4: expression(13:19) → • "(" expression(7:14) ")"
|
445
|
+
{}
|
446
|
+
52/n4: expression(13:19) → • "(" $error ")"
|
447
|
+
{}
|
448
|
+
|
449
|
+
transitions:
|
450
|
+
expression: State 18
|
451
|
+
NUMBER : State 2
|
452
|
+
LPAREN : State 7
|
453
|
+
|
454
|
+
State 13:
|
455
|
+
rules:
|
456
|
+
53/l3: expression(13:19) → expression "/" • expression
|
457
|
+
{}
|
458
|
+
54/n1: expression(13:19) → • NUMBER
|
459
|
+
{}
|
460
|
+
55/l2: expression(13:19) → • expression(13:19) "+" expression(10:16)
|
461
|
+
{}
|
462
|
+
56/l2: expression(13:19) → • expression(13:19) "-" expression(11:17)
|
463
|
+
{}
|
464
|
+
57/l3: expression(13:19) → • expression(13:19) "*" expression(12:18)
|
465
|
+
{}
|
466
|
+
58/l3: expression(13:19) → • expression(13:19) "/" expression(13:19)
|
467
|
+
{}
|
468
|
+
59/n4: expression(13:19) → • "(" expression(7:14) ")"
|
469
|
+
{}
|
470
|
+
60/n4: expression(13:19) → • "(" $error ")"
|
471
|
+
{}
|
472
|
+
|
473
|
+
transitions:
|
474
|
+
expression: State 19
|
475
|
+
NUMBER : State 2
|
476
|
+
LPAREN : State 7
|
477
|
+
|
478
|
+
State 14:
|
479
|
+
rules:
|
480
|
+
61/n4: expression(13:19) → "(" expression • ")"
|
481
|
+
{}
|
482
|
+
87/n0: $start(0) → expression • $
|
483
|
+
{}
|
484
|
+
88/l2: expression(13:19) → expression • "+" expression
|
485
|
+
{}
|
486
|
+
89/l2: expression(13:19) → expression • "-" expression
|
487
|
+
{}
|
488
|
+
90/l3: expression(13:19) → expression • "*" expression
|
489
|
+
{}
|
490
|
+
91/l3: expression(13:19) → expression • "/" expression
|
491
|
+
{}
|
492
|
+
|
493
|
+
transitions:
|
494
|
+
$ : State 9
|
495
|
+
ADD : State 10
|
496
|
+
SUBTRACT: State 11
|
497
|
+
MULTIPLY: State 12
|
498
|
+
DIVIDE : State 13
|
499
|
+
RPAREN : State 20
|
500
|
+
|
501
|
+
State 15:
|
502
|
+
rules:
|
503
|
+
67/n4: expression(13:19) → "(" $error • ")"
|
504
|
+
{}
|
505
|
+
|
506
|
+
transitions:
|
507
|
+
RPAREN: State 21
|
508
|
+
|
509
|
+
State 16:
|
510
|
+
rules:
|
511
|
+
68/l2: expression(13:19) → expression "+" expression •
|
512
|
+
{"+", "-", "*", "/", ")", $}
|
513
|
+
87/n0: $start(0) → expression • $
|
514
|
+
{}
|
515
|
+
88/l2: expression(13:19) → expression • "+" expression
|
516
|
+
{}
|
517
|
+
89/l2: expression(13:19) → expression • "-" expression
|
518
|
+
{}
|
519
|
+
90/l3: expression(13:19) → expression • "*" expression
|
520
|
+
{}
|
521
|
+
91/l3: expression(13:19) → expression • "/" expression
|
522
|
+
{}
|
523
|
+
|
524
|
+
transitions:
|
525
|
+
$ : State 9
|
526
|
+
ADD : State 10
|
527
|
+
SUBTRACT: State 11
|
528
|
+
MULTIPLY: State 12
|
529
|
+
DIVIDE : State 13
|
530
|
+
|
531
|
+
State 17:
|
532
|
+
rules:
|
533
|
+
74/l2: expression(13:19) → expression "-" expression •
|
534
|
+
{"+", "-", "*", "/", ")", $}
|
535
|
+
87/n0: $start(0) → expression • $
|
536
|
+
{}
|
537
|
+
88/l2: expression(13:19) → expression • "+" expression
|
538
|
+
{}
|
539
|
+
89/l2: expression(13:19) → expression • "-" expression
|
540
|
+
{}
|
541
|
+
90/l3: expression(13:19) → expression • "*" expression
|
542
|
+
{}
|
543
|
+
91/l3: expression(13:19) → expression • "/" expression
|
544
|
+
{}
|
545
|
+
|
546
|
+
transitions:
|
547
|
+
$ : State 9
|
548
|
+
ADD : State 10
|
549
|
+
SUBTRACT: State 11
|
550
|
+
MULTIPLY: State 12
|
551
|
+
DIVIDE : State 13
|
552
|
+
|
553
|
+
State 18:
|
554
|
+
rules:
|
555
|
+
80/l3: expression(13:19) → expression "*" expression •
|
556
|
+
{"+", "-", "*", "/", ")", $}
|
557
|
+
87/n0: $start(0) → expression • $
|
558
|
+
{}
|
559
|
+
88/l2: expression(13:19) → expression • "+" expression
|
560
|
+
{}
|
561
|
+
89/l2: expression(13:19) → expression • "-" expression
|
562
|
+
{}
|
563
|
+
90/l3: expression(13:19) → expression • "*" expression
|
564
|
+
{}
|
565
|
+
91/l3: expression(13:19) → expression • "/" expression
|
566
|
+
{}
|
567
|
+
|
568
|
+
transitions:
|
569
|
+
$ : State 9
|
570
|
+
ADD : State 10
|
571
|
+
SUBTRACT: State 11
|
572
|
+
MULTIPLY: State 12
|
573
|
+
DIVIDE : State 13
|
574
|
+
|
575
|
+
State 19:
|
576
|
+
rules:
|
577
|
+
86/l3: expression(13:19) → expression "/" expression •
|
578
|
+
{"+", "-", "*", "/", ")", $}
|
579
|
+
87/n0: $start(0) → expression • $
|
580
|
+
{}
|
581
|
+
88/l2: expression(13:19) → expression • "+" expression
|
582
|
+
{}
|
583
|
+
89/l2: expression(13:19) → expression • "-" expression
|
584
|
+
{}
|
585
|
+
90/l3: expression(13:19) → expression • "*" expression
|
586
|
+
{}
|
587
|
+
91/l3: expression(13:19) → expression • "/" expression
|
588
|
+
{}
|
589
|
+
|
590
|
+
transitions:
|
591
|
+
$ : State 9
|
592
|
+
ADD : State 10
|
593
|
+
SUBTRACT: State 11
|
594
|
+
MULTIPLY: State 12
|
595
|
+
DIVIDE : State 13
|
596
|
+
|
597
|
+
State 20:
|
598
|
+
rules:
|
599
|
+
92/n4: expression(13:19) → "(" expression ")" •
|
600
|
+
{"+", "-", "*", "/", ")", $}
|
601
|
+
|
602
|
+
transitions:
|
603
|
+
|
604
|
+
State 21:
|
605
|
+
rules:
|
606
|
+
93/n4: expression(13:19) → "(" $error ")" •
|
607
|
+
{"+", "-", "*", "/", ")", $}
|
608
|
+
|
609
|
+
transitions:
|
610
|
+
|
data/examples/simple.ace
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
%{
|
2
|
+
require "antelope"
|
3
|
+
%}
|
4
|
+
|
5
|
+
%require "0.0.1"
|
6
|
+
%type "ruby"
|
7
|
+
|
8
|
+
%terminal IDENT
|
9
|
+
%terminal STAR "*"
|
10
|
+
%terminal EQUALS "="
|
11
|
+
|
12
|
+
%%
|
13
|
+
|
14
|
+
e: l EQUALS r
|
15
|
+
| r
|
16
|
+
|
17
|
+
l: IDENT
|
18
|
+
| STAR r
|
19
|
+
|
20
|
+
r: l
|
21
|
+
|
22
|
+
%%
|
23
|
+
|
24
|
+
class SimpleParser < Antelope::Parser
|
25
|
+
%{write}
|
26
|
+
end
|