antelope 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -0
- data/CONTRIBUTING.md +4 -4
- data/GENERATORS.md +61 -19
- data/README.md +84 -9
- data/TODO.md +58 -0
- data/examples/deterministic.ace +21 -9
- data/examples/example.ace +16 -10
- data/examples/example.output +213 -146
- data/examples/simple.ace +1 -1
- data/lib/antelope/ace/compiler.rb +52 -15
- data/lib/antelope/ace/errors.rb +7 -0
- data/lib/antelope/ace/grammar/generation.rb +3 -3
- data/lib/antelope/ace/grammar/precedences.rb +5 -7
- data/lib/antelope/ace/grammar/productions.rb +36 -11
- data/lib/antelope/ace/grammar/{terminals.rb → symbols.rb} +25 -2
- data/lib/antelope/ace/grammar.rb +12 -3
- data/lib/antelope/ace/precedence.rb +4 -0
- data/lib/antelope/ace/scanner/argument.rb +57 -0
- data/lib/antelope/ace/scanner/first.rb +32 -6
- data/lib/antelope/ace/scanner/second.rb +23 -8
- data/lib/antelope/ace/scanner.rb +32 -26
- data/lib/antelope/ace/token.rb +21 -2
- data/lib/antelope/cli.rb +22 -2
- data/lib/antelope/generation/constructor/first.rb +1 -1
- data/lib/antelope/generation/constructor.rb +2 -0
- data/lib/antelope/generation/null.rb +13 -0
- data/lib/antelope/generation/recognizer/rule.rb +4 -3
- data/lib/antelope/generation/recognizer/state.rb +18 -3
- data/lib/antelope/generation/recognizer.rb +19 -24
- data/lib/antelope/generation/tableizer.rb +30 -2
- data/lib/antelope/generation.rb +1 -0
- data/lib/antelope/generator/base.rb +150 -13
- data/lib/antelope/generator/c.rb +11 -0
- data/lib/antelope/generator/c_header.rb +105 -0
- data/lib/antelope/generator/c_source.rb +39 -0
- data/lib/antelope/generator/null.rb +5 -0
- data/lib/antelope/generator/output.rb +3 -3
- data/lib/antelope/generator/ruby.rb +23 -5
- data/lib/antelope/generator/templates/c_header.ant +36 -0
- data/lib/antelope/generator/templates/c_source.ant +202 -0
- data/lib/antelope/generator/templates/output.ant +68 -0
- data/lib/antelope/generator/templates/ruby.ant +146 -0
- data/lib/antelope/generator.rb +15 -3
- data/lib/antelope/template/compiler.rb +78 -0
- data/lib/antelope/template/errors.rb +9 -0
- data/lib/antelope/template/scanner.rb +111 -0
- data/lib/antelope/template.rb +60 -0
- data/lib/antelope/version.rb +1 -1
- data/lib/antelope.rb +1 -0
- data/spec/antelope/template_spec.rb +39 -0
- data/subl/Ace (Ruby).JSON-tmLanguage +94 -0
- data/subl/Ace (Ruby).tmLanguage +153 -0
- metadata +21 -8
- data/examples/deterministic.output +0 -131
- data/examples/simple.output +0 -121
- data/lib/antelope/generator/templates/output.erb +0 -56
- data/lib/antelope/generator/templates/ruby.erb +0 -63
data/examples/example.output
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
Productions:
|
2
|
-
0 $start: expression $
|
2
|
+
0 $start: expression $end
|
3
3
|
1 expression: NUMBER { |a| a[1] }
|
4
|
-
2 expression: expression "
|
5
|
-
3 expression: expression "
|
6
|
-
4 expression: expression "
|
7
|
-
5 expression: expression "
|
8
|
-
6 expression: "
|
9
|
-
7 expression: "("
|
4
|
+
2 expression: expression "^" expression { |a, _, b| a** b }
|
5
|
+
3 expression: expression "+" expression { |a, _, b| a + b }
|
6
|
+
4 expression: expression "-" expression { |a, _, b| a - b }
|
7
|
+
5 expression: expression "*" expression { |a, _, b| a * b }
|
8
|
+
6 expression: expression "/" expression { |a, _, b| a / b }
|
9
|
+
7 expression: "(" expression ")" { |_, a, _| a }
|
10
|
+
8 expression: "(" $error ")" { |_, e, _| e[1] }
|
11
|
+
|
10
12
|
|
11
13
|
Precedence:
|
12
14
|
--- highest
|
13
|
-
|
14
|
-
{
|
15
|
+
right 4:
|
16
|
+
{EXPONENTIATE}
|
15
17
|
left 3:
|
16
18
|
{MULTIPLY, DIVIDE}
|
17
19
|
left 2:
|
@@ -19,25 +21,28 @@ Precedence:
|
|
19
21
|
nonassoc 1:
|
20
22
|
{_}
|
21
23
|
nonassoc 0:
|
22
|
-
{$}
|
24
|
+
{$end}
|
23
25
|
--- lowest
|
24
26
|
|
27
|
+
|
25
28
|
State 0:
|
26
|
-
0/n0: $start → • expression $
|
29
|
+
0/n0: $start → • expression $end
|
27
30
|
{}
|
28
31
|
1/n1: expression → • NUMBER
|
29
32
|
{}
|
30
|
-
2/
|
33
|
+
2/r4: expression → • expression "^" expression
|
31
34
|
{}
|
32
|
-
3/l2: expression → • expression "
|
35
|
+
3/l2: expression → • expression "+" expression
|
33
36
|
{}
|
34
|
-
4/
|
37
|
+
4/l2: expression → • expression "-" expression
|
35
38
|
{}
|
36
|
-
5/l3: expression → • expression "
|
39
|
+
5/l3: expression → • expression "*" expression
|
37
40
|
{}
|
38
|
-
6/
|
41
|
+
6/l3: expression → • expression "/" expression
|
39
42
|
{}
|
40
|
-
7/
|
43
|
+
7/n1: expression → • "(" expression ")"
|
44
|
+
{}
|
45
|
+
8/n1: expression → • "(" $error ")"
|
41
46
|
{}
|
42
47
|
transitions:
|
43
48
|
expression: State 1
|
@@ -45,274 +50,336 @@ Precedence:
|
|
45
50
|
"(": State 3
|
46
51
|
|
47
52
|
State 1:
|
48
|
-
|
53
|
+
9/n0: $start → expression • $end
|
54
|
+
{}
|
55
|
+
10/r4: expression → expression • "^" expression
|
49
56
|
{}
|
50
|
-
|
57
|
+
11/l2: expression → expression • "+" expression
|
51
58
|
{}
|
52
|
-
|
59
|
+
12/l2: expression → expression • "-" expression
|
53
60
|
{}
|
54
|
-
|
61
|
+
13/l3: expression → expression • "*" expression
|
55
62
|
{}
|
56
|
-
|
63
|
+
14/l3: expression → expression • "/" expression
|
57
64
|
{}
|
58
65
|
transitions:
|
59
|
-
|
60
|
-
"
|
61
|
-
"
|
62
|
-
"
|
63
|
-
"
|
66
|
+
$end: State 4
|
67
|
+
"^": State 5
|
68
|
+
"+": State 6
|
69
|
+
"-": State 7
|
70
|
+
"*": State 8
|
71
|
+
"/": State 9
|
64
72
|
|
65
73
|
State 2:
|
66
|
-
|
67
|
-
{
|
74
|
+
15/n1: expression → NUMBER •
|
75
|
+
{$end, "^", "+", "-", "*", "/", ")"}
|
68
76
|
reductions:
|
69
|
-
|
70
|
-
"+": Rule 1
|
71
|
-
"-": Rule 1
|
72
|
-
"*": Rule 1
|
73
|
-
"/": Rule 1
|
74
|
-
")": Rule 1
|
77
|
+
$default: Rule 1
|
75
78
|
|
76
79
|
State 3:
|
77
|
-
|
80
|
+
16/n1: expression → "(" • expression ")"
|
78
81
|
{}
|
79
|
-
|
82
|
+
17/n1: expression → "(" • $error ")"
|
80
83
|
{}
|
81
|
-
|
84
|
+
18/n1: expression → • NUMBER
|
82
85
|
{}
|
83
|
-
|
86
|
+
19/r4: expression → • expression "^" expression
|
84
87
|
{}
|
85
|
-
|
88
|
+
20/l2: expression → • expression "+" expression
|
86
89
|
{}
|
87
|
-
|
90
|
+
21/l2: expression → • expression "-" expression
|
88
91
|
{}
|
89
|
-
|
92
|
+
22/l3: expression → • expression "*" expression
|
90
93
|
{}
|
91
|
-
|
94
|
+
23/l3: expression → • expression "/" expression
|
92
95
|
{}
|
93
|
-
|
96
|
+
24/n1: expression → • "(" expression ")"
|
97
|
+
{}
|
98
|
+
25/n1: expression → • "(" $error ")"
|
94
99
|
{}
|
95
100
|
transitions:
|
96
|
-
expression: State
|
101
|
+
expression: State 10
|
102
|
+
$error: State 11
|
97
103
|
NUMBER: State 2
|
98
104
|
"(": State 3
|
99
|
-
$error: State 10
|
100
105
|
|
101
106
|
State 4:
|
102
|
-
|
107
|
+
26/n0: $start → expression $end •
|
103
108
|
{}
|
104
109
|
accepting:
|
105
|
-
|
110
|
+
$end: Rule 0
|
106
111
|
|
107
112
|
State 5:
|
108
|
-
|
113
|
+
27/r4: expression → expression "^" • expression
|
114
|
+
{}
|
115
|
+
28/n1: expression → • NUMBER
|
109
116
|
{}
|
110
|
-
|
117
|
+
29/r4: expression → • expression "^" expression
|
111
118
|
{}
|
112
|
-
|
119
|
+
30/l2: expression → • expression "+" expression
|
113
120
|
{}
|
114
|
-
|
121
|
+
31/l2: expression → • expression "-" expression
|
115
122
|
{}
|
116
|
-
|
123
|
+
32/l3: expression → • expression "*" expression
|
117
124
|
{}
|
118
|
-
|
125
|
+
33/l3: expression → • expression "/" expression
|
119
126
|
{}
|
120
|
-
|
127
|
+
34/n1: expression → • "(" expression ")"
|
121
128
|
{}
|
122
|
-
|
129
|
+
35/n1: expression → • "(" $error ")"
|
123
130
|
{}
|
124
131
|
transitions:
|
125
|
-
expression: State
|
132
|
+
expression: State 12
|
126
133
|
NUMBER: State 2
|
127
134
|
"(": State 3
|
128
135
|
|
129
136
|
State 6:
|
130
|
-
|
137
|
+
36/l2: expression → expression "+" • expression
|
131
138
|
{}
|
132
|
-
|
139
|
+
37/n1: expression → • NUMBER
|
133
140
|
{}
|
134
|
-
|
141
|
+
38/r4: expression → • expression "^" expression
|
135
142
|
{}
|
136
|
-
|
143
|
+
39/l2: expression → • expression "+" expression
|
137
144
|
{}
|
138
|
-
|
145
|
+
40/l2: expression → • expression "-" expression
|
139
146
|
{}
|
140
|
-
|
147
|
+
41/l3: expression → • expression "*" expression
|
141
148
|
{}
|
142
|
-
|
149
|
+
42/l3: expression → • expression "/" expression
|
143
150
|
{}
|
144
|
-
|
151
|
+
43/n1: expression → • "(" expression ")"
|
152
|
+
{}
|
153
|
+
44/n1: expression → • "(" $error ")"
|
145
154
|
{}
|
146
155
|
transitions:
|
147
|
-
expression: State
|
156
|
+
expression: State 13
|
148
157
|
NUMBER: State 2
|
149
158
|
"(": State 3
|
150
159
|
|
151
160
|
State 7:
|
152
|
-
|
161
|
+
45/l2: expression → expression "-" • expression
|
162
|
+
{}
|
163
|
+
46/n1: expression → • NUMBER
|
153
164
|
{}
|
154
|
-
|
165
|
+
47/r4: expression → • expression "^" expression
|
155
166
|
{}
|
156
|
-
|
167
|
+
48/l2: expression → • expression "+" expression
|
157
168
|
{}
|
158
|
-
|
169
|
+
49/l2: expression → • expression "-" expression
|
159
170
|
{}
|
160
|
-
|
171
|
+
50/l3: expression → • expression "*" expression
|
161
172
|
{}
|
162
|
-
|
173
|
+
51/l3: expression → • expression "/" expression
|
163
174
|
{}
|
164
|
-
|
175
|
+
52/n1: expression → • "(" expression ")"
|
165
176
|
{}
|
166
|
-
|
177
|
+
53/n1: expression → • "(" $error ")"
|
167
178
|
{}
|
168
179
|
transitions:
|
169
|
-
expression: State
|
180
|
+
expression: State 14
|
170
181
|
NUMBER: State 2
|
171
182
|
"(": State 3
|
172
183
|
|
173
184
|
State 8:
|
174
|
-
|
185
|
+
54/l3: expression → expression "*" • expression
|
186
|
+
{}
|
187
|
+
55/n1: expression → • NUMBER
|
175
188
|
{}
|
176
|
-
|
189
|
+
56/r4: expression → • expression "^" expression
|
177
190
|
{}
|
178
|
-
|
191
|
+
57/l2: expression → • expression "+" expression
|
179
192
|
{}
|
180
|
-
|
193
|
+
58/l2: expression → • expression "-" expression
|
181
194
|
{}
|
182
|
-
|
195
|
+
59/l3: expression → • expression "*" expression
|
183
196
|
{}
|
184
|
-
|
197
|
+
60/l3: expression → • expression "/" expression
|
185
198
|
{}
|
186
|
-
|
199
|
+
61/n1: expression → • "(" expression ")"
|
187
200
|
{}
|
188
|
-
|
201
|
+
62/n1: expression → • "(" $error ")"
|
189
202
|
{}
|
190
203
|
transitions:
|
191
|
-
expression: State
|
204
|
+
expression: State 15
|
192
205
|
NUMBER: State 2
|
193
206
|
"(": State 3
|
194
207
|
|
195
208
|
State 9:
|
196
|
-
|
209
|
+
63/l3: expression → expression "/" • expression
|
210
|
+
{}
|
211
|
+
64/n1: expression → • NUMBER
|
212
|
+
{}
|
213
|
+
65/r4: expression → • expression "^" expression
|
214
|
+
{}
|
215
|
+
66/l2: expression → • expression "+" expression
|
197
216
|
{}
|
198
|
-
|
217
|
+
67/l2: expression → • expression "-" expression
|
199
218
|
{}
|
200
|
-
|
219
|
+
68/l3: expression → • expression "*" expression
|
201
220
|
{}
|
202
|
-
|
221
|
+
69/l3: expression → • expression "/" expression
|
203
222
|
{}
|
204
|
-
|
223
|
+
70/n1: expression → • "(" expression ")"
|
224
|
+
{}
|
225
|
+
71/n1: expression → • "(" $error ")"
|
205
226
|
{}
|
206
227
|
transitions:
|
207
|
-
|
208
|
-
|
209
|
-
"
|
210
|
-
"*": State 7
|
211
|
-
"/": State 8
|
228
|
+
expression: State 16
|
229
|
+
NUMBER: State 2
|
230
|
+
"(": State 3
|
212
231
|
|
213
232
|
State 10:
|
214
|
-
|
233
|
+
72/n1: expression → "(" expression • ")"
|
234
|
+
{}
|
235
|
+
73/r4: expression → expression • "^" expression
|
236
|
+
{}
|
237
|
+
74/l2: expression → expression • "+" expression
|
238
|
+
{}
|
239
|
+
75/l2: expression → expression • "-" expression
|
240
|
+
{}
|
241
|
+
76/l3: expression → expression • "*" expression
|
242
|
+
{}
|
243
|
+
77/l3: expression → expression • "/" expression
|
215
244
|
{}
|
216
245
|
transitions:
|
217
|
-
")": State
|
246
|
+
")": State 17
|
247
|
+
"^": State 5
|
248
|
+
"+": State 6
|
249
|
+
"-": State 7
|
250
|
+
"*": State 8
|
251
|
+
"/": State 9
|
218
252
|
|
219
253
|
State 11:
|
220
|
-
|
221
|
-
{$, "+", "-", "*", "/", ")"}
|
222
|
-
63/l2: expression → expression • "+" expression
|
254
|
+
78/n1: expression → "(" $error • ")"
|
223
255
|
{}
|
224
|
-
|
256
|
+
transitions:
|
257
|
+
")": State 18
|
258
|
+
|
259
|
+
State 12:
|
260
|
+
79/r4: expression → expression "^" expression •
|
261
|
+
{$end, "^", "+", "-", "*", "/", ")"}
|
262
|
+
80/r4: expression → expression • "^" expression
|
263
|
+
{}
|
264
|
+
81/l2: expression → expression • "+" expression
|
265
|
+
{}
|
266
|
+
82/l2: expression → expression • "-" expression
|
225
267
|
{}
|
226
|
-
|
268
|
+
83/l3: expression → expression • "*" expression
|
227
269
|
{}
|
228
|
-
|
270
|
+
84/l3: expression → expression • "/" expression
|
229
271
|
{}
|
230
272
|
transitions:
|
231
|
-
"
|
232
|
-
"/": State 8
|
273
|
+
"^": State 5
|
233
274
|
reductions:
|
234
275
|
"+": Rule 2
|
235
276
|
"-": Rule 2
|
236
|
-
|
277
|
+
"*": Rule 2
|
278
|
+
"/": Rule 2
|
279
|
+
$end: Rule 2
|
237
280
|
")": Rule 2
|
238
281
|
|
239
|
-
State
|
240
|
-
|
241
|
-
{
|
242
|
-
|
282
|
+
State 13:
|
283
|
+
85/l2: expression → expression "+" expression •
|
284
|
+
{$end, "^", "+", "-", "*", "/", ")"}
|
285
|
+
86/r4: expression → expression • "^" expression
|
286
|
+
{}
|
287
|
+
87/l2: expression → expression • "+" expression
|
243
288
|
{}
|
244
|
-
|
289
|
+
88/l2: expression → expression • "-" expression
|
245
290
|
{}
|
246
|
-
|
291
|
+
89/l3: expression → expression • "*" expression
|
247
292
|
{}
|
248
|
-
|
293
|
+
90/l3: expression → expression • "/" expression
|
249
294
|
{}
|
250
295
|
transitions:
|
251
|
-
"
|
252
|
-
"
|
296
|
+
"^": State 5
|
297
|
+
"*": State 8
|
298
|
+
"/": State 9
|
253
299
|
reductions:
|
254
300
|
"+": Rule 3
|
255
301
|
"-": Rule 3
|
256
|
-
|
302
|
+
$end: Rule 3
|
257
303
|
")": Rule 3
|
258
304
|
|
259
|
-
State
|
260
|
-
|
261
|
-
{
|
262
|
-
|
305
|
+
State 14:
|
306
|
+
91/l2: expression → expression "-" expression •
|
307
|
+
{$end, "^", "+", "-", "*", "/", ")"}
|
308
|
+
92/r4: expression → expression • "^" expression
|
309
|
+
{}
|
310
|
+
93/l2: expression → expression • "+" expression
|
263
311
|
{}
|
264
|
-
|
312
|
+
94/l2: expression → expression • "-" expression
|
265
313
|
{}
|
266
|
-
|
314
|
+
95/l3: expression → expression • "*" expression
|
267
315
|
{}
|
268
|
-
|
316
|
+
96/l3: expression → expression • "/" expression
|
269
317
|
{}
|
318
|
+
transitions:
|
319
|
+
"^": State 5
|
320
|
+
"*": State 8
|
321
|
+
"/": State 9
|
270
322
|
reductions:
|
271
323
|
"+": Rule 4
|
272
324
|
"-": Rule 4
|
273
|
-
|
274
|
-
"/": Rule 4
|
275
|
-
$: Rule 4
|
325
|
+
$end: Rule 4
|
276
326
|
")": Rule 4
|
277
327
|
|
278
|
-
State
|
279
|
-
|
280
|
-
{
|
281
|
-
|
328
|
+
State 15:
|
329
|
+
97/l3: expression → expression "*" expression •
|
330
|
+
{$end, "^", "+", "-", "*", "/", ")"}
|
331
|
+
98/r4: expression → expression • "^" expression
|
282
332
|
{}
|
283
|
-
|
333
|
+
99/l2: expression → expression • "+" expression
|
284
334
|
{}
|
285
|
-
|
335
|
+
100/l2: expression → expression • "-" expression
|
286
336
|
{}
|
287
|
-
|
337
|
+
101/l3: expression → expression • "*" expression
|
288
338
|
{}
|
339
|
+
102/l3: expression → expression • "/" expression
|
340
|
+
{}
|
341
|
+
transitions:
|
342
|
+
"^": State 5
|
289
343
|
reductions:
|
290
344
|
"+": Rule 5
|
291
345
|
"-": Rule 5
|
292
346
|
"*": Rule 5
|
293
347
|
"/": Rule 5
|
294
|
-
|
348
|
+
$end: Rule 5
|
295
349
|
")": Rule 5
|
296
350
|
|
297
|
-
State
|
298
|
-
|
299
|
-
{
|
351
|
+
State 16:
|
352
|
+
103/l3: expression → expression "/" expression •
|
353
|
+
{$end, "^", "+", "-", "*", "/", ")"}
|
354
|
+
104/r4: expression → expression • "^" expression
|
355
|
+
{}
|
356
|
+
105/l2: expression → expression • "+" expression
|
357
|
+
{}
|
358
|
+
106/l2: expression → expression • "-" expression
|
359
|
+
{}
|
360
|
+
107/l3: expression → expression • "*" expression
|
361
|
+
{}
|
362
|
+
108/l3: expression → expression • "/" expression
|
363
|
+
{}
|
364
|
+
transitions:
|
365
|
+
"^": State 5
|
300
366
|
reductions:
|
301
|
-
$: Rule 6
|
302
367
|
"+": Rule 6
|
303
368
|
"-": Rule 6
|
304
369
|
"*": Rule 6
|
305
370
|
"/": Rule 6
|
371
|
+
$end: Rule 6
|
306
372
|
")": Rule 6
|
307
373
|
|
308
|
-
State
|
309
|
-
|
310
|
-
{
|
374
|
+
State 17:
|
375
|
+
109/n1: expression → "(" expression ")" •
|
376
|
+
{$end, "^", "+", "-", "*", "/", ")"}
|
377
|
+
reductions:
|
378
|
+
$default: Rule 7
|
379
|
+
|
380
|
+
State 18:
|
381
|
+
110/n1: expression → "(" $error ")" •
|
382
|
+
{$end, "^", "+", "-", "*", "/", ")"}
|
311
383
|
reductions:
|
312
|
-
|
313
|
-
"+": Rule 7
|
314
|
-
"-": Rule 7
|
315
|
-
"*": Rule 7
|
316
|
-
"/": Rule 7
|
317
|
-
")": Rule 7
|
384
|
+
$default: Rule 8
|
318
385
|
|
data/examples/simple.ace
CHANGED