personify 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/.gitignore +2 -1
  2. data/.rvmrc +1 -0
  3. data/Rakefile +1 -0
  4. data/VERSION +1 -1
  5. data/lib/personify/parser/personify.rb +178 -122
  6. data/lib/personify.rb +1 -1
  7. data/test/context_test.rb +3 -3
  8. data/test/parse_runner.rb +1 -2
  9. data/test/parser_test.rb +3 -3
  10. metadata +42 -120
  11. data/vendor/treetop/.gitignore +0 -5
  12. data/vendor/treetop/History.txt +0 -9
  13. data/vendor/treetop/README +0 -164
  14. data/vendor/treetop/Rakefile +0 -20
  15. data/vendor/treetop/Treetop.tmbundle/Snippets/grammar ___ end.tmSnippet +0 -20
  16. data/vendor/treetop/Treetop.tmbundle/Snippets/rule ___ end.tmSnippet +0 -18
  17. data/vendor/treetop/Treetop.tmbundle/Syntaxes/Treetop Grammar.tmLanguage +0 -251
  18. data/vendor/treetop/Treetop.tmbundle/info.plist +0 -10
  19. data/vendor/treetop/bin/tt +0 -28
  20. data/vendor/treetop/doc/contributing_and_planned_features.markdown +0 -103
  21. data/vendor/treetop/doc/grammar_composition.markdown +0 -65
  22. data/vendor/treetop/doc/index.markdown +0 -90
  23. data/vendor/treetop/doc/pitfalls_and_advanced_techniques.markdown +0 -51
  24. data/vendor/treetop/doc/semantic_interpretation.markdown +0 -189
  25. data/vendor/treetop/doc/site.rb +0 -110
  26. data/vendor/treetop/doc/sitegen.rb +0 -60
  27. data/vendor/treetop/doc/syntactic_recognition.markdown +0 -100
  28. data/vendor/treetop/doc/using_in_ruby.markdown +0 -21
  29. data/vendor/treetop/examples/lambda_calculus/arithmetic.rb +0 -551
  30. data/vendor/treetop/examples/lambda_calculus/arithmetic.treetop +0 -97
  31. data/vendor/treetop/examples/lambda_calculus/arithmetic_node_classes.rb +0 -7
  32. data/vendor/treetop/examples/lambda_calculus/arithmetic_test.rb +0 -54
  33. data/vendor/treetop/examples/lambda_calculus/lambda_calculus +0 -0
  34. data/vendor/treetop/examples/lambda_calculus/lambda_calculus.rb +0 -718
  35. data/vendor/treetop/examples/lambda_calculus/lambda_calculus.treetop +0 -132
  36. data/vendor/treetop/examples/lambda_calculus/lambda_calculus_node_classes.rb +0 -5
  37. data/vendor/treetop/examples/lambda_calculus/lambda_calculus_test.rb +0 -89
  38. data/vendor/treetop/examples/lambda_calculus/test_helper.rb +0 -18
  39. data/vendor/treetop/lib/treetop/bootstrap_gen_1_metagrammar.rb +0 -45
  40. data/vendor/treetop/lib/treetop/compiler/grammar_compiler.rb +0 -40
  41. data/vendor/treetop/lib/treetop/compiler/lexical_address_space.rb +0 -17
  42. data/vendor/treetop/lib/treetop/compiler/metagrammar.rb +0 -2955
  43. data/vendor/treetop/lib/treetop/compiler/metagrammar.treetop +0 -404
  44. data/vendor/treetop/lib/treetop/compiler/node_classes/anything_symbol.rb +0 -20
  45. data/vendor/treetop/lib/treetop/compiler/node_classes/atomic_expression.rb +0 -14
  46. data/vendor/treetop/lib/treetop/compiler/node_classes/character_class.rb +0 -22
  47. data/vendor/treetop/lib/treetop/compiler/node_classes/choice.rb +0 -31
  48. data/vendor/treetop/lib/treetop/compiler/node_classes/declaration_sequence.rb +0 -24
  49. data/vendor/treetop/lib/treetop/compiler/node_classes/grammar.rb +0 -28
  50. data/vendor/treetop/lib/treetop/compiler/node_classes/inline_module.rb +0 -27
  51. data/vendor/treetop/lib/treetop/compiler/node_classes/nonterminal.rb +0 -13
  52. data/vendor/treetop/lib/treetop/compiler/node_classes/optional.rb +0 -19
  53. data/vendor/treetop/lib/treetop/compiler/node_classes/parenthesized_expression.rb +0 -9
  54. data/vendor/treetop/lib/treetop/compiler/node_classes/parsing_expression.rb +0 -138
  55. data/vendor/treetop/lib/treetop/compiler/node_classes/parsing_rule.rb +0 -55
  56. data/vendor/treetop/lib/treetop/compiler/node_classes/predicate.rb +0 -45
  57. data/vendor/treetop/lib/treetop/compiler/node_classes/repetition.rb +0 -55
  58. data/vendor/treetop/lib/treetop/compiler/node_classes/sequence.rb +0 -68
  59. data/vendor/treetop/lib/treetop/compiler/node_classes/terminal.rb +0 -20
  60. data/vendor/treetop/lib/treetop/compiler/node_classes/transient_prefix.rb +0 -9
  61. data/vendor/treetop/lib/treetop/compiler/node_classes/treetop_file.rb +0 -9
  62. data/vendor/treetop/lib/treetop/compiler/node_classes.rb +0 -19
  63. data/vendor/treetop/lib/treetop/compiler/ruby_builder.rb +0 -113
  64. data/vendor/treetop/lib/treetop/compiler.rb +0 -6
  65. data/vendor/treetop/lib/treetop/ruby_extensions/string.rb +0 -42
  66. data/vendor/treetop/lib/treetop/ruby_extensions.rb +0 -2
  67. data/vendor/treetop/lib/treetop/runtime/compiled_parser.rb +0 -95
  68. data/vendor/treetop/lib/treetop/runtime/interval_skip_list/head_node.rb +0 -15
  69. data/vendor/treetop/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb +0 -200
  70. data/vendor/treetop/lib/treetop/runtime/interval_skip_list/node.rb +0 -164
  71. data/vendor/treetop/lib/treetop/runtime/interval_skip_list.rb +0 -4
  72. data/vendor/treetop/lib/treetop/runtime/syntax_node.rb +0 -72
  73. data/vendor/treetop/lib/treetop/runtime/terminal_parse_failure.rb +0 -16
  74. data/vendor/treetop/lib/treetop/runtime/terminal_syntax_node.rb +0 -17
  75. data/vendor/treetop/lib/treetop/runtime.rb +0 -5
  76. data/vendor/treetop/lib/treetop/version.rb +0 -9
  77. data/vendor/treetop/lib/treetop.rb +0 -11
  78. data/vendor/treetop/script/generate_metagrammar.rb +0 -14
  79. data/vendor/treetop/script/svnadd +0 -11
  80. data/vendor/treetop/script/svnrm +0 -11
  81. data/vendor/treetop/spec/compiler/and_predicate_spec.rb +0 -36
  82. data/vendor/treetop/spec/compiler/anything_symbol_spec.rb +0 -52
  83. data/vendor/treetop/spec/compiler/character_class_spec.rb +0 -188
  84. data/vendor/treetop/spec/compiler/choice_spec.rb +0 -80
  85. data/vendor/treetop/spec/compiler/circular_compilation_spec.rb +0 -28
  86. data/vendor/treetop/spec/compiler/failure_propagation_functional_spec.rb +0 -21
  87. data/vendor/treetop/spec/compiler/grammar_compiler_spec.rb +0 -84
  88. data/vendor/treetop/spec/compiler/grammar_spec.rb +0 -41
  89. data/vendor/treetop/spec/compiler/nonterminal_symbol_spec.rb +0 -40
  90. data/vendor/treetop/spec/compiler/not_predicate_spec.rb +0 -38
  91. data/vendor/treetop/spec/compiler/one_or_more_spec.rb +0 -35
  92. data/vendor/treetop/spec/compiler/optional_spec.rb +0 -37
  93. data/vendor/treetop/spec/compiler/parenthesized_expression_spec.rb +0 -19
  94. data/vendor/treetop/spec/compiler/parsing_rule_spec.rb +0 -32
  95. data/vendor/treetop/spec/compiler/sequence_spec.rb +0 -115
  96. data/vendor/treetop/spec/compiler/terminal_spec.rb +0 -81
  97. data/vendor/treetop/spec/compiler/terminal_symbol_spec.rb +0 -37
  98. data/vendor/treetop/spec/compiler/test_grammar.treetop +0 -7
  99. data/vendor/treetop/spec/compiler/test_grammar.tt +0 -7
  100. data/vendor/treetop/spec/compiler/test_grammar_do.treetop +0 -7
  101. data/vendor/treetop/spec/compiler/zero_or_more_spec.rb +0 -56
  102. data/vendor/treetop/spec/composition/a.treetop +0 -11
  103. data/vendor/treetop/spec/composition/b.treetop +0 -11
  104. data/vendor/treetop/spec/composition/c.treetop +0 -10
  105. data/vendor/treetop/spec/composition/d.treetop +0 -10
  106. data/vendor/treetop/spec/composition/grammar_composition_spec.rb +0 -26
  107. data/vendor/treetop/spec/ruby_extensions/string_spec.rb +0 -32
  108. data/vendor/treetop/spec/runtime/compiled_parser_spec.rb +0 -101
  109. data/vendor/treetop/spec/runtime/interval_skip_list/delete_spec.rb +0 -147
  110. data/vendor/treetop/spec/runtime/interval_skip_list/expire_range_spec.rb +0 -349
  111. data/vendor/treetop/spec/runtime/interval_skip_list/insert_and_delete_node.rb +0 -385
  112. data/vendor/treetop/spec/runtime/interval_skip_list/insert_spec.rb +0 -660
  113. data/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +0 -6175
  114. data/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +0 -58
  115. data/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture.rb +0 -23
  116. data/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +0 -164
  117. data/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb +0 -84
  118. data/vendor/treetop/spec/runtime/syntax_node_spec.rb +0 -53
  119. data/vendor/treetop/spec/spec_helper.rb +0 -106
  120. data/vendor/treetop/spec/spec_suite.rb +0 -4
  121. data/vendor/treetop/treetop.gemspec +0 -18
@@ -1,404 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- grammar Metagrammar
4
- rule treetop_file
5
- prefix:space? module_or_grammar:(module_declaration / grammar) suffix:space? {
6
- def compile
7
- prefix.text_value + module_or_grammar.compile + suffix.text_value
8
- end
9
- }
10
- end
11
-
12
- rule module_declaration
13
- prefix:('module' space [A-Z] alphanumeric_char* space) module_contents:(module_declaration / grammar) suffix:(space 'end') {
14
- def compile
15
- prefix.text_value + module_contents.compile + suffix.text_value
16
- end
17
- }
18
- end
19
-
20
- rule grammar
21
- 'grammar' space grammar_name space ('do' space)? declaration_sequence space? 'end' <Grammar>
22
- end
23
-
24
- rule grammar_name
25
- ([A-Z] alphanumeric_char*)
26
- end
27
-
28
- rule declaration_sequence
29
- head:declaration tail:(space declaration)* <DeclarationSequence> {
30
- def declarations
31
- [head] + tail
32
- end
33
-
34
- def tail
35
- super.elements.map { |elt| elt.declaration }
36
- end
37
- }
38
- /
39
- '' {
40
- def compile(builder)
41
- end
42
- }
43
- end
44
-
45
- rule declaration
46
- parsing_rule / include_declaration
47
- end
48
-
49
- rule include_declaration
50
- 'include' space [A-Z] (alphanumeric_char / '::')* {
51
- def compile(builder)
52
- builder << text_value
53
- end
54
- }
55
- end
56
-
57
- rule parsing_rule
58
- 'rule' space nonterminal space ('do' space)? parsing_expression space 'end' <ParsingRule>
59
- end
60
-
61
- rule parsing_expression
62
- choice / sequence / primary
63
- end
64
-
65
- rule choice
66
- head:alternative tail:(space? '/' space? alternative)+ <Choice> {
67
- def alternatives
68
- [head] + tail
69
- end
70
-
71
- def tail
72
- super.elements.map {|elt| elt.alternative}
73
- end
74
-
75
- def inline_modules
76
- (alternatives.map {|alt| alt.inline_modules }).flatten
77
- end
78
- }
79
- end
80
-
81
- rule sequence
82
- head:labeled_sequence_primary tail:(space labeled_sequence_primary)+ node_class_declarations <Sequence> {
83
- def sequence_elements
84
- [head] + tail
85
- end
86
-
87
- def tail
88
- super.elements.map {|elt| elt.labeled_sequence_primary }
89
- end
90
-
91
- def inline_modules
92
- (sequence_elements.map {|elt| elt.inline_modules}).flatten +
93
- [sequence_element_accessor_module] +
94
- node_class_declarations.inline_modules
95
- end
96
-
97
- def inline_module_name
98
- node_class_declarations.inline_module_name
99
- end
100
- }
101
- end
102
-
103
- rule alternative
104
- sequence / primary
105
- end
106
-
107
- rule primary
108
- prefix atomic {
109
- def compile(address, builder, parent_expression=nil)
110
- prefix.compile(address, builder, self)
111
- end
112
-
113
- def prefixed_expression
114
- atomic
115
- end
116
-
117
- def inline_modules
118
- atomic.inline_modules
119
- end
120
-
121
- def inline_module_name
122
- nil
123
- end
124
- }
125
- /
126
- atomic suffix node_class_declarations {
127
- def compile(address, builder, parent_expression=nil)
128
- suffix.compile(address, builder, self)
129
- end
130
-
131
- def optional_expression
132
- atomic
133
- end
134
-
135
- def node_class_name
136
- node_class_declarations.node_class_name
137
- end
138
-
139
- def inline_modules
140
- atomic.inline_modules + node_class_declarations.inline_modules
141
- end
142
-
143
- def inline_module_name
144
- node_class_declarations.inline_module_name
145
- end
146
- }
147
- /
148
- atomic node_class_declarations {
149
- def compile(address, builder, parent_expression=nil)
150
- atomic.compile(address, builder, self)
151
- end
152
-
153
- def node_class_name
154
- node_class_declarations.node_class_name
155
- end
156
-
157
- def inline_modules
158
- atomic.inline_modules + node_class_declarations.inline_modules
159
- end
160
-
161
- def inline_module_name
162
- node_class_declarations.inline_module_name
163
- end
164
- }
165
- end
166
-
167
- rule labeled_sequence_primary
168
- label sequence_primary {
169
- def compile(lexical_address, builder)
170
- sequence_primary.compile(lexical_address, builder)
171
- end
172
-
173
- def inline_modules
174
- sequence_primary.inline_modules
175
- end
176
-
177
- def label_name
178
- if label.name
179
- label.name
180
- elsif sequence_primary.instance_of?(Nonterminal)
181
- sequence_primary.text_value
182
- else
183
- nil
184
- end
185
- end
186
- }
187
- end
188
-
189
- rule label
190
- (alpha_char alphanumeric_char*) ':' {
191
- def name
192
- elements[0].text_value
193
- end
194
- }
195
- /
196
- '' {
197
- def name
198
- nil
199
- end
200
- }
201
- end
202
-
203
- rule sequence_primary
204
- prefix atomic {
205
- def compile(lexical_address, builder)
206
- prefix.compile(lexical_address, builder, self)
207
- end
208
-
209
- def prefixed_expression
210
- elements[1]
211
- end
212
-
213
- def inline_modules
214
- atomic.inline_modules
215
- end
216
-
217
- def inline_module_name
218
- nil
219
- end
220
- }
221
- /
222
- atomic suffix {
223
- def compile(lexical_address, builder)
224
- suffix.compile(lexical_address, builder, self)
225
- end
226
-
227
- def node_class_name
228
- nil
229
- end
230
-
231
- def inline_modules
232
- atomic.inline_modules
233
- end
234
-
235
- def inline_module_name
236
- nil
237
- end
238
- }
239
- /
240
- atomic
241
- end
242
-
243
- rule suffix
244
- repetition_suffix / optional_suffix
245
- end
246
-
247
- rule optional_suffix
248
- '?' <Optional>
249
- end
250
-
251
- rule node_class_declarations
252
- node_class_expression trailing_inline_module {
253
- def node_class_name
254
- node_class_expression.node_class_name
255
- end
256
-
257
- def inline_modules
258
- trailing_inline_module.inline_modules
259
- end
260
-
261
- def inline_module
262
- trailing_inline_module.inline_module
263
- end
264
-
265
- def inline_module_name
266
- inline_module.module_name if inline_module
267
- end
268
- }
269
- end
270
-
271
- rule repetition_suffix
272
- '+' <OneOrMore> / '*' <ZeroOrMore>
273
- end
274
-
275
- rule prefix
276
- '&' <AndPredicate> / '!' <NotPredicate> / '~' <TransientPrefix>
277
- end
278
-
279
- rule atomic
280
- terminal
281
- /
282
- nonterminal
283
- /
284
- parenthesized_expression
285
- end
286
-
287
- rule parenthesized_expression
288
- '(' space? parsing_expression space? ')' <ParenthesizedExpression> {
289
- def inline_modules
290
- parsing_expression.inline_modules
291
- end
292
- }
293
- end
294
-
295
- rule nonterminal
296
- !keyword_inside_grammar (alpha_char alphanumeric_char*) <Nonterminal>
297
- end
298
-
299
- rule terminal
300
- quoted_string / character_class / anything_symbol
301
- end
302
-
303
- rule quoted_string
304
- (single_quoted_string / double_quoted_string) {
305
- def string
306
- super.text_value
307
- end
308
- }
309
- end
310
-
311
- rule double_quoted_string
312
- '"' string:(!'"' ("\\\\" / '\"' / .))* '"' <Terminal>
313
- end
314
-
315
- rule single_quoted_string
316
- "'" string:(!"'" ("\\\\" / "\\'" / .))* "'" <Terminal>
317
- end
318
-
319
- rule character_class
320
- '[' characters:(!']' ('\\' . /!'\\' .))+ ']' <CharacterClass> {
321
- def characters
322
- super.text_value
323
- end
324
- }
325
- end
326
-
327
- rule anything_symbol
328
- '.' <AnythingSymbol>
329
- end
330
-
331
- rule node_class_expression
332
- space '<' (!'>' .)+ '>' {
333
- def node_class_name
334
- elements[2].text_value
335
- end
336
- }
337
- /
338
- '' {
339
- def node_class_name
340
- nil
341
- end
342
- }
343
- end
344
-
345
- rule trailing_inline_module
346
- space inline_module {
347
- def inline_modules
348
- [inline_module]
349
- end
350
-
351
- def inline_module_name
352
- inline_module.module_name
353
- end
354
- }
355
- /
356
- '' {
357
- def inline_modules
358
- []
359
- end
360
-
361
- def inline_module
362
- nil
363
- end
364
-
365
- def inline_module_name
366
- nil
367
- end
368
- }
369
- end
370
-
371
- rule inline_module
372
- '{' (inline_module / ![{}] .)* '}' <InlineModule>
373
- end
374
-
375
- rule keyword_inside_grammar
376
- ('rule' / 'end') !non_space_char
377
- end
378
-
379
- rule non_space_char
380
- !space .
381
- end
382
-
383
- rule alpha_char
384
- [A-Za-z_]
385
- end
386
-
387
- rule alphanumeric_char
388
- alpha_char / [0-9]
389
- end
390
-
391
- rule space
392
- (white / comment_to_eol)+
393
- end
394
-
395
- rule comment_to_eol
396
- '#' (!"\n" .)*
397
- end
398
-
399
- rule white
400
- [ \t\n\r]
401
- end
402
- end
403
- end
404
- end
@@ -1,20 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class AnythingSymbol < AtomicExpression
4
- def compile(address, builder, parent_expression = nil)
5
- super
6
- builder.if__ "index < input_length" do
7
- builder << 'next_character = index + input[index..-1].match(/\A(.)/um).end(1)'
8
- assign_result "instantiate_node(#{node_class_name},input, index...next_character)"
9
- extend_result_with_inline_module
10
- builder << "@index = next_character"
11
- end
12
- builder.else_ do
13
- builder << 'terminal_parse_failure("any character")'
14
- assign_result 'nil'
15
- end
16
- end
17
- end
18
- end
19
- end
20
-
@@ -1,14 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class AtomicExpression < ParsingExpression
4
- def inline_modules
5
- []
6
- end
7
-
8
- def single_quote(string)
9
- # Double any backslashes, then backslash any single-quotes:
10
- "'#{string.gsub(/\\/) { '\\\\' }.gsub(/'/) { "\\'"}}'"
11
- end
12
- end
13
- end
14
- end
@@ -1,22 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class CharacterClass < AtomicExpression
4
- def compile(address, builder, parent_expression = nil)
5
- super
6
-
7
- builder.if__ "input.index(Regexp.new(#{single_quote(text_value)},nil,'u'), index) == index" do
8
- builder << 'next_character = index + input[index..-1].match(/\A(.)/um).end(1)'
9
- assign_result "instantiate_node(#{node_class_name},input, index...next_character)"
10
- extend_result_with_inline_module
11
- builder << "@index = next_character"
12
- end
13
- builder.else_ do
14
- "terminal_parse_failure(#{single_quote(characters)})"
15
- assign_result 'nil'
16
- end
17
- end
18
- end
19
- end
20
- end
21
-
22
-
@@ -1,31 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Choice < ParsingExpression
4
- def compile(address, builder, parent_expression = nil)
5
- super
6
- begin_comment(self)
7
- use_vars :result, :start_index
8
- compile_alternatives(alternatives)
9
- end_comment(self)
10
- end
11
-
12
- def compile_alternatives(alternatives)
13
- obtain_new_subexpression_address
14
- alternatives.first.compile(subexpression_address, builder)
15
- builder.if__ subexpression_success? do
16
- assign_result subexpression_result_var
17
- extend_result_with_declared_module
18
- extend_result_with_inline_module
19
- end
20
- builder.else_ do
21
- if alternatives.size == 1
22
- reset_index
23
- assign_failure start_index_var
24
- else
25
- compile_alternatives(alternatives[1..-1])
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,24 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class DeclarationSequence < Runtime::SyntaxNode
4
-
5
- def compile(builder)
6
- unless rules.empty?
7
- builder.method_declaration("root") do
8
- builder << "@root || :#{rules.first.name}"
9
- end
10
- builder.newline
11
- end
12
-
13
- declarations.each do |declaration|
14
- declaration.compile(builder)
15
- builder.newline
16
- end
17
- end
18
-
19
- def rules
20
- declarations.select { |declaration| declaration.instance_of?(ParsingRule) }
21
- end
22
- end
23
- end
24
- end
@@ -1,28 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Grammar < Runtime::SyntaxNode
4
- def compile
5
- builder = RubyBuilder.new
6
-
7
- builder.module_declaration "#{grammar_name.text_value}" do
8
- builder.in(indent_level) # account for initial indentation of grammar declaration
9
- builder << "include Treetop::Runtime"
10
- builder.newline
11
- declaration_sequence.compile(builder)
12
- end
13
- builder.newline
14
- builder.class_declaration "#{parser_name} < Treetop::Runtime::CompiledParser" do
15
- builder << "include #{grammar_name.text_value}"
16
- end
17
- end
18
-
19
- def indent_level
20
- input.column_of(interval.begin) - 1
21
- end
22
-
23
- def parser_name
24
- grammar_name.text_value + 'Parser'
25
- end
26
- end
27
- end
28
- end
@@ -1,27 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- module InlineModuleMixin
4
- attr_reader :module_name
5
-
6
- def compile(index, builder, rule)
7
- @module_name = "#{rule.name.treetop_camelize}#{index}"
8
- end
9
- end
10
-
11
- class InlineModule < Runtime::SyntaxNode
12
-
13
- include InlineModuleMixin
14
-
15
- def compile(index, builder, rule)
16
- super
17
- builder.module_declaration(module_name) do
18
- builder << ruby_code.gsub(/\A\n/, '').rstrip
19
- end
20
- end
21
-
22
- def ruby_code
23
- elements[1].text_value
24
- end
25
- end
26
- end
27
- end
@@ -1,13 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Nonterminal < AtomicExpression
4
- def compile(address, builder, parent_expression = nil)
5
- super
6
- use_vars :result
7
- assign_result text_value == 'super' ? 'super' : "_nt_#{text_value}"
8
- extend_result_with_declared_module
9
- extend_result_with_inline_module
10
- end
11
- end
12
- end
13
- end
@@ -1,19 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class Optional < ParsingExpression
4
- def compile(address, builder, parent_expression)
5
- super
6
- use_vars :result
7
- obtain_new_subexpression_address
8
- parent_expression.atomic.compile(subexpression_address, builder)
9
-
10
- builder.if__ subexpression_success? do
11
- assign_result subexpression_result_var
12
- end
13
- builder.else_ do
14
- assign_result epsilon_node
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,9 +0,0 @@
1
- module Treetop
2
- module Compiler
3
- class ParenthesizedExpression < ParsingExpression
4
- def compile(address, builder, parent_expression = nil)
5
- elements[2].compile(address, builder, parent_expression)
6
- end
7
- end
8
- end
9
- end