antelope 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +25 -23
- data/.rspec +3 -3
- data/.travis.yml +10 -9
- data/.yardopts +7 -7
- data/CONTRIBUTING.md +38 -38
- data/GENERATORS.md +124 -124
- data/Gemfile +7 -7
- data/LICENSE.txt +22 -22
- data/README.md +104 -104
- data/Rakefile +2 -2
- data/TODO.md +58 -58
- data/antelope.gemspec +28 -28
- data/bin/antelope +7 -7
- data/examples/deterministic.ace +35 -35
- data/examples/example.ace +51 -50
- data/examples/example.err +192 -0
- data/examples/{example.output → example.inf} +384 -385
- data/examples/liquidscript.ace +233 -162
- data/examples/simple.ace +22 -22
- data/lib/antelope/ace/compiler.rb +334 -334
- data/lib/antelope/ace/errors.rb +48 -48
- data/lib/antelope/ace/grammar/generation.rb +80 -80
- data/lib/antelope/ace/grammar/loading.rb +53 -53
- data/lib/antelope/ace/grammar/precedences.rb +68 -65
- data/lib/antelope/ace/grammar/productions.rb +156 -150
- data/lib/antelope/ace/grammar/symbols.rb +66 -66
- data/lib/antelope/ace/grammar.rb +69 -69
- data/lib/antelope/ace/precedence.rb +61 -61
- data/lib/antelope/ace/production.rb +57 -57
- data/lib/antelope/ace/scanner/argument.rb +57 -57
- data/lib/antelope/ace/scanner/first.rb +89 -89
- data/lib/antelope/ace/scanner/second.rb +177 -177
- data/lib/antelope/ace/scanner/third.rb +27 -27
- data/lib/antelope/ace/scanner.rb +134 -134
- data/lib/antelope/ace/token/epsilon.rb +24 -24
- data/lib/antelope/ace/token/error.rb +26 -26
- data/lib/antelope/ace/token/nonterminal.rb +17 -17
- data/lib/antelope/ace/token/terminal.rb +17 -17
- data/lib/antelope/ace/token.rb +238 -238
- data/lib/antelope/ace.rb +53 -53
- data/lib/antelope/cli.rb +55 -55
- data/lib/antelope/errors.rb +8 -8
- data/lib/antelope/generation/constructor/first.rb +88 -88
- data/lib/antelope/generation/constructor/follow.rb +103 -103
- data/lib/antelope/generation/constructor/nullable.rb +64 -64
- data/lib/antelope/generation/constructor.rb +126 -126
- data/lib/antelope/generation/errors.rb +17 -17
- data/lib/antelope/generation/null.rb +13 -13
- data/lib/antelope/generation/recognizer/rule.rb +216 -216
- data/lib/antelope/generation/recognizer/state.rb +130 -130
- data/lib/antelope/generation/recognizer.rb +180 -180
- data/lib/antelope/generation/tableizer.rb +175 -154
- data/lib/antelope/generation.rb +15 -15
- data/lib/antelope/generator/base.rb +264 -264
- data/lib/antelope/generator/c.rb +11 -11
- data/lib/antelope/generator/c_header.rb +105 -105
- data/lib/antelope/generator/c_source.rb +39 -39
- data/lib/antelope/generator/error.rb +34 -0
- data/lib/antelope/generator/group.rb +57 -57
- data/lib/antelope/generator/html.rb +51 -0
- data/lib/antelope/generator/info.rb +47 -0
- data/lib/antelope/generator/null.rb +18 -18
- data/lib/antelope/generator/output.rb +17 -49
- data/lib/antelope/generator/ruby.rb +79 -79
- data/lib/antelope/generator/templates/c_header.ant +36 -36
- data/lib/antelope/generator/templates/c_source.ant +202 -202
- data/lib/antelope/generator/templates/error.ant +33 -0
- data/lib/antelope/generator/templates/html/antelope.css +1 -0
- data/lib/antelope/generator/templates/html/antelope.html +1 -0
- data/lib/antelope/generator/templates/html/antelope.js +1 -0
- data/lib/antelope/generator/templates/html/css.ant +53 -0
- data/lib/antelope/generator/templates/html/html.ant +82 -0
- data/lib/antelope/generator/templates/html/js.ant +9 -0
- data/lib/antelope/generator/templates/info.ant +53 -0
- data/lib/antelope/generator/templates/ruby.ant +178 -146
- data/lib/antelope/generator.rb +66 -63
- data/lib/antelope/template/compiler.rb +78 -78
- data/lib/antelope/template/errors.rb +9 -9
- data/lib/antelope/template/scanner.rb +109 -109
- data/lib/antelope/template.rb +65 -60
- data/lib/antelope/version.rb +6 -6
- data/lib/antelope.rb +13 -13
- data/optimizations.txt +42 -0
- data/spec/antelope/ace/compiler_spec.rb +60 -60
- data/spec/antelope/ace/scanner_spec.rb +27 -27
- data/spec/antelope/constructor_spec.rb +133 -136
- data/spec/antelope/template_spec.rb +50 -49
- data/spec/fixtures/simple.ace +22 -22
- data/spec/spec_helper.rb +39 -39
- data/spec/support/benchmark_helper.rb +5 -5
- data/spec/support/grammar_helper.rb +15 -15
- data/subl/Ace (Ruby).JSON-tmLanguage +94 -94
- data/subl/Ace (Ruby).tmLanguage +153 -153
- metadata +17 -6
- data/lib/antelope/generator/templates/output.ant +0 -68
data/examples/liquidscript.ace
CHANGED
@@ -1,162 +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
|
-
%
|
56
|
-
%
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
| vexpression
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
| vexpression
|
103
|
-
| vexpression
|
104
|
-
|
|
105
|
-
|
|
106
|
-
| vexpression
|
107
|
-
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
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
|