antelope 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/deterministic.output +44 -55
- data/examples/example.output +143 -181
- data/examples/simple.output +36 -45
- data/lib/antelope/ace/compiler.rb +1 -1
- data/lib/antelope/generation/tableizer.rb +11 -4
- data/lib/antelope/generator/templates/output.erb +5 -4
- data/lib/antelope/generator.rb +3 -1
- data/lib/antelope/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3063af6acee6ef27ff96efdec1aeaf8c51cda510
|
4
|
+
data.tar.gz: cc405e6635d9a2192f246687cf7ee55df8026753
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f52610cdd27dd8946772314fe5afe57af9e982983d51abb51a627e488d64bfcb1eed894a66a6f653b85829315d73bb840bc094aa687938ada70df989ce18eb8
|
7
|
+
data.tar.gz: a0b91029a688a6312a592dae9f6ae8a2b95d7c8b0fc597df3bf6a5a3667dd575c7342a34a1c61c06541cba2fe84fc80b024ed07d463c2a2ac5f20377fda56a86
|
@@ -1,21 +1,10 @@
|
|
1
1
|
Productions:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
2 e(5:9) → t(5:3) ";"
|
9
|
-
3 e(5:9) → t(5:3) "+" e(8:10)
|
10
|
-
4 t(5:3) → NUMBER
|
11
|
-
5 t(5:3) → "(" e(5:9) ")"
|
12
|
-
2 e(8:10) → t(8:3) ";"
|
13
|
-
3 e(8:10) → t(8:3) "+" e(8:10)
|
14
|
-
4 t(8:3) → NUMBER
|
15
|
-
5 t(8:3) → "(" e(5:9) ")"
|
16
|
-
|
17
|
-
Nontemrinals:
|
18
|
-
["$start(0)", "s(0:1)", "e(0:2)", "t(0:3)", "e(5:9)", "t(5:3)", "e(8:10)", "t(8:3)"]
|
2
|
+
s → e
|
3
|
+
e → t ";"
|
4
|
+
e → t "+" e
|
5
|
+
t → NUMBER
|
6
|
+
t → "(" e ")"
|
7
|
+
$start → s $
|
19
8
|
|
20
9
|
Precedence:
|
21
10
|
--- highest
|
@@ -27,116 +16,116 @@ Precedence:
|
|
27
16
|
|
28
17
|
State 0:
|
29
18
|
0/n0: $start → • s $
|
30
|
-
{}
|
19
|
+
{}
|
31
20
|
1/n1: s → • e
|
32
|
-
{}
|
21
|
+
{}
|
33
22
|
2/n1: e → • t ";"
|
34
|
-
{}
|
23
|
+
{}
|
35
24
|
3/n1: e → • t "+" e
|
36
|
-
{}
|
25
|
+
{}
|
37
26
|
4/n1: t → • NUMBER
|
38
|
-
{}
|
27
|
+
{}
|
39
28
|
5/n1: t → • "(" e ")"
|
40
|
-
{}
|
29
|
+
{}
|
41
30
|
transitions:
|
42
31
|
s: State 1
|
43
32
|
e: State 2
|
44
33
|
t: State 3
|
45
34
|
NUMBER: State 4
|
46
|
-
|
35
|
+
"(": State 5
|
47
36
|
|
48
37
|
State 1:
|
49
38
|
6/n0: $start → s • $
|
50
|
-
{}
|
39
|
+
{}
|
51
40
|
transitions:
|
52
41
|
$: State 6
|
53
42
|
|
54
43
|
State 2:
|
55
44
|
7/n1: s → e •
|
56
|
-
{$}
|
45
|
+
{$}
|
57
46
|
reductions:
|
58
47
|
$: Rule 1
|
59
48
|
|
60
49
|
State 3:
|
61
50
|
8/n1: e → t • ";"
|
62
|
-
{}
|
51
|
+
{}
|
63
52
|
9/n1: e → t • "+" e
|
64
|
-
{}
|
53
|
+
{}
|
65
54
|
transitions:
|
66
|
-
|
67
|
-
|
55
|
+
";": State 7
|
56
|
+
"+": State 8
|
68
57
|
|
69
58
|
State 4:
|
70
59
|
10/n1: t → NUMBER •
|
71
|
-
{";", "+"}
|
60
|
+
{";", "+"}
|
72
61
|
reductions:
|
73
|
-
|
74
|
-
|
62
|
+
";": Rule 4
|
63
|
+
"+": Rule 4
|
75
64
|
|
76
65
|
State 5:
|
77
66
|
11/n1: t → "(" • e ")"
|
78
|
-
{}
|
67
|
+
{}
|
79
68
|
12/n1: e → • t ";"
|
80
|
-
{}
|
69
|
+
{}
|
81
70
|
13/n1: e → • t "+" e
|
82
|
-
{}
|
71
|
+
{}
|
83
72
|
14/n1: t → • NUMBER
|
84
|
-
{}
|
73
|
+
{}
|
85
74
|
15/n1: t → • "(" e ")"
|
86
|
-
{}
|
75
|
+
{}
|
87
76
|
transitions:
|
88
77
|
e: State 9
|
89
78
|
t: State 3
|
90
79
|
NUMBER: State 4
|
91
|
-
|
80
|
+
"(": State 5
|
92
81
|
|
93
82
|
State 6:
|
94
83
|
16/n0: $start → s $ •
|
95
|
-
{}
|
84
|
+
{}
|
96
85
|
accepting:
|
97
86
|
$: Rule 0
|
98
87
|
|
99
88
|
State 7:
|
100
89
|
17/n1: e → t ";" •
|
101
|
-
{$, ")"}
|
90
|
+
{$, ")"}
|
102
91
|
reductions:
|
103
92
|
$: Rule 2
|
104
|
-
|
93
|
+
")": Rule 2
|
105
94
|
|
106
95
|
State 8:
|
107
96
|
18/n1: e → t "+" • e
|
108
|
-
{}
|
97
|
+
{}
|
109
98
|
19/n1: e → • t ";"
|
110
|
-
{}
|
99
|
+
{}
|
111
100
|
20/n1: e → • t "+" e
|
112
|
-
{}
|
101
|
+
{}
|
113
102
|
21/n1: t → • NUMBER
|
114
|
-
{}
|
103
|
+
{}
|
115
104
|
22/n1: t → • "(" e ")"
|
116
|
-
{}
|
105
|
+
{}
|
117
106
|
transitions:
|
118
107
|
e: State 10
|
119
108
|
t: State 3
|
120
109
|
NUMBER: State 4
|
121
|
-
|
110
|
+
"(": State 5
|
122
111
|
|
123
112
|
State 9:
|
124
113
|
23/n1: t → "(" e • ")"
|
125
|
-
{}
|
114
|
+
{}
|
126
115
|
transitions:
|
127
|
-
|
116
|
+
")": State 11
|
128
117
|
|
129
118
|
State 10:
|
130
119
|
24/n1: e → t "+" e •
|
131
|
-
{$, ")"}
|
120
|
+
{$, ")"}
|
132
121
|
reductions:
|
133
122
|
$: Rule 3
|
134
|
-
|
123
|
+
")": Rule 3
|
135
124
|
|
136
125
|
State 11:
|
137
126
|
25/n1: t → "(" e ")" •
|
138
|
-
{";", "+"}
|
127
|
+
{";", "+"}
|
139
128
|
reductions:
|
140
|
-
|
141
|
-
|
129
|
+
";": Rule 5
|
130
|
+
"+": Rule 5
|
142
131
|
|
data/examples/example.output
CHANGED
@@ -1,50 +1,12 @@
|
|
1
1
|
Productions:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
1 expression(3:9) → NUMBER { |a| a[1] }
|
11
|
-
2 expression(3:9) → expression(3:9) "+" expression(5:11) { |a, _, b| a + b }
|
12
|
-
3 expression(3:9) → expression(3:9) "-" expression(6:12) { |a, _, b| a - b }
|
13
|
-
4 expression(3:9) → expression(3:9) "*" expression(7:13) { |a, _, b| a * b }
|
14
|
-
5 expression(3:9) → expression(3:9) "/" expression(8:14) { |a, _, b| a / b }
|
15
|
-
6 expression(3:9) → "(" expression(3:9) ")" { |_, a, _| a }
|
16
|
-
7 expression(3:9) → "(" $error ")"
|
17
|
-
1 expression(5:11) → NUMBER { |a| a[1] }
|
18
|
-
2 expression(5:11) → expression(5:11) "+" expression(5:11) { |a, _, b| a + b }
|
19
|
-
3 expression(5:11) → expression(5:11) "-" expression(6:12) { |a, _, b| a - b }
|
20
|
-
4 expression(5:11) → expression(5:11) "*" expression(7:13) { |a, _, b| a * b }
|
21
|
-
5 expression(5:11) → expression(5:11) "/" expression(8:14) { |a, _, b| a / b }
|
22
|
-
6 expression(5:11) → "(" expression(3:9) ")" { |_, a, _| a }
|
23
|
-
7 expression(5:11) → "(" $error ")"
|
24
|
-
1 expression(6:12) → NUMBER { |a| a[1] }
|
25
|
-
2 expression(6:12) → expression(6:12) "+" expression(5:11) { |a, _, b| a + b }
|
26
|
-
3 expression(6:12) → expression(6:12) "-" expression(6:12) { |a, _, b| a - b }
|
27
|
-
4 expression(6:12) → expression(6:12) "*" expression(7:13) { |a, _, b| a * b }
|
28
|
-
5 expression(6:12) → expression(6:12) "/" expression(8:14) { |a, _, b| a / b }
|
29
|
-
6 expression(6:12) → "(" expression(3:9) ")" { |_, a, _| a }
|
30
|
-
7 expression(6:12) → "(" $error ")"
|
31
|
-
1 expression(7:13) → NUMBER { |a| a[1] }
|
32
|
-
2 expression(7:13) → expression(7:13) "+" expression(5:11) { |a, _, b| a + b }
|
33
|
-
3 expression(7:13) → expression(7:13) "-" expression(6:12) { |a, _, b| a - b }
|
34
|
-
4 expression(7:13) → expression(7:13) "*" expression(7:13) { |a, _, b| a * b }
|
35
|
-
5 expression(7:13) → expression(7:13) "/" expression(8:14) { |a, _, b| a / b }
|
36
|
-
6 expression(7:13) → "(" expression(3:9) ")" { |_, a, _| a }
|
37
|
-
7 expression(7:13) → "(" $error ")"
|
38
|
-
1 expression(8:14) → NUMBER { |a| a[1] }
|
39
|
-
2 expression(8:14) → expression(8:14) "+" expression(5:11) { |a, _, b| a + b }
|
40
|
-
3 expression(8:14) → expression(8:14) "-" expression(6:12) { |a, _, b| a - b }
|
41
|
-
4 expression(8:14) → expression(8:14) "*" expression(7:13) { |a, _, b| a * b }
|
42
|
-
5 expression(8:14) → expression(8:14) "/" expression(8:14) { |a, _, b| a / b }
|
43
|
-
6 expression(8:14) → "(" expression(3:9) ")" { |_, a, _| a }
|
44
|
-
7 expression(8:14) → "(" $error ")"
|
45
|
-
|
46
|
-
Nontemrinals:
|
47
|
-
["$start(0)", "expression(0:1)", "expression(3:9)", "expression(5:11)", "expression(6:12)", "expression(7:13)", "expression(8:14)"]
|
2
|
+
expression → NUMBER { |a| a[1] }
|
3
|
+
expression → expression "+" expression { |a, _, b| a + b }
|
4
|
+
expression → expression "-" expression { |a, _, b| a - b }
|
5
|
+
expression → expression "*" expression { |a, _, b| a * b }
|
6
|
+
expression → expression "/" expression { |a, _, b| a / b }
|
7
|
+
expression → "(" expression ")" { |_, a, _| a }
|
8
|
+
expression → "(" $error ")"
|
9
|
+
$start → expression $
|
48
10
|
|
49
11
|
Precedence:
|
50
12
|
--- highest
|
@@ -62,295 +24,295 @@ Precedence:
|
|
62
24
|
|
63
25
|
State 0:
|
64
26
|
0/n0: $start → • expression $
|
65
|
-
{}
|
27
|
+
{}
|
66
28
|
1/n1: expression → • NUMBER
|
67
|
-
{}
|
29
|
+
{}
|
68
30
|
2/l2: expression → • expression "+" expression
|
69
|
-
{}
|
31
|
+
{}
|
70
32
|
3/l2: expression → • expression "-" expression
|
71
|
-
{}
|
33
|
+
{}
|
72
34
|
4/l3: expression → • expression "*" expression
|
73
|
-
{}
|
35
|
+
{}
|
74
36
|
5/l3: expression → • expression "/" expression
|
75
|
-
{}
|
37
|
+
{}
|
76
38
|
6/n4: expression → • "(" expression ")"
|
77
|
-
{}
|
39
|
+
{}
|
78
40
|
7/n4: expression → • "(" $error ")"
|
79
|
-
{}
|
41
|
+
{}
|
80
42
|
transitions:
|
81
43
|
expression: State 1
|
82
44
|
NUMBER: State 2
|
83
|
-
|
45
|
+
"(": State 3
|
84
46
|
|
85
47
|
State 1:
|
86
48
|
8/n0: $start → expression • $
|
87
|
-
{}
|
49
|
+
{}
|
88
50
|
9/l2: expression → expression • "+" expression
|
89
|
-
{}
|
51
|
+
{}
|
90
52
|
10/l2: expression → expression • "-" expression
|
91
|
-
{}
|
53
|
+
{}
|
92
54
|
11/l3: expression → expression • "*" expression
|
93
|
-
{}
|
55
|
+
{}
|
94
56
|
12/l3: expression → expression • "/" expression
|
95
|
-
{}
|
57
|
+
{}
|
96
58
|
transitions:
|
97
59
|
$: State 4
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
60
|
+
"+": State 5
|
61
|
+
"-": State 6
|
62
|
+
"*": State 7
|
63
|
+
"/": State 8
|
102
64
|
|
103
65
|
State 2:
|
104
66
|
13/n1: expression → NUMBER •
|
105
|
-
{$, "+", "-", "*", "/", ")"}
|
67
|
+
{$, "+", "-", "*", "/", ")"}
|
106
68
|
reductions:
|
107
69
|
$: Rule 1
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
70
|
+
"+": Rule 1
|
71
|
+
"-": Rule 1
|
72
|
+
"*": Rule 1
|
73
|
+
"/": Rule 1
|
74
|
+
")": Rule 1
|
113
75
|
|
114
76
|
State 3:
|
115
77
|
14/n4: expression → "(" • expression ")"
|
116
|
-
{}
|
78
|
+
{}
|
117
79
|
15/n1: expression → • NUMBER
|
118
|
-
{}
|
80
|
+
{}
|
119
81
|
16/l2: expression → • expression "+" expression
|
120
|
-
{}
|
82
|
+
{}
|
121
83
|
17/l2: expression → • expression "-" expression
|
122
|
-
{}
|
84
|
+
{}
|
123
85
|
18/l3: expression → • expression "*" expression
|
124
|
-
{}
|
86
|
+
{}
|
125
87
|
19/l3: expression → • expression "/" expression
|
126
|
-
{}
|
88
|
+
{}
|
127
89
|
20/n4: expression → • "(" expression ")"
|
128
|
-
{}
|
90
|
+
{}
|
129
91
|
21/n4: expression → • "(" $error ")"
|
130
|
-
{}
|
92
|
+
{}
|
131
93
|
22/n4: expression → "(" • $error ")"
|
132
|
-
{}
|
94
|
+
{}
|
133
95
|
transitions:
|
134
96
|
expression: State 9
|
135
97
|
NUMBER: State 2
|
136
|
-
|
98
|
+
"(": State 3
|
137
99
|
$error: State 10
|
138
100
|
|
139
101
|
State 4:
|
140
102
|
23/n0: $start → expression $ •
|
141
|
-
{}
|
103
|
+
{}
|
142
104
|
accepting:
|
143
105
|
$: Rule 0
|
144
106
|
|
145
107
|
State 5:
|
146
108
|
24/l2: expression → expression "+" • expression
|
147
|
-
{}
|
109
|
+
{}
|
148
110
|
25/n1: expression → • NUMBER
|
149
|
-
{}
|
111
|
+
{}
|
150
112
|
26/l2: expression → • expression "+" expression
|
151
|
-
{}
|
113
|
+
{}
|
152
114
|
27/l2: expression → • expression "-" expression
|
153
|
-
{}
|
115
|
+
{}
|
154
116
|
28/l3: expression → • expression "*" expression
|
155
|
-
{}
|
117
|
+
{}
|
156
118
|
29/l3: expression → • expression "/" expression
|
157
|
-
{}
|
119
|
+
{}
|
158
120
|
30/n4: expression → • "(" expression ")"
|
159
|
-
{}
|
121
|
+
{}
|
160
122
|
31/n4: expression → • "(" $error ")"
|
161
|
-
{}
|
123
|
+
{}
|
162
124
|
transitions:
|
163
125
|
expression: State 11
|
164
126
|
NUMBER: State 2
|
165
|
-
|
127
|
+
"(": State 3
|
166
128
|
|
167
129
|
State 6:
|
168
130
|
32/l2: expression → expression "-" • expression
|
169
|
-
{}
|
131
|
+
{}
|
170
132
|
33/n1: expression → • NUMBER
|
171
|
-
{}
|
133
|
+
{}
|
172
134
|
34/l2: expression → • expression "+" expression
|
173
|
-
{}
|
135
|
+
{}
|
174
136
|
35/l2: expression → • expression "-" expression
|
175
|
-
{}
|
137
|
+
{}
|
176
138
|
36/l3: expression → • expression "*" expression
|
177
|
-
{}
|
139
|
+
{}
|
178
140
|
37/l3: expression → • expression "/" expression
|
179
|
-
{}
|
141
|
+
{}
|
180
142
|
38/n4: expression → • "(" expression ")"
|
181
|
-
{}
|
143
|
+
{}
|
182
144
|
39/n4: expression → • "(" $error ")"
|
183
|
-
{}
|
145
|
+
{}
|
184
146
|
transitions:
|
185
147
|
expression: State 12
|
186
148
|
NUMBER: State 2
|
187
|
-
|
149
|
+
"(": State 3
|
188
150
|
|
189
151
|
State 7:
|
190
152
|
40/l3: expression → expression "*" • expression
|
191
|
-
{}
|
153
|
+
{}
|
192
154
|
41/n1: expression → • NUMBER
|
193
|
-
{}
|
155
|
+
{}
|
194
156
|
42/l2: expression → • expression "+" expression
|
195
|
-
{}
|
157
|
+
{}
|
196
158
|
43/l2: expression → • expression "-" expression
|
197
|
-
{}
|
159
|
+
{}
|
198
160
|
44/l3: expression → • expression "*" expression
|
199
|
-
{}
|
161
|
+
{}
|
200
162
|
45/l3: expression → • expression "/" expression
|
201
|
-
{}
|
163
|
+
{}
|
202
164
|
46/n4: expression → • "(" expression ")"
|
203
|
-
{}
|
165
|
+
{}
|
204
166
|
47/n4: expression → • "(" $error ")"
|
205
|
-
{}
|
167
|
+
{}
|
206
168
|
transitions:
|
207
169
|
expression: State 13
|
208
170
|
NUMBER: State 2
|
209
|
-
|
171
|
+
"(": State 3
|
210
172
|
|
211
173
|
State 8:
|
212
174
|
48/l3: expression → expression "/" • expression
|
213
|
-
{}
|
175
|
+
{}
|
214
176
|
49/n1: expression → • NUMBER
|
215
|
-
{}
|
177
|
+
{}
|
216
178
|
50/l2: expression → • expression "+" expression
|
217
|
-
{}
|
179
|
+
{}
|
218
180
|
51/l2: expression → • expression "-" expression
|
219
|
-
{}
|
181
|
+
{}
|
220
182
|
52/l3: expression → • expression "*" expression
|
221
|
-
{}
|
183
|
+
{}
|
222
184
|
53/l3: expression → • expression "/" expression
|
223
|
-
{}
|
185
|
+
{}
|
224
186
|
54/n4: expression → • "(" expression ")"
|
225
|
-
{}
|
187
|
+
{}
|
226
188
|
55/n4: expression → • "(" $error ")"
|
227
|
-
{}
|
189
|
+
{}
|
228
190
|
transitions:
|
229
191
|
expression: State 14
|
230
192
|
NUMBER: State 2
|
231
|
-
|
193
|
+
"(": State 3
|
232
194
|
|
233
195
|
State 9:
|
234
196
|
56/n4: expression → "(" expression • ")"
|
235
|
-
{}
|
197
|
+
{}
|
236
198
|
57/l2: expression → expression • "+" expression
|
237
|
-
{}
|
199
|
+
{}
|
238
200
|
58/l2: expression → expression • "-" expression
|
239
|
-
{}
|
201
|
+
{}
|
240
202
|
59/l3: expression → expression • "*" expression
|
241
|
-
{}
|
203
|
+
{}
|
242
204
|
60/l3: expression → expression • "/" expression
|
243
|
-
{}
|
205
|
+
{}
|
244
206
|
transitions:
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
207
|
+
")": State 15
|
208
|
+
"+": State 5
|
209
|
+
"-": State 6
|
210
|
+
"*": State 7
|
211
|
+
"/": State 8
|
250
212
|
|
251
213
|
State 10:
|
252
214
|
61/n4: expression → "(" $error • ")"
|
253
|
-
{}
|
215
|
+
{}
|
254
216
|
transitions:
|
255
|
-
|
217
|
+
")": State 16
|
256
218
|
|
257
219
|
State 11:
|
258
220
|
62/l2: expression → expression "+" expression •
|
259
|
-
{$, "+", "-", "*", "/", ")"}
|
221
|
+
{$, "+", "-", "*", "/", ")"}
|
260
222
|
63/l2: expression → expression • "+" expression
|
261
|
-
{}
|
223
|
+
{}
|
262
224
|
64/l2: expression → expression • "-" expression
|
263
|
-
{}
|
225
|
+
{}
|
264
226
|
65/l3: expression → expression • "*" expression
|
265
|
-
{}
|
227
|
+
{}
|
266
228
|
66/l3: expression → expression • "/" expression
|
267
|
-
{}
|
229
|
+
{}
|
268
230
|
transitions:
|
269
|
-
|
270
|
-
|
231
|
+
"*": State 7
|
232
|
+
"/": State 8
|
271
233
|
reductions:
|
272
|
-
|
273
|
-
|
234
|
+
"+": Rule 2
|
235
|
+
"-": Rule 2
|
274
236
|
$: Rule 2
|
275
|
-
|
237
|
+
")": Rule 2
|
276
238
|
|
277
239
|
State 12:
|
278
240
|
67/l2: expression → expression "-" expression •
|
279
|
-
{$, "+", "-", "*", "/", ")"}
|
241
|
+
{$, "+", "-", "*", "/", ")"}
|
280
242
|
68/l2: expression → expression • "+" expression
|
281
|
-
{}
|
243
|
+
{}
|
282
244
|
69/l2: expression → expression • "-" expression
|
283
|
-
{}
|
245
|
+
{}
|
284
246
|
70/l3: expression → expression • "*" expression
|
285
|
-
{}
|
247
|
+
{}
|
286
248
|
71/l3: expression → expression • "/" expression
|
287
|
-
{}
|
249
|
+
{}
|
288
250
|
transitions:
|
289
|
-
|
290
|
-
|
251
|
+
"*": State 7
|
252
|
+
"/": State 8
|
291
253
|
reductions:
|
292
|
-
|
293
|
-
|
254
|
+
"+": Rule 3
|
255
|
+
"-": Rule 3
|
294
256
|
$: Rule 3
|
295
|
-
|
257
|
+
")": Rule 3
|
296
258
|
|
297
259
|
State 13:
|
298
260
|
72/l3: expression → expression "*" expression •
|
299
|
-
{$, "+", "-", "*", "/", ")"}
|
261
|
+
{$, "+", "-", "*", "/", ")"}
|
300
262
|
73/l2: expression → expression • "+" expression
|
301
|
-
{}
|
263
|
+
{}
|
302
264
|
74/l2: expression → expression • "-" expression
|
303
|
-
{}
|
265
|
+
{}
|
304
266
|
75/l3: expression → expression • "*" expression
|
305
|
-
{}
|
267
|
+
{}
|
306
268
|
76/l3: expression → expression • "/" expression
|
307
|
-
{}
|
269
|
+
{}
|
308
270
|
reductions:
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
271
|
+
"+": Rule 4
|
272
|
+
"-": Rule 4
|
273
|
+
"*": Rule 4
|
274
|
+
"/": Rule 4
|
313
275
|
$: Rule 4
|
314
|
-
|
276
|
+
")": Rule 4
|
315
277
|
|
316
278
|
State 14:
|
317
279
|
77/l3: expression → expression "/" expression •
|
318
|
-
{$, "+", "-", "*", "/", ")"}
|
280
|
+
{$, "+", "-", "*", "/", ")"}
|
319
281
|
78/l2: expression → expression • "+" expression
|
320
|
-
{}
|
282
|
+
{}
|
321
283
|
79/l2: expression → expression • "-" expression
|
322
|
-
{}
|
284
|
+
{}
|
323
285
|
80/l3: expression → expression • "*" expression
|
324
|
-
{}
|
286
|
+
{}
|
325
287
|
81/l3: expression → expression • "/" expression
|
326
|
-
{}
|
288
|
+
{}
|
327
289
|
reductions:
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
290
|
+
"+": Rule 5
|
291
|
+
"-": Rule 5
|
292
|
+
"*": Rule 5
|
293
|
+
"/": Rule 5
|
332
294
|
$: Rule 5
|
333
|
-
|
295
|
+
")": Rule 5
|
334
296
|
|
335
297
|
State 15:
|
336
298
|
82/n4: expression → "(" expression ")" •
|
337
|
-
{$, "+", "-", "*", "/", ")"}
|
299
|
+
{$, "+", "-", "*", "/", ")"}
|
338
300
|
reductions:
|
339
301
|
$: Rule 6
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
302
|
+
"+": Rule 6
|
303
|
+
"-": Rule 6
|
304
|
+
"*": Rule 6
|
305
|
+
"/": Rule 6
|
306
|
+
")": Rule 6
|
345
307
|
|
346
308
|
State 16:
|
347
309
|
83/n4: expression → "(" $error ")" •
|
348
|
-
{$, "+", "-", "*", "/", ")"}
|
310
|
+
{$, "+", "-", "*", "/", ")"}
|
349
311
|
reductions:
|
350
312
|
$: Rule 7
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
313
|
+
"+": Rule 7
|
314
|
+
"-": Rule 7
|
315
|
+
"*": Rule 7
|
316
|
+
"/": Rule 7
|
317
|
+
")": Rule 7
|
356
318
|
|
data/examples/simple.output
CHANGED
@@ -1,19 +1,10 @@
|
|
1
1
|
Productions:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
5 r(5:8) → l(5:9)
|
9
|
-
3 l(5:9) → IDENT
|
10
|
-
4 l(5:9) → "*" r(5:8)
|
11
|
-
5 r(7:10) → l(7:9)
|
12
|
-
3 l(7:9) → IDENT
|
13
|
-
4 l(7:9) → "*" r(5:8)
|
14
|
-
|
15
|
-
Nontemrinals:
|
16
|
-
["$start(0)", "e(0:1)", "l(0:2)", "r(0:3)", "r(5:8)", "l(5:9)", "r(7:10)", "l(7:9)"]
|
2
|
+
e → l "=" r
|
3
|
+
e → r
|
4
|
+
l → IDENT
|
5
|
+
l → "*" r
|
6
|
+
r → l
|
7
|
+
$start → e $
|
17
8
|
|
18
9
|
Precedence:
|
19
10
|
--- highest
|
@@ -25,106 +16,106 @@ Precedence:
|
|
25
16
|
|
26
17
|
State 0:
|
27
18
|
0/n0: $start → • e $
|
28
|
-
{}
|
19
|
+
{}
|
29
20
|
1/n1: e → • l "=" r
|
30
|
-
{}
|
21
|
+
{}
|
31
22
|
2/n1: e → • r
|
32
|
-
{}
|
23
|
+
{}
|
33
24
|
3/n1: l → • IDENT
|
34
|
-
{}
|
25
|
+
{}
|
35
26
|
4/n1: l → • "*" r
|
36
|
-
{}
|
27
|
+
{}
|
37
28
|
5/n1: r → • l
|
38
|
-
{}
|
29
|
+
{}
|
39
30
|
transitions:
|
40
31
|
e: State 1
|
41
32
|
l: State 2
|
42
33
|
r: State 3
|
43
34
|
IDENT: State 4
|
44
|
-
|
35
|
+
"*": State 5
|
45
36
|
|
46
37
|
State 1:
|
47
38
|
6/n0: $start → e • $
|
48
|
-
{}
|
39
|
+
{}
|
49
40
|
transitions:
|
50
41
|
$: State 6
|
51
42
|
|
52
43
|
State 2:
|
53
44
|
7/n1: e → l • "=" r
|
54
|
-
{}
|
45
|
+
{}
|
55
46
|
8/n1: r → l •
|
56
|
-
{$}
|
47
|
+
{$}
|
57
48
|
transitions:
|
58
|
-
|
49
|
+
"=": State 7
|
59
50
|
reductions:
|
60
51
|
$: Rule 5
|
61
52
|
|
62
53
|
State 3:
|
63
54
|
9/n1: e → r •
|
64
|
-
{$}
|
55
|
+
{$}
|
65
56
|
reductions:
|
66
57
|
$: Rule 2
|
67
58
|
|
68
59
|
State 4:
|
69
60
|
10/n1: l → IDENT •
|
70
|
-
{"=", $}
|
61
|
+
{"=", $}
|
71
62
|
reductions:
|
72
|
-
|
63
|
+
"=": Rule 3
|
73
64
|
$: Rule 3
|
74
65
|
|
75
66
|
State 5:
|
76
67
|
11/n1: l → "*" • r
|
77
|
-
{}
|
68
|
+
{}
|
78
69
|
12/n1: r → • l
|
79
|
-
{}
|
70
|
+
{}
|
80
71
|
13/n1: l → • IDENT
|
81
|
-
{}
|
72
|
+
{}
|
82
73
|
14/n1: l → • "*" r
|
83
|
-
{}
|
74
|
+
{}
|
84
75
|
transitions:
|
85
76
|
r: State 8
|
86
77
|
l: State 9
|
87
78
|
IDENT: State 4
|
88
|
-
|
79
|
+
"*": State 5
|
89
80
|
|
90
81
|
State 6:
|
91
82
|
15/n0: $start → e $ •
|
92
|
-
{}
|
83
|
+
{}
|
93
84
|
accepting:
|
94
85
|
$: Rule 0
|
95
86
|
|
96
87
|
State 7:
|
97
88
|
16/n1: e → l "=" • r
|
98
|
-
{}
|
89
|
+
{}
|
99
90
|
17/n1: r → • l
|
100
|
-
{}
|
91
|
+
{}
|
101
92
|
18/n1: l → • IDENT
|
102
|
-
{}
|
93
|
+
{}
|
103
94
|
19/n1: l → • "*" r
|
104
|
-
{}
|
95
|
+
{}
|
105
96
|
transitions:
|
106
97
|
r: State 10
|
107
98
|
l: State 9
|
108
99
|
IDENT: State 4
|
109
|
-
|
100
|
+
"*": State 5
|
110
101
|
|
111
102
|
State 8:
|
112
103
|
20/n1: l → "*" r •
|
113
|
-
{"=", $}
|
104
|
+
{"=", $}
|
114
105
|
reductions:
|
115
|
-
|
106
|
+
"=": Rule 4
|
116
107
|
$: Rule 4
|
117
108
|
|
118
109
|
State 9:
|
119
110
|
21/n1: r → l •
|
120
|
-
{"=", $}
|
111
|
+
{"=", $}
|
121
112
|
reductions:
|
122
|
-
|
113
|
+
"=": Rule 5
|
123
114
|
$: Rule 5
|
124
115
|
|
125
116
|
State 10:
|
126
117
|
22/n1: e → l "=" r •
|
127
|
-
{$}
|
118
|
+
{$}
|
128
119
|
reductions:
|
129
120
|
$: Rule 1
|
130
121
|
|
@@ -91,19 +91,26 @@ module Antelope
|
|
91
91
|
|
92
92
|
terminal = grammar.precedence_for(on)
|
93
93
|
|
94
|
-
|
95
|
-
|
94
|
+
rule_part, other_part = data.sort_by { |(t, d)| t }
|
95
|
+
|
96
|
+
unless other_part[0] == :state
|
97
|
+
$stderr.puts \
|
98
|
+
"Could not determine move for #{on} in state " \
|
99
|
+
"#{state} (reduce/reduce conflict)"
|
100
|
+
next
|
101
|
+
end
|
96
102
|
|
97
103
|
result = @rules[rule_part[1]].prec <=> terminal
|
98
104
|
|
99
105
|
case result
|
100
106
|
when 0
|
101
107
|
$stderr.puts \
|
102
|
-
"Could not determine move for #{on} in state
|
108
|
+
"Could not determine move for #{on} in state " \
|
109
|
+
"#{state} (shift/reduce conflict)"
|
103
110
|
when 1
|
104
111
|
@table[state][on] = rule_part
|
105
112
|
when -1
|
106
|
-
@table[state][on] =
|
113
|
+
@table[state][on] = other_part
|
107
114
|
end
|
108
115
|
end
|
109
116
|
end
|
@@ -22,9 +22,9 @@ Precedence:
|
|
22
22
|
<%= rule %>
|
23
23
|
{<%= rule.lookahead.to_a.join(", ") %>}
|
24
24
|
% end
|
25
|
-
% transitions = v.each.select { |_, a| a[0] == :state
|
26
|
-
% reductions = v.each.select { |_, a| a[0] == :reduce
|
27
|
-
% accepting = v.each.select { |_, a| a[0] == :accept
|
25
|
+
% transitions = v.each.select { |_, a| a && a[0] == :state }
|
26
|
+
% reductions = v.each.select { |_, a| a && a[0] == :reduce}
|
27
|
+
% accepting = v.each.select { |_, a| a && a[0] == :accept}
|
28
28
|
% conflicts = v.each.select { |_, (a, b)| a.is_a?(Array) }
|
29
29
|
% thing = [:transitions, :reductions, :accepting]
|
30
30
|
% num_type = {transitions: "State", reductions: "Rule", accepting: "Rule"}
|
@@ -33,7 +33,8 @@ Precedence:
|
|
33
33
|
% next unless value.any?
|
34
34
|
<%= key %>:
|
35
35
|
% value.each do |token, (_, name)|
|
36
|
-
|
36
|
+
% token_value = grammar.terminals.find { |_| _.name == token } || token
|
37
|
+
<%= token_value %>: <%= num_type[key] %> <%= name %>
|
37
38
|
% end
|
38
39
|
% end
|
39
40
|
% if conflicts.any?
|
data/lib/antelope/generator.rb
CHANGED
@@ -74,7 +74,9 @@ module Antelope
|
|
74
74
|
src_file = self.class.source_root + source
|
75
75
|
src = src_file.open("r")
|
76
76
|
context = instance_eval('binding')
|
77
|
-
|
77
|
+
erb = ERB.new(src.read, nil, "%")
|
78
|
+
erb.filename = source
|
79
|
+
content = erb.result(context)
|
78
80
|
content = yield content if block_given?
|
79
81
|
dest_file = grammar.output + destination
|
80
82
|
dest_file.open("w") do |f|
|
data/lib/antelope/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: antelope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Rodi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|