mail 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of mail might be problematic. Click here for more details.

Files changed (129) hide show
  1. data/Rakefile +1 -1
  2. data/lib/mail.rb +2 -1
  3. data/lib/mail/version.rb +1 -1
  4. data/lib/vendor/treetop-1.4.3/History.txt +18 -0
  5. data/lib/vendor/treetop-1.4.3/LICENSE +19 -0
  6. data/lib/vendor/treetop-1.4.3/README.md +164 -0
  7. data/lib/vendor/treetop-1.4.3/Rakefile +23 -0
  8. data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/Snippets/grammar ___ end.tmSnippet +20 -0
  9. data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/Snippets/rule ___ end.tmSnippet +18 -0
  10. data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/designable.nib +1524 -0
  11. data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/keyedobjects.nib +0 -0
  12. data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/Support/syntax_tree_viewer.rb +117 -0
  13. data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/Syntaxes/Treetop Grammar.tmLanguage +251 -0
  14. data/lib/vendor/treetop-1.4.3/Treetop.tmbundle/info.plist +10 -0
  15. data/lib/vendor/treetop-1.4.3/benchmark/seqpar.gnuplot +15 -0
  16. data/lib/vendor/treetop-1.4.3/benchmark/seqpar.treetop +16 -0
  17. data/lib/vendor/treetop-1.4.3/benchmark/seqpar_benchmark.rb +107 -0
  18. data/lib/vendor/treetop-1.4.3/bin/tt +112 -0
  19. data/lib/vendor/treetop-1.4.3/doc/contributing_and_planned_features.markdown +103 -0
  20. data/lib/vendor/treetop-1.4.3/doc/grammar_composition.markdown +65 -0
  21. data/lib/vendor/treetop-1.4.3/doc/index.markdown +90 -0
  22. data/lib/vendor/treetop-1.4.3/doc/pitfalls_and_advanced_techniques.markdown +51 -0
  23. data/lib/vendor/treetop-1.4.3/doc/semantic_interpretation.markdown +189 -0
  24. data/lib/vendor/treetop-1.4.3/doc/site.rb +112 -0
  25. data/lib/vendor/treetop-1.4.3/doc/sitegen.rb +65 -0
  26. data/lib/vendor/treetop-1.4.3/doc/syntactic_recognition.markdown +100 -0
  27. data/lib/vendor/treetop-1.4.3/doc/using_in_ruby.markdown +21 -0
  28. data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/arithmetic.rb +551 -0
  29. data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/arithmetic.treetop +97 -0
  30. data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/arithmetic_node_classes.rb +7 -0
  31. data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/arithmetic_test.rb +54 -0
  32. data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/lambda_calculus +0 -0
  33. data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/lambda_calculus.rb +718 -0
  34. data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/lambda_calculus.treetop +132 -0
  35. data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/lambda_calculus_node_classes.rb +5 -0
  36. data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/lambda_calculus_test.rb +89 -0
  37. data/lib/vendor/treetop-1.4.3/examples/lambda_calculus/test_helper.rb +18 -0
  38. data/lib/vendor/treetop-1.4.3/lib/treetop.rb +17 -0
  39. data/lib/vendor/treetop-1.4.3/lib/treetop/bootstrap_gen_1_metagrammar.rb +45 -0
  40. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler.rb +6 -0
  41. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/grammar_compiler.rb +44 -0
  42. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/lexical_address_space.rb +17 -0
  43. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/metagrammar.rb +3366 -0
  44. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/metagrammar.treetop +436 -0
  45. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes.rb +20 -0
  46. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/anything_symbol.rb +18 -0
  47. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/atomic_expression.rb +14 -0
  48. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/character_class.rb +28 -0
  49. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/choice.rb +31 -0
  50. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/declaration_sequence.rb +24 -0
  51. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/grammar.rb +28 -0
  52. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/inline_module.rb +27 -0
  53. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/nonterminal.rb +13 -0
  54. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/optional.rb +19 -0
  55. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/parenthesized_expression.rb +9 -0
  56. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/parsing_expression.rb +146 -0
  57. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/parsing_rule.rb +58 -0
  58. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/predicate.rb +45 -0
  59. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/predicate_block.rb +16 -0
  60. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/repetition.rb +55 -0
  61. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/sequence.rb +71 -0
  62. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/terminal.rb +20 -0
  63. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/transient_prefix.rb +9 -0
  64. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/node_classes/treetop_file.rb +9 -0
  65. data/lib/vendor/treetop-1.4.3/lib/treetop/compiler/ruby_builder.rb +113 -0
  66. data/lib/vendor/treetop-1.4.3/lib/treetop/ruby_extensions.rb +2 -0
  67. data/lib/vendor/treetop-1.4.3/lib/treetop/ruby_extensions/string.rb +42 -0
  68. data/lib/vendor/treetop-1.4.3/lib/treetop/runtime.rb +5 -0
  69. data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/compiled_parser.rb +110 -0
  70. data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/interval_skip_list.rb +4 -0
  71. data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/interval_skip_list/head_node.rb +15 -0
  72. data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb +200 -0
  73. data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/interval_skip_list/node.rb +164 -0
  74. data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/syntax_node.rb +114 -0
  75. data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/terminal_parse_failure.rb +16 -0
  76. data/lib/vendor/treetop-1.4.3/lib/treetop/runtime/terminal_syntax_node.rb +17 -0
  77. data/lib/vendor/treetop-1.4.3/lib/treetop/version.rb +9 -0
  78. data/lib/vendor/treetop-1.4.3/script/generate_metagrammar.rb +14 -0
  79. data/lib/vendor/treetop-1.4.3/script/svnadd +11 -0
  80. data/lib/vendor/treetop-1.4.3/script/svnrm +11 -0
  81. data/lib/vendor/treetop-1.4.3/spec/compiler/and_predicate_spec.rb +36 -0
  82. data/lib/vendor/treetop-1.4.3/spec/compiler/anything_symbol_spec.rb +44 -0
  83. data/lib/vendor/treetop-1.4.3/spec/compiler/character_class_spec.rb +276 -0
  84. data/lib/vendor/treetop-1.4.3/spec/compiler/choice_spec.rb +80 -0
  85. data/lib/vendor/treetop-1.4.3/spec/compiler/circular_compilation_spec.rb +28 -0
  86. data/lib/vendor/treetop-1.4.3/spec/compiler/failure_propagation_functional_spec.rb +21 -0
  87. data/lib/vendor/treetop-1.4.3/spec/compiler/grammar_compiler_spec.rb +84 -0
  88. data/lib/vendor/treetop-1.4.3/spec/compiler/grammar_spec.rb +41 -0
  89. data/lib/vendor/treetop-1.4.3/spec/compiler/multibyte_chars_spec.rb +46 -0
  90. data/lib/vendor/treetop-1.4.3/spec/compiler/nonterminal_symbol_spec.rb +40 -0
  91. data/lib/vendor/treetop-1.4.3/spec/compiler/not_predicate_spec.rb +38 -0
  92. data/lib/vendor/treetop-1.4.3/spec/compiler/one_or_more_spec.rb +35 -0
  93. data/lib/vendor/treetop-1.4.3/spec/compiler/optional_spec.rb +37 -0
  94. data/lib/vendor/treetop-1.4.3/spec/compiler/parenthesized_expression_spec.rb +19 -0
  95. data/lib/vendor/treetop-1.4.3/spec/compiler/parsing_rule_spec.rb +61 -0
  96. data/lib/vendor/treetop-1.4.3/spec/compiler/repeated_subrule_spec.rb +29 -0
  97. data/lib/vendor/treetop-1.4.3/spec/compiler/semantic_predicate_spec.rb +175 -0
  98. data/lib/vendor/treetop-1.4.3/spec/compiler/sequence_spec.rb +115 -0
  99. data/lib/vendor/treetop-1.4.3/spec/compiler/terminal_spec.rb +81 -0
  100. data/lib/vendor/treetop-1.4.3/spec/compiler/terminal_symbol_spec.rb +37 -0
  101. data/lib/vendor/treetop-1.4.3/spec/compiler/test_grammar.treetop +7 -0
  102. data/lib/vendor/treetop-1.4.3/spec/compiler/test_grammar.tt +7 -0
  103. data/lib/vendor/treetop-1.4.3/spec/compiler/test_grammar_do.treetop +7 -0
  104. data/lib/vendor/treetop-1.4.3/spec/compiler/tt_compiler_spec.rb +216 -0
  105. data/lib/vendor/treetop-1.4.3/spec/compiler/zero_or_more_spec.rb +56 -0
  106. data/lib/vendor/treetop-1.4.3/spec/composition/a.treetop +11 -0
  107. data/lib/vendor/treetop-1.4.3/spec/composition/b.treetop +11 -0
  108. data/lib/vendor/treetop-1.4.3/spec/composition/c.treetop +10 -0
  109. data/lib/vendor/treetop-1.4.3/spec/composition/d.treetop +10 -0
  110. data/lib/vendor/treetop-1.4.3/spec/composition/f.treetop +17 -0
  111. data/lib/vendor/treetop-1.4.3/spec/composition/grammar_composition_spec.rb +40 -0
  112. data/lib/vendor/treetop-1.4.3/spec/composition/subfolder/e_includes_c.treetop +15 -0
  113. data/lib/vendor/treetop-1.4.3/spec/ruby_extensions/string_spec.rb +32 -0
  114. data/lib/vendor/treetop-1.4.3/spec/runtime/compiled_parser_spec.rb +101 -0
  115. data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/delete_spec.rb +147 -0
  116. data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/expire_range_spec.rb +349 -0
  117. data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/insert_and_delete_node.rb +385 -0
  118. data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/insert_spec.rb +660 -0
  119. data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +6175 -0
  120. data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +58 -0
  121. data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/palindromic_fixture.rb +23 -0
  122. data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +164 -0
  123. data/lib/vendor/treetop-1.4.3/spec/runtime/interval_skip_list/spec_helper.rb +84 -0
  124. data/lib/vendor/treetop-1.4.3/spec/runtime/syntax_node_spec.rb +77 -0
  125. data/lib/vendor/treetop-1.4.3/spec/spec_helper.rb +110 -0
  126. data/lib/vendor/treetop-1.4.3/spec/spec_suite.rb +4 -0
  127. data/lib/vendor/treetop-1.4.3/treetop.gemspec +18 -0
  128. data/lib/vendor/treetop.rb +5 -0
  129. metadata +126 -11
@@ -0,0 +1,132 @@
1
+ grammar LambdaCalculus
2
+ include Arithmetic
3
+
4
+ rule program
5
+ expression more_expressions:(';' space expression)* {
6
+ def eval(env={})
7
+ env = env.clone
8
+ last_eval = nil
9
+ expressions.each do |exp|
10
+ last_eval = exp.eval(env)
11
+ end
12
+ last_eval
13
+ end
14
+
15
+ def expressions
16
+ [expression] + more_expressions.elements.map {|elt| elt.expression}
17
+ end
18
+ }
19
+ end
20
+
21
+ rule expression
22
+ definition / conditional / application / function / super
23
+ end
24
+
25
+ rule definition
26
+ 'def' space variable space expression {
27
+ def eval(env)
28
+ env[variable.name] = expression.eval(env)
29
+ end
30
+ }
31
+ end
32
+
33
+ rule conditional
34
+ 'if' space '(' space condition:expression space ')' space
35
+ true_case:expression space 'else' space false_case:expression {
36
+ def eval(env)
37
+ if condition.eval(env)
38
+ true_case.eval(env)
39
+ else
40
+ false_case.eval(env)
41
+ end
42
+ end
43
+ }
44
+ end
45
+
46
+ rule primary
47
+ application / super
48
+ end
49
+
50
+ rule application
51
+ operator space expression <Application> {
52
+ def eval(env={})
53
+ left_associative_apply(operator.eval(env), env)
54
+ end
55
+
56
+ def left_associative_apply(operator, env)
57
+ if expression.instance_of?(Application)
58
+ expression.left_associative_apply(operator.apply(expression.operator.eval(env)), env)
59
+ else
60
+ operator.apply(expression.eval(env))
61
+ end
62
+ end
63
+
64
+ def to_s(env={})
65
+ operator.to_s(env) + ' ' + expression.to_s(env)
66
+ end
67
+ }
68
+ end
69
+
70
+ rule operator
71
+ function / variable
72
+ end
73
+
74
+ rule non_application
75
+ function / variable
76
+ end
77
+
78
+ rule function
79
+ '\\' param:variable '(' body:expression ')' {
80
+ class Closure
81
+ attr_reader :env, :function
82
+
83
+ def initialize(function, env)
84
+ @function = function
85
+ @env = env
86
+ end
87
+
88
+ def apply(arg)
89
+ function.body.eval(function.param.bind(arg, env))
90
+ end
91
+
92
+ def to_s(other_env={})
93
+ "\\#{function.param.to_s}(#{function.body.to_s(other_env.merge(env))})"
94
+ end
95
+ end
96
+
97
+ def eval(env={})
98
+ Closure.new(self, env)
99
+ end
100
+
101
+ def to_s(env={})
102
+ eval(env).to_s
103
+ end
104
+ }
105
+ end
106
+
107
+ rule variable
108
+ !keyword (
109
+ super {
110
+ def bind(value, env)
111
+ env.merge(name => value)
112
+ end
113
+
114
+ def to_s(env={})
115
+ env.has_key?(name) ? env[name].to_s : name
116
+ end
117
+ }
118
+ )
119
+ end
120
+
121
+ rule keyword
122
+ ('if' / 'else') !non_space_char
123
+ end
124
+
125
+ rule non_space_char
126
+ ![ \n] .
127
+ end
128
+
129
+ rule space
130
+ [ \n]*
131
+ end
132
+ end
@@ -0,0 +1,5 @@
1
+ module LambdaCalculus
2
+ class Application < Treetop::Runtime::SyntaxNode
3
+
4
+ end
5
+ end
@@ -0,0 +1,89 @@
1
+ dir = File.dirname(__FILE__)
2
+ require File.expand_path("#{dir}/test_helper")
3
+ require File.expand_path("#{dir}/arithmetic_node_classes")
4
+ require File.expand_path("#{dir}/lambda_calculus_node_classes")
5
+ Treetop.load File.expand_path("#{dir}/arithmetic")
6
+ Treetop.load File.expand_path("#{dir}/lambda_calculus")
7
+
8
+ class Treetop::Runtime::SyntaxNode
9
+ def method_missing(method, *args)
10
+ raise "Node representing #{text_value} does not respond to #{method}"
11
+ end
12
+ end
13
+
14
+ class LambdaCalculusParserTest < Test::Unit::TestCase
15
+ include ParserTestHelper
16
+
17
+ def setup
18
+ @parser = LambdaCalculusParser.new
19
+ end
20
+
21
+ def test_free_variable
22
+ assert_equal 'x', parse('x').eval.to_s
23
+ end
24
+
25
+ def test_variable_binding
26
+ variable = parse('x').eval
27
+ env = variable.bind(1, {})
28
+ assert_equal 1, env['x']
29
+ end
30
+
31
+ def test_bound_variable_evaluation
32
+ assert_equal 1, parse('x').eval({'x' => 1})
33
+ end
34
+
35
+ def test_identity_function
36
+ assert_equal '\x(x)', parse('\x(x)').eval.to_s
37
+ end
38
+
39
+ def test_function_returning_constant_function
40
+ assert_equal '\x(\y(x))', parse('\x(\y(x))').eval.to_s
41
+ end
42
+
43
+ def test_identity_function_application
44
+ assert_equal 1, parse('\x(x) 1').eval
45
+ assert_equal '\y(y)', parse('\x(x) \y(y)').eval.to_s
46
+ end
47
+
48
+ def test_constant_function_construction
49
+ assert_equal '\y(1)', parse('\x(\y(x)) 1').eval.to_s
50
+ end
51
+
52
+ def test_multiple_argument_application_is_left_associative
53
+ assert_equal '\b(b)', parse('\x(\y(x y)) \a(a) \b(b)').eval.to_s
54
+ end
55
+
56
+ def test_parentheses_override_application_order
57
+ assert_equal '\y(\b(b) y)', parse('\x(\y(x y)) (\a(a) \b(b))').eval.to_s
58
+ end
59
+
60
+ def test_arithmetic_in_function_body
61
+ assert_equal 10, parse('\x(x + 5) 5').eval
62
+ end
63
+
64
+ def test_addition_of_function_results
65
+ assert_equal 20, parse('\x(x + 5) 5 + \x(15 - x) 5').eval
66
+ end
67
+
68
+ def test_conditional
69
+ result = parse('if (x) 1 else 2')
70
+ assert_equal 1, result.eval({'x' => true})
71
+ assert_equal 2, result.eval({'x' => false})
72
+ end
73
+
74
+ def test_keyword
75
+ assert @parser.parse('if').failure?
76
+ assert @parser.parse('else').failure?
77
+ assert parse('elsee').success?
78
+ assert parse('iff').success?
79
+ end
80
+
81
+ def test_program
82
+ result = parse('def fact \x(if (x == 0)
83
+ 1
84
+ else
85
+ x * fact (x - 1));
86
+ fact(5)').eval
87
+ assert_equal 5 * 4 * 3 * 2, result
88
+ end
89
+ end
@@ -0,0 +1,18 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'treetop'
4
+
5
+ module ParserTestHelper
6
+ def assert_evals_to_self(input)
7
+ assert_evals_to(input, input)
8
+ end
9
+
10
+ def parse(input)
11
+ result = @parser.parse(input)
12
+ unless result
13
+ puts @parser.terminal_failures.join("\n")
14
+ end
15
+ assert !result.nil?
16
+ result
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+
2
+ module Treetop
3
+ VALID_GRAMMAR_EXT = ['treetop', 'tt']
4
+ VALID_GRAMMAR_EXT_REGEXP = /\.(#{VALID_GRAMMAR_EXT.join('|')})\Z/o
5
+ end
6
+
7
+ dir = File.dirname(__FILE__)
8
+
9
+ TREETOP_ROOT = File.join(dir, 'treetop')
10
+ require File.join(TREETOP_ROOT, "ruby_extensions")
11
+ require File.join(TREETOP_ROOT, "runtime")
12
+ require File.join(TREETOP_ROOT, "compiler")
13
+
14
+ unless defined?(::TREETOP_DISABLE_POLYGLOT)
15
+ require 'polyglot'
16
+ Polyglot.register(Treetop::VALID_GRAMMAR_EXT, Treetop)
17
+ end
@@ -0,0 +1,45 @@
1
+ # This file's job is to load a Treetop::Compiler::Metagrammar and Treetop::Compiler::MetagrammarParser
2
+ # into the environment by compiling the current metagrammar.treetop using a trusted version of Treetop.
3
+
4
+ require 'rubygems'
5
+ dir = File.dirname(__FILE__)
6
+
7
+ TREETOP_VERSION_REQUIRED_TO_BOOTSTRAP = '>= 1.1.5'
8
+
9
+ # Loading trusted version of Treetop to compile the compiler
10
+ gem_spec = Gem.source_index.find_name('treetop', TREETOP_VERSION_REQUIRED_TO_BOOTSTRAP).last
11
+ raise "Install a Treetop Gem version #{TREETOP_VERSION_REQUIRED_TO_BOOTSTRAP} to bootstrap." unless gem_spec
12
+ trusted_treetop_path = gem_spec.full_gem_path
13
+ require File.join(trusted_treetop_path, 'lib', 'treetop')
14
+
15
+ # Relocating trusted version of Treetop to Trusted::Treetop
16
+ Trusted = Module.new
17
+ Trusted::Treetop = Treetop
18
+ Object.send(:remove_const, :Treetop)
19
+ Object.send(:remove_const, :TREETOP_ROOT)
20
+
21
+ # Requiring version of Treetop that is under test
22
+ $exclude_metagrammar = true
23
+ require File.expand_path(File.join(dir, '..', 'treetop'))
24
+
25
+ # Compile and evaluate freshly generated metagrammar source
26
+ METAGRAMMAR_PATH = File.join(TREETOP_ROOT, 'compiler', 'metagrammar.treetop')
27
+ compiled_metagrammar_source = Trusted::Treetop::Compiler::GrammarCompiler.new.ruby_source(METAGRAMMAR_PATH)
28
+ Object.class_eval(compiled_metagrammar_source)
29
+
30
+ # The compiler under test was compiled with the trusted grammar and therefore depends on its runtime
31
+ # But the runtime in the global namespace is the new runtime. We therefore inject the trusted runtime
32
+ # into the compiler so its parser functions correctly. It will still not work for custom classes that
33
+ # explicitly subclass the wrong runtime. For now I am working around this by keeping 1 generation of
34
+ # backward compatibility in these cases.
35
+ # Treetop::Compiler::Metagrammar.module_eval do
36
+ # include Trusted::Treetop::Runtime
37
+ # end
38
+ #
39
+ # Treetop::Compiler.send(:remove_const, :MetagrammarParser)
40
+ # class Treetop::Compiler::MetagrammarParser < Trusted::Treetop::Runtime::CompiledParser
41
+ # include Treetop::Compiler::Metagrammar
42
+ # include Trusted::Treetop::Runtime
43
+ # end
44
+
45
+ $bootstrapped_gen_1_metagrammar = true
@@ -0,0 +1,6 @@
1
+ dir = File.dirname(__FILE__)
2
+ require File.join(dir, *%w[compiler lexical_address_space])
3
+ require File.join(dir, *%w[compiler ruby_builder])
4
+ require File.join(dir, *%w[compiler node_classes])
5
+ require File.join(dir, *%w[compiler metagrammar]) unless defined?($exclude_metagrammar)
6
+ require File.join(dir, *%w[compiler grammar_compiler])
@@ -0,0 +1,44 @@
1
+ module Treetop
2
+ module Compiler
3
+ AUTOGENERATED = "# Autogenerated from a Treetop grammar. Edits may be lost.\n"
4
+ class GrammarCompiler
5
+ def compile(source_path, target_path = source_path.gsub(/\.(treetop|tt)\Z/, '.rb'))
6
+ File.open(target_path, 'w') do |target_file|
7
+ target_file.write(AUTOGENERATED+"\n\n")
8
+ target_file.write(ruby_source(source_path))
9
+ end
10
+ end
11
+
12
+ # compile a treetop file into ruby
13
+ def ruby_source(source_path)
14
+ ruby_source_from_string(File.read(source_path))
15
+ end
16
+
17
+ # compile a string containing treetop source into ruby
18
+ def ruby_source_from_string(s)
19
+ parser = MetagrammarParser.new
20
+ result = parser.parse(s)
21
+ unless result
22
+ raise RuntimeError.new(parser.failure_reason)
23
+ end
24
+ result.compile
25
+ end
26
+ end
27
+ end
28
+
29
+ # compile a treetop source file and load it
30
+ def self.load(path)
31
+ adjusted_path = path =~ /\.(treetop|tt)\Z/ ? path : path + '.treetop'
32
+ File.open(adjusted_path) do |source_file|
33
+ source = source_file.read
34
+ source.gsub!(/\b__FILE__\b/, %Q{"#{adjusted_path}"})
35
+ load_from_string(source)
36
+ end
37
+ end
38
+
39
+ # compile a treetop source string and load it
40
+ def self.load_from_string(s)
41
+ compiler = Treetop::Compiler::GrammarCompiler.new
42
+ Object.class_eval(compiler.ruby_source_from_string(s))
43
+ end
44
+ end
@@ -0,0 +1,17 @@
1
+ module Treetop
2
+ module Compiler
3
+ class LexicalAddressSpace
4
+ def initialize
5
+ reset_addresses
6
+ end
7
+
8
+ def next_address
9
+ @next_address += 1
10
+ end
11
+
12
+ def reset_addresses
13
+ @next_address = -1
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3366 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
4
+ module Treetop
5
+ module Compiler
6
+ module Metagrammar
7
+ include Treetop::Runtime
8
+
9
+ def root
10
+ @root || :treetop_file
11
+ end
12
+
13
+ module TreetopFile0
14
+ def require_statement
15
+ elements[1]
16
+ end
17
+ end
18
+
19
+ module TreetopFile1
20
+ def requires
21
+ elements[0]
22
+ end
23
+
24
+ def prefix
25
+ elements[1]
26
+ end
27
+
28
+ def module_or_grammar
29
+ elements[2]
30
+ end
31
+
32
+ def suffix
33
+ elements[3]
34
+ end
35
+ end
36
+
37
+ module TreetopFile2
38
+ def compile
39
+ requires.text_value + prefix.text_value + module_or_grammar.compile + suffix.text_value
40
+ end
41
+ end
42
+
43
+ def _nt_treetop_file
44
+ start_index = index
45
+ if node_cache[:treetop_file].has_key?(index)
46
+ cached = node_cache[:treetop_file][index]
47
+ if cached
48
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
49
+ @index = cached.interval.end
50
+ end
51
+ return cached
52
+ end
53
+
54
+ i0, s0 = index, []
55
+ s1, i1 = [], index
56
+ loop do
57
+ i2, s2 = index, []
58
+ r4 = _nt_space
59
+ if r4
60
+ r3 = r4
61
+ else
62
+ r3 = instantiate_node(SyntaxNode,input, index...index)
63
+ end
64
+ s2 << r3
65
+ if r3
66
+ r5 = _nt_require_statement
67
+ s2 << r5
68
+ end
69
+ if s2.last
70
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
71
+ r2.extend(TreetopFile0)
72
+ else
73
+ @index = i2
74
+ r2 = nil
75
+ end
76
+ if r2
77
+ s1 << r2
78
+ else
79
+ break
80
+ end
81
+ end
82
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
83
+ s0 << r1
84
+ if r1
85
+ r7 = _nt_space
86
+ if r7
87
+ r6 = r7
88
+ else
89
+ r6 = instantiate_node(SyntaxNode,input, index...index)
90
+ end
91
+ s0 << r6
92
+ if r6
93
+ i8 = index
94
+ r9 = _nt_module_declaration
95
+ if r9
96
+ r8 = r9
97
+ else
98
+ r10 = _nt_grammar
99
+ if r10
100
+ r8 = r10
101
+ else
102
+ @index = i8
103
+ r8 = nil
104
+ end
105
+ end
106
+ s0 << r8
107
+ if r8
108
+ r12 = _nt_space
109
+ if r12
110
+ r11 = r12
111
+ else
112
+ r11 = instantiate_node(SyntaxNode,input, index...index)
113
+ end
114
+ s0 << r11
115
+ end
116
+ end
117
+ end
118
+ if s0.last
119
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
120
+ r0.extend(TreetopFile1)
121
+ r0.extend(TreetopFile2)
122
+ else
123
+ @index = i0
124
+ r0 = nil
125
+ end
126
+
127
+ node_cache[:treetop_file][start_index] = r0
128
+
129
+ r0
130
+ end
131
+
132
+ module RequireStatement0
133
+ def prefix
134
+ elements[0]
135
+ end
136
+
137
+ end
138
+
139
+ def _nt_require_statement
140
+ start_index = index
141
+ if node_cache[:require_statement].has_key?(index)
142
+ cached = node_cache[:require_statement][index]
143
+ if cached
144
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
145
+ @index = cached.interval.end
146
+ end
147
+ return cached
148
+ end
149
+
150
+ i0, s0 = index, []
151
+ r2 = _nt_space
152
+ if r2
153
+ r1 = r2
154
+ else
155
+ r1 = instantiate_node(SyntaxNode,input, index...index)
156
+ end
157
+ s0 << r1
158
+ if r1
159
+ if has_terminal?("require", false, index)
160
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 7))
161
+ @index += 7
162
+ else
163
+ terminal_parse_failure("require")
164
+ r3 = nil
165
+ end
166
+ s0 << r3
167
+ if r3
168
+ s4, i4 = [], index
169
+ loop do
170
+ if has_terminal?('\G[ \\t]', true, index)
171
+ r5 = true
172
+ @index += 1
173
+ else
174
+ r5 = nil
175
+ end
176
+ if r5
177
+ s4 << r5
178
+ else
179
+ break
180
+ end
181
+ end
182
+ if s4.empty?
183
+ @index = i4
184
+ r4 = nil
185
+ else
186
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
187
+ end
188
+ s0 << r4
189
+ if r4
190
+ s6, i6 = [], index
191
+ loop do
192
+ if has_terminal?('\G[^\\n\\r]', true, index)
193
+ r7 = true
194
+ @index += 1
195
+ else
196
+ r7 = nil
197
+ end
198
+ if r7
199
+ s6 << r7
200
+ else
201
+ break
202
+ end
203
+ end
204
+ if s6.empty?
205
+ @index = i6
206
+ r6 = nil
207
+ else
208
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
209
+ end
210
+ s0 << r6
211
+ if r6
212
+ if has_terminal?('\G[\\n\\r]', true, index)
213
+ r8 = true
214
+ @index += 1
215
+ else
216
+ r8 = nil
217
+ end
218
+ s0 << r8
219
+ end
220
+ end
221
+ end
222
+ end
223
+ if s0.last
224
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
225
+ r0.extend(RequireStatement0)
226
+ else
227
+ @index = i0
228
+ r0 = nil
229
+ end
230
+
231
+ node_cache[:require_statement][start_index] = r0
232
+
233
+ r0
234
+ end
235
+
236
+ module ModuleDeclaration0
237
+ def space1
238
+ elements[1]
239
+ end
240
+
241
+ def space2
242
+ elements[4]
243
+ end
244
+ end
245
+
246
+ module ModuleDeclaration1
247
+ def space
248
+ elements[0]
249
+ end
250
+
251
+ end
252
+
253
+ module ModuleDeclaration2
254
+ def prefix
255
+ elements[0]
256
+ end
257
+
258
+ def module_contents
259
+ elements[1]
260
+ end
261
+
262
+ def suffix
263
+ elements[2]
264
+ end
265
+ end
266
+
267
+ module ModuleDeclaration3
268
+ def compile
269
+ prefix.text_value + module_contents.compile + suffix.text_value
270
+ end
271
+ end
272
+
273
+ def _nt_module_declaration
274
+ start_index = index
275
+ if node_cache[:module_declaration].has_key?(index)
276
+ cached = node_cache[:module_declaration][index]
277
+ if cached
278
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
279
+ @index = cached.interval.end
280
+ end
281
+ return cached
282
+ end
283
+
284
+ i0, s0 = index, []
285
+ i1, s1 = index, []
286
+ if has_terminal?('module', false, index)
287
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 6))
288
+ @index += 6
289
+ else
290
+ terminal_parse_failure('module')
291
+ r2 = nil
292
+ end
293
+ s1 << r2
294
+ if r2
295
+ r3 = _nt_space
296
+ s1 << r3
297
+ if r3
298
+ if has_terminal?('\G[A-Z]', true, index)
299
+ r4 = true
300
+ @index += 1
301
+ else
302
+ r4 = nil
303
+ end
304
+ s1 << r4
305
+ if r4
306
+ s5, i5 = [], index
307
+ loop do
308
+ r6 = _nt_alphanumeric_char
309
+ if r6
310
+ s5 << r6
311
+ else
312
+ break
313
+ end
314
+ end
315
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
316
+ s1 << r5
317
+ if r5
318
+ r7 = _nt_space
319
+ s1 << r7
320
+ end
321
+ end
322
+ end
323
+ end
324
+ if s1.last
325
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
326
+ r1.extend(ModuleDeclaration0)
327
+ else
328
+ @index = i1
329
+ r1 = nil
330
+ end
331
+ s0 << r1
332
+ if r1
333
+ i8 = index
334
+ r9 = _nt_module_declaration
335
+ if r9
336
+ r8 = r9
337
+ else
338
+ r10 = _nt_grammar
339
+ if r10
340
+ r8 = r10
341
+ else
342
+ @index = i8
343
+ r8 = nil
344
+ end
345
+ end
346
+ s0 << r8
347
+ if r8
348
+ i11, s11 = index, []
349
+ r12 = _nt_space
350
+ s11 << r12
351
+ if r12
352
+ if has_terminal?('end', false, index)
353
+ r13 = instantiate_node(SyntaxNode,input, index...(index + 3))
354
+ @index += 3
355
+ else
356
+ terminal_parse_failure('end')
357
+ r13 = nil
358
+ end
359
+ s11 << r13
360
+ end
361
+ if s11.last
362
+ r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
363
+ r11.extend(ModuleDeclaration1)
364
+ else
365
+ @index = i11
366
+ r11 = nil
367
+ end
368
+ s0 << r11
369
+ end
370
+ end
371
+ if s0.last
372
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
373
+ r0.extend(ModuleDeclaration2)
374
+ r0.extend(ModuleDeclaration3)
375
+ else
376
+ @index = i0
377
+ r0 = nil
378
+ end
379
+
380
+ node_cache[:module_declaration][start_index] = r0
381
+
382
+ r0
383
+ end
384
+
385
+ module Grammar0
386
+ def space
387
+ elements[1]
388
+ end
389
+ end
390
+
391
+ module Grammar1
392
+ def space1
393
+ elements[1]
394
+ end
395
+
396
+ def grammar_name
397
+ elements[2]
398
+ end
399
+
400
+ def space2
401
+ elements[3]
402
+ end
403
+
404
+ def declaration_sequence
405
+ elements[5]
406
+ end
407
+
408
+ end
409
+
410
+ def _nt_grammar
411
+ start_index = index
412
+ if node_cache[:grammar].has_key?(index)
413
+ cached = node_cache[:grammar][index]
414
+ if cached
415
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
416
+ @index = cached.interval.end
417
+ end
418
+ return cached
419
+ end
420
+
421
+ i0, s0 = index, []
422
+ if has_terminal?('grammar', false, index)
423
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 7))
424
+ @index += 7
425
+ else
426
+ terminal_parse_failure('grammar')
427
+ r1 = nil
428
+ end
429
+ s0 << r1
430
+ if r1
431
+ r2 = _nt_space
432
+ s0 << r2
433
+ if r2
434
+ r3 = _nt_grammar_name
435
+ s0 << r3
436
+ if r3
437
+ r4 = _nt_space
438
+ s0 << r4
439
+ if r4
440
+ i6, s6 = index, []
441
+ if has_terminal?('do', false, index)
442
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 2))
443
+ @index += 2
444
+ else
445
+ terminal_parse_failure('do')
446
+ r7 = nil
447
+ end
448
+ s6 << r7
449
+ if r7
450
+ r8 = _nt_space
451
+ s6 << r8
452
+ end
453
+ if s6.last
454
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
455
+ r6.extend(Grammar0)
456
+ else
457
+ @index = i6
458
+ r6 = nil
459
+ end
460
+ if r6
461
+ r5 = r6
462
+ else
463
+ r5 = instantiate_node(SyntaxNode,input, index...index)
464
+ end
465
+ s0 << r5
466
+ if r5
467
+ r9 = _nt_declaration_sequence
468
+ s0 << r9
469
+ if r9
470
+ r11 = _nt_space
471
+ if r11
472
+ r10 = r11
473
+ else
474
+ r10 = instantiate_node(SyntaxNode,input, index...index)
475
+ end
476
+ s0 << r10
477
+ if r10
478
+ if has_terminal?('end', false, index)
479
+ r12 = instantiate_node(SyntaxNode,input, index...(index + 3))
480
+ @index += 3
481
+ else
482
+ terminal_parse_failure('end')
483
+ r12 = nil
484
+ end
485
+ s0 << r12
486
+ end
487
+ end
488
+ end
489
+ end
490
+ end
491
+ end
492
+ end
493
+ if s0.last
494
+ r0 = instantiate_node(Grammar,input, i0...index, s0)
495
+ r0.extend(Grammar1)
496
+ else
497
+ @index = i0
498
+ r0 = nil
499
+ end
500
+
501
+ node_cache[:grammar][start_index] = r0
502
+
503
+ r0
504
+ end
505
+
506
+ module GrammarName0
507
+ end
508
+
509
+ def _nt_grammar_name
510
+ start_index = index
511
+ if node_cache[:grammar_name].has_key?(index)
512
+ cached = node_cache[:grammar_name][index]
513
+ if cached
514
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
515
+ @index = cached.interval.end
516
+ end
517
+ return cached
518
+ end
519
+
520
+ i0, s0 = index, []
521
+ if has_terminal?('\G[A-Z]', true, index)
522
+ r1 = true
523
+ @index += 1
524
+ else
525
+ r1 = nil
526
+ end
527
+ s0 << r1
528
+ if r1
529
+ s2, i2 = [], index
530
+ loop do
531
+ r3 = _nt_alphanumeric_char
532
+ if r3
533
+ s2 << r3
534
+ else
535
+ break
536
+ end
537
+ end
538
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
539
+ s0 << r2
540
+ end
541
+ if s0.last
542
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
543
+ r0.extend(GrammarName0)
544
+ else
545
+ @index = i0
546
+ r0 = nil
547
+ end
548
+
549
+ node_cache[:grammar_name][start_index] = r0
550
+
551
+ r0
552
+ end
553
+
554
+ module DeclarationSequence0
555
+ def space
556
+ elements[0]
557
+ end
558
+
559
+ def declaration
560
+ elements[1]
561
+ end
562
+ end
563
+
564
+ module DeclarationSequence1
565
+ def head
566
+ elements[0]
567
+ end
568
+
569
+ def tail
570
+ elements[1]
571
+ end
572
+ end
573
+
574
+ module DeclarationSequence2
575
+ def declarations
576
+ [head] + tail
577
+ end
578
+
579
+ def tail
580
+ super.elements.map { |elt| elt.declaration }
581
+ end
582
+ end
583
+
584
+ module DeclarationSequence3
585
+ def compile(builder)
586
+ end
587
+ end
588
+
589
+ def _nt_declaration_sequence
590
+ start_index = index
591
+ if node_cache[:declaration_sequence].has_key?(index)
592
+ cached = node_cache[:declaration_sequence][index]
593
+ if cached
594
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
595
+ @index = cached.interval.end
596
+ end
597
+ return cached
598
+ end
599
+
600
+ i0 = index
601
+ i1, s1 = index, []
602
+ r2 = _nt_declaration
603
+ s1 << r2
604
+ if r2
605
+ s3, i3 = [], index
606
+ loop do
607
+ i4, s4 = index, []
608
+ r5 = _nt_space
609
+ s4 << r5
610
+ if r5
611
+ r6 = _nt_declaration
612
+ s4 << r6
613
+ end
614
+ if s4.last
615
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
616
+ r4.extend(DeclarationSequence0)
617
+ else
618
+ @index = i4
619
+ r4 = nil
620
+ end
621
+ if r4
622
+ s3 << r4
623
+ else
624
+ break
625
+ end
626
+ end
627
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
628
+ s1 << r3
629
+ end
630
+ if s1.last
631
+ r1 = instantiate_node(DeclarationSequence,input, i1...index, s1)
632
+ r1.extend(DeclarationSequence1)
633
+ r1.extend(DeclarationSequence2)
634
+ else
635
+ @index = i1
636
+ r1 = nil
637
+ end
638
+ if r1
639
+ r0 = r1
640
+ else
641
+ if has_terminal?('', false, index)
642
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 0))
643
+ r7.extend(DeclarationSequence3)
644
+ @index += 0
645
+ else
646
+ terminal_parse_failure('')
647
+ r7 = nil
648
+ end
649
+ if r7
650
+ r0 = r7
651
+ else
652
+ @index = i0
653
+ r0 = nil
654
+ end
655
+ end
656
+
657
+ node_cache[:declaration_sequence][start_index] = r0
658
+
659
+ r0
660
+ end
661
+
662
+ def _nt_declaration
663
+ start_index = index
664
+ if node_cache[:declaration].has_key?(index)
665
+ cached = node_cache[:declaration][index]
666
+ if cached
667
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
668
+ @index = cached.interval.end
669
+ end
670
+ return cached
671
+ end
672
+
673
+ i0 = index
674
+ r1 = _nt_parsing_rule
675
+ if r1
676
+ r0 = r1
677
+ else
678
+ r2 = _nt_include_declaration
679
+ if r2
680
+ r0 = r2
681
+ else
682
+ @index = i0
683
+ r0 = nil
684
+ end
685
+ end
686
+
687
+ node_cache[:declaration][start_index] = r0
688
+
689
+ r0
690
+ end
691
+
692
+ module IncludeDeclaration0
693
+ def space
694
+ elements[1]
695
+ end
696
+
697
+ end
698
+
699
+ module IncludeDeclaration1
700
+ def compile(builder)
701
+ builder << text_value
702
+ end
703
+ end
704
+
705
+ def _nt_include_declaration
706
+ start_index = index
707
+ if node_cache[:include_declaration].has_key?(index)
708
+ cached = node_cache[:include_declaration][index]
709
+ if cached
710
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
711
+ @index = cached.interval.end
712
+ end
713
+ return cached
714
+ end
715
+
716
+ i0, s0 = index, []
717
+ if has_terminal?('include', false, index)
718
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 7))
719
+ @index += 7
720
+ else
721
+ terminal_parse_failure('include')
722
+ r1 = nil
723
+ end
724
+ s0 << r1
725
+ if r1
726
+ r2 = _nt_space
727
+ s0 << r2
728
+ if r2
729
+ if has_terminal?('\G[A-Z]', true, index)
730
+ r3 = true
731
+ @index += 1
732
+ else
733
+ r3 = nil
734
+ end
735
+ s0 << r3
736
+ if r3
737
+ s4, i4 = [], index
738
+ loop do
739
+ i5 = index
740
+ r6 = _nt_alphanumeric_char
741
+ if r6
742
+ r5 = r6
743
+ else
744
+ if has_terminal?('::', false, index)
745
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 2))
746
+ @index += 2
747
+ else
748
+ terminal_parse_failure('::')
749
+ r7 = nil
750
+ end
751
+ if r7
752
+ r5 = r7
753
+ else
754
+ @index = i5
755
+ r5 = nil
756
+ end
757
+ end
758
+ if r5
759
+ s4 << r5
760
+ else
761
+ break
762
+ end
763
+ end
764
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
765
+ s0 << r4
766
+ end
767
+ end
768
+ end
769
+ if s0.last
770
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
771
+ r0.extend(IncludeDeclaration0)
772
+ r0.extend(IncludeDeclaration1)
773
+ else
774
+ @index = i0
775
+ r0 = nil
776
+ end
777
+
778
+ node_cache[:include_declaration][start_index] = r0
779
+
780
+ r0
781
+ end
782
+
783
+ module ParsingRule0
784
+ def space
785
+ elements[1]
786
+ end
787
+ end
788
+
789
+ module ParsingRule1
790
+ def space1
791
+ elements[1]
792
+ end
793
+
794
+ def nonterminal
795
+ elements[2]
796
+ end
797
+
798
+ def space2
799
+ elements[3]
800
+ end
801
+
802
+ def parsing_expression
803
+ elements[5]
804
+ end
805
+
806
+ def space3
807
+ elements[6]
808
+ end
809
+
810
+ end
811
+
812
+ def _nt_parsing_rule
813
+ start_index = index
814
+ if node_cache[:parsing_rule].has_key?(index)
815
+ cached = node_cache[:parsing_rule][index]
816
+ if cached
817
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
818
+ @index = cached.interval.end
819
+ end
820
+ return cached
821
+ end
822
+
823
+ i0, s0 = index, []
824
+ if has_terminal?('rule', false, index)
825
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 4))
826
+ @index += 4
827
+ else
828
+ terminal_parse_failure('rule')
829
+ r1 = nil
830
+ end
831
+ s0 << r1
832
+ if r1
833
+ r2 = _nt_space
834
+ s0 << r2
835
+ if r2
836
+ r3 = _nt_nonterminal
837
+ s0 << r3
838
+ if r3
839
+ r4 = _nt_space
840
+ s0 << r4
841
+ if r4
842
+ i6, s6 = index, []
843
+ if has_terminal?('do', false, index)
844
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 2))
845
+ @index += 2
846
+ else
847
+ terminal_parse_failure('do')
848
+ r7 = nil
849
+ end
850
+ s6 << r7
851
+ if r7
852
+ r8 = _nt_space
853
+ s6 << r8
854
+ end
855
+ if s6.last
856
+ r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
857
+ r6.extend(ParsingRule0)
858
+ else
859
+ @index = i6
860
+ r6 = nil
861
+ end
862
+ if r6
863
+ r5 = r6
864
+ else
865
+ r5 = instantiate_node(SyntaxNode,input, index...index)
866
+ end
867
+ s0 << r5
868
+ if r5
869
+ r9 = _nt_parsing_expression
870
+ s0 << r9
871
+ if r9
872
+ r10 = _nt_space
873
+ s0 << r10
874
+ if r10
875
+ if has_terminal?('end', false, index)
876
+ r11 = instantiate_node(SyntaxNode,input, index...(index + 3))
877
+ @index += 3
878
+ else
879
+ terminal_parse_failure('end')
880
+ r11 = nil
881
+ end
882
+ s0 << r11
883
+ end
884
+ end
885
+ end
886
+ end
887
+ end
888
+ end
889
+ end
890
+ if s0.last
891
+ r0 = instantiate_node(ParsingRule,input, i0...index, s0)
892
+ r0.extend(ParsingRule1)
893
+ else
894
+ @index = i0
895
+ r0 = nil
896
+ end
897
+
898
+ node_cache[:parsing_rule][start_index] = r0
899
+
900
+ r0
901
+ end
902
+
903
+ def _nt_parsing_expression
904
+ start_index = index
905
+ if node_cache[:parsing_expression].has_key?(index)
906
+ cached = node_cache[:parsing_expression][index]
907
+ if cached
908
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
909
+ @index = cached.interval.end
910
+ end
911
+ return cached
912
+ end
913
+
914
+ i0 = index
915
+ r1 = _nt_choice
916
+ if r1
917
+ r0 = r1
918
+ else
919
+ r2 = _nt_sequence
920
+ if r2
921
+ r0 = r2
922
+ else
923
+ r3 = _nt_primary
924
+ if r3
925
+ r0 = r3
926
+ else
927
+ @index = i0
928
+ r0 = nil
929
+ end
930
+ end
931
+ end
932
+
933
+ node_cache[:parsing_expression][start_index] = r0
934
+
935
+ r0
936
+ end
937
+
938
+ module Choice0
939
+ def alternative
940
+ elements[3]
941
+ end
942
+ end
943
+
944
+ module Choice1
945
+ def head
946
+ elements[0]
947
+ end
948
+
949
+ def tail
950
+ elements[1]
951
+ end
952
+ end
953
+
954
+ module Choice2
955
+ def alternatives
956
+ [head] + tail
957
+ end
958
+
959
+ def tail
960
+ super.elements.map {|elt| elt.alternative}
961
+ end
962
+
963
+ def inline_modules
964
+ (alternatives.map {|alt| alt.inline_modules }).flatten
965
+ end
966
+ end
967
+
968
+ def _nt_choice
969
+ start_index = index
970
+ if node_cache[:choice].has_key?(index)
971
+ cached = node_cache[:choice][index]
972
+ if cached
973
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
974
+ @index = cached.interval.end
975
+ end
976
+ return cached
977
+ end
978
+
979
+ i0, s0 = index, []
980
+ r1 = _nt_alternative
981
+ s0 << r1
982
+ if r1
983
+ s2, i2 = [], index
984
+ loop do
985
+ i3, s3 = index, []
986
+ r5 = _nt_space
987
+ if r5
988
+ r4 = r5
989
+ else
990
+ r4 = instantiate_node(SyntaxNode,input, index...index)
991
+ end
992
+ s3 << r4
993
+ if r4
994
+ if has_terminal?('/', false, index)
995
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
996
+ @index += 1
997
+ else
998
+ terminal_parse_failure('/')
999
+ r6 = nil
1000
+ end
1001
+ s3 << r6
1002
+ if r6
1003
+ r8 = _nt_space
1004
+ if r8
1005
+ r7 = r8
1006
+ else
1007
+ r7 = instantiate_node(SyntaxNode,input, index...index)
1008
+ end
1009
+ s3 << r7
1010
+ if r7
1011
+ r9 = _nt_alternative
1012
+ s3 << r9
1013
+ end
1014
+ end
1015
+ end
1016
+ if s3.last
1017
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
1018
+ r3.extend(Choice0)
1019
+ else
1020
+ @index = i3
1021
+ r3 = nil
1022
+ end
1023
+ if r3
1024
+ s2 << r3
1025
+ else
1026
+ break
1027
+ end
1028
+ end
1029
+ if s2.empty?
1030
+ @index = i2
1031
+ r2 = nil
1032
+ else
1033
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1034
+ end
1035
+ s0 << r2
1036
+ end
1037
+ if s0.last
1038
+ r0 = instantiate_node(Choice,input, i0...index, s0)
1039
+ r0.extend(Choice1)
1040
+ r0.extend(Choice2)
1041
+ else
1042
+ @index = i0
1043
+ r0 = nil
1044
+ end
1045
+
1046
+ node_cache[:choice][start_index] = r0
1047
+
1048
+ r0
1049
+ end
1050
+
1051
+ module Sequence0
1052
+ def space
1053
+ elements[0]
1054
+ end
1055
+
1056
+ def labeled_sequence_primary
1057
+ elements[1]
1058
+ end
1059
+ end
1060
+
1061
+ module Sequence1
1062
+ def head
1063
+ elements[0]
1064
+ end
1065
+
1066
+ def tail
1067
+ elements[1]
1068
+ end
1069
+
1070
+ def node_class_declarations
1071
+ elements[2]
1072
+ end
1073
+ end
1074
+
1075
+ module Sequence2
1076
+ def sequence_elements
1077
+ [head] + tail
1078
+ end
1079
+
1080
+ def tail
1081
+ super.elements.map {|elt| elt.labeled_sequence_primary }
1082
+ end
1083
+
1084
+ def inline_modules
1085
+ (sequence_elements.map {|elt| elt.inline_modules}).flatten +
1086
+ [sequence_element_accessor_module] +
1087
+ node_class_declarations.inline_modules
1088
+ end
1089
+
1090
+ def inline_module_name
1091
+ node_class_declarations.inline_module_name
1092
+ end
1093
+ end
1094
+
1095
+ def _nt_sequence
1096
+ start_index = index
1097
+ if node_cache[:sequence].has_key?(index)
1098
+ cached = node_cache[:sequence][index]
1099
+ if cached
1100
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1101
+ @index = cached.interval.end
1102
+ end
1103
+ return cached
1104
+ end
1105
+
1106
+ i0, s0 = index, []
1107
+ r1 = _nt_labeled_sequence_primary
1108
+ s0 << r1
1109
+ if r1
1110
+ s2, i2 = [], index
1111
+ loop do
1112
+ i3, s3 = index, []
1113
+ r4 = _nt_space
1114
+ s3 << r4
1115
+ if r4
1116
+ r5 = _nt_labeled_sequence_primary
1117
+ s3 << r5
1118
+ end
1119
+ if s3.last
1120
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
1121
+ r3.extend(Sequence0)
1122
+ else
1123
+ @index = i3
1124
+ r3 = nil
1125
+ end
1126
+ if r3
1127
+ s2 << r3
1128
+ else
1129
+ break
1130
+ end
1131
+ end
1132
+ if s2.empty?
1133
+ @index = i2
1134
+ r2 = nil
1135
+ else
1136
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1137
+ end
1138
+ s0 << r2
1139
+ if r2
1140
+ r6 = _nt_node_class_declarations
1141
+ s0 << r6
1142
+ end
1143
+ end
1144
+ if s0.last
1145
+ r0 = instantiate_node(Sequence,input, i0...index, s0)
1146
+ r0.extend(Sequence1)
1147
+ r0.extend(Sequence2)
1148
+ else
1149
+ @index = i0
1150
+ r0 = nil
1151
+ end
1152
+
1153
+ node_cache[:sequence][start_index] = r0
1154
+
1155
+ r0
1156
+ end
1157
+
1158
+ def _nt_alternative
1159
+ start_index = index
1160
+ if node_cache[:alternative].has_key?(index)
1161
+ cached = node_cache[:alternative][index]
1162
+ if cached
1163
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1164
+ @index = cached.interval.end
1165
+ end
1166
+ return cached
1167
+ end
1168
+
1169
+ i0 = index
1170
+ r1 = _nt_sequence
1171
+ if r1
1172
+ r0 = r1
1173
+ else
1174
+ r2 = _nt_primary
1175
+ if r2
1176
+ r0 = r2
1177
+ else
1178
+ @index = i0
1179
+ r0 = nil
1180
+ end
1181
+ end
1182
+
1183
+ node_cache[:alternative][start_index] = r0
1184
+
1185
+ r0
1186
+ end
1187
+
1188
+ module Primary0
1189
+ def prefix
1190
+ elements[0]
1191
+ end
1192
+
1193
+ def atomic
1194
+ elements[1]
1195
+ end
1196
+ end
1197
+
1198
+ module Primary1
1199
+ def compile(address, builder, parent_expression=nil)
1200
+ prefix.compile(address, builder, self)
1201
+ end
1202
+
1203
+ def prefixed_expression
1204
+ atomic
1205
+ end
1206
+
1207
+ def inline_modules
1208
+ atomic.inline_modules
1209
+ end
1210
+
1211
+ def inline_module_name
1212
+ nil
1213
+ end
1214
+ end
1215
+
1216
+ module Primary2
1217
+ def prefix
1218
+ elements[0]
1219
+ end
1220
+
1221
+ def predicate_block
1222
+ elements[2]
1223
+ end
1224
+ end
1225
+
1226
+ module Primary3
1227
+ def compile(address, builder, parent_expression=nil)
1228
+ prefix.compile(address, builder, self)
1229
+ end
1230
+ def prefixed_expression
1231
+ predicate_block
1232
+ end
1233
+ def inline_modules
1234
+ []
1235
+ end
1236
+ end
1237
+
1238
+ module Primary4
1239
+ def atomic
1240
+ elements[0]
1241
+ end
1242
+
1243
+ def suffix
1244
+ elements[1]
1245
+ end
1246
+
1247
+ def node_class_declarations
1248
+ elements[2]
1249
+ end
1250
+ end
1251
+
1252
+ module Primary5
1253
+ def compile(address, builder, parent_expression=nil)
1254
+ suffix.compile(address, builder, self)
1255
+ end
1256
+
1257
+ def optional_expression
1258
+ atomic
1259
+ end
1260
+
1261
+ def node_class_name
1262
+ node_class_declarations.node_class_name
1263
+ end
1264
+
1265
+ def inline_modules
1266
+ atomic.inline_modules + node_class_declarations.inline_modules
1267
+ end
1268
+
1269
+ def inline_module_name
1270
+ node_class_declarations.inline_module_name
1271
+ end
1272
+ end
1273
+
1274
+ module Primary6
1275
+ def atomic
1276
+ elements[0]
1277
+ end
1278
+
1279
+ def node_class_declarations
1280
+ elements[1]
1281
+ end
1282
+ end
1283
+
1284
+ module Primary7
1285
+ def compile(address, builder, parent_expression=nil)
1286
+ atomic.compile(address, builder, self)
1287
+ end
1288
+
1289
+ def node_class_name
1290
+ node_class_declarations.node_class_name
1291
+ end
1292
+
1293
+ def inline_modules
1294
+ atomic.inline_modules + node_class_declarations.inline_modules
1295
+ end
1296
+
1297
+ def inline_module_name
1298
+ node_class_declarations.inline_module_name
1299
+ end
1300
+ end
1301
+
1302
+ def _nt_primary
1303
+ start_index = index
1304
+ if node_cache[:primary].has_key?(index)
1305
+ cached = node_cache[:primary][index]
1306
+ if cached
1307
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1308
+ @index = cached.interval.end
1309
+ end
1310
+ return cached
1311
+ end
1312
+
1313
+ i0 = index
1314
+ i1, s1 = index, []
1315
+ r2 = _nt_prefix
1316
+ s1 << r2
1317
+ if r2
1318
+ r3 = _nt_atomic
1319
+ s1 << r3
1320
+ end
1321
+ if s1.last
1322
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1323
+ r1.extend(Primary0)
1324
+ r1.extend(Primary1)
1325
+ else
1326
+ @index = i1
1327
+ r1 = nil
1328
+ end
1329
+ if r1
1330
+ r0 = r1
1331
+ else
1332
+ i4, s4 = index, []
1333
+ r5 = _nt_prefix
1334
+ s4 << r5
1335
+ if r5
1336
+ r7 = _nt_space
1337
+ if r7
1338
+ r6 = r7
1339
+ else
1340
+ r6 = instantiate_node(SyntaxNode,input, index...index)
1341
+ end
1342
+ s4 << r6
1343
+ if r6
1344
+ r8 = _nt_predicate_block
1345
+ s4 << r8
1346
+ end
1347
+ end
1348
+ if s4.last
1349
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
1350
+ r4.extend(Primary2)
1351
+ r4.extend(Primary3)
1352
+ else
1353
+ @index = i4
1354
+ r4 = nil
1355
+ end
1356
+ if r4
1357
+ r0 = r4
1358
+ else
1359
+ i9, s9 = index, []
1360
+ r10 = _nt_atomic
1361
+ s9 << r10
1362
+ if r10
1363
+ r11 = _nt_suffix
1364
+ s9 << r11
1365
+ if r11
1366
+ r12 = _nt_node_class_declarations
1367
+ s9 << r12
1368
+ end
1369
+ end
1370
+ if s9.last
1371
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
1372
+ r9.extend(Primary4)
1373
+ r9.extend(Primary5)
1374
+ else
1375
+ @index = i9
1376
+ r9 = nil
1377
+ end
1378
+ if r9
1379
+ r0 = r9
1380
+ else
1381
+ i13, s13 = index, []
1382
+ r14 = _nt_atomic
1383
+ s13 << r14
1384
+ if r14
1385
+ r15 = _nt_node_class_declarations
1386
+ s13 << r15
1387
+ end
1388
+ if s13.last
1389
+ r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
1390
+ r13.extend(Primary6)
1391
+ r13.extend(Primary7)
1392
+ else
1393
+ @index = i13
1394
+ r13 = nil
1395
+ end
1396
+ if r13
1397
+ r0 = r13
1398
+ else
1399
+ @index = i0
1400
+ r0 = nil
1401
+ end
1402
+ end
1403
+ end
1404
+ end
1405
+
1406
+ node_cache[:primary][start_index] = r0
1407
+
1408
+ r0
1409
+ end
1410
+
1411
+ module LabeledSequencePrimary0
1412
+ def label
1413
+ elements[0]
1414
+ end
1415
+
1416
+ def sequence_primary
1417
+ elements[1]
1418
+ end
1419
+ end
1420
+
1421
+ module LabeledSequencePrimary1
1422
+ def compile(lexical_address, builder)
1423
+ sequence_primary.compile(lexical_address, builder)
1424
+ end
1425
+
1426
+ def inline_modules
1427
+ sequence_primary.inline_modules
1428
+ end
1429
+
1430
+ def label_name
1431
+ if label.name
1432
+ label.name
1433
+ elsif sequence_primary.instance_of?(Nonterminal)
1434
+ sequence_primary.text_value
1435
+ else
1436
+ nil
1437
+ end
1438
+ end
1439
+ end
1440
+
1441
+ def _nt_labeled_sequence_primary
1442
+ start_index = index
1443
+ if node_cache[:labeled_sequence_primary].has_key?(index)
1444
+ cached = node_cache[:labeled_sequence_primary][index]
1445
+ if cached
1446
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1447
+ @index = cached.interval.end
1448
+ end
1449
+ return cached
1450
+ end
1451
+
1452
+ i0, s0 = index, []
1453
+ r1 = _nt_label
1454
+ s0 << r1
1455
+ if r1
1456
+ r2 = _nt_sequence_primary
1457
+ s0 << r2
1458
+ end
1459
+ if s0.last
1460
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1461
+ r0.extend(LabeledSequencePrimary0)
1462
+ r0.extend(LabeledSequencePrimary1)
1463
+ else
1464
+ @index = i0
1465
+ r0 = nil
1466
+ end
1467
+
1468
+ node_cache[:labeled_sequence_primary][start_index] = r0
1469
+
1470
+ r0
1471
+ end
1472
+
1473
+ module Label0
1474
+ def alpha_char
1475
+ elements[0]
1476
+ end
1477
+
1478
+ end
1479
+
1480
+ module Label1
1481
+ end
1482
+
1483
+ module Label2
1484
+ def name
1485
+ elements[0].text_value
1486
+ end
1487
+ end
1488
+
1489
+ module Label3
1490
+ def name
1491
+ nil
1492
+ end
1493
+ end
1494
+
1495
+ def _nt_label
1496
+ start_index = index
1497
+ if node_cache[:label].has_key?(index)
1498
+ cached = node_cache[:label][index]
1499
+ if cached
1500
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1501
+ @index = cached.interval.end
1502
+ end
1503
+ return cached
1504
+ end
1505
+
1506
+ i0 = index
1507
+ i1, s1 = index, []
1508
+ i2, s2 = index, []
1509
+ r3 = _nt_alpha_char
1510
+ s2 << r3
1511
+ if r3
1512
+ s4, i4 = [], index
1513
+ loop do
1514
+ r5 = _nt_alphanumeric_char
1515
+ if r5
1516
+ s4 << r5
1517
+ else
1518
+ break
1519
+ end
1520
+ end
1521
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
1522
+ s2 << r4
1523
+ end
1524
+ if s2.last
1525
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
1526
+ r2.extend(Label0)
1527
+ else
1528
+ @index = i2
1529
+ r2 = nil
1530
+ end
1531
+ s1 << r2
1532
+ if r2
1533
+ if has_terminal?(':', false, index)
1534
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
1535
+ @index += 1
1536
+ else
1537
+ terminal_parse_failure(':')
1538
+ r6 = nil
1539
+ end
1540
+ s1 << r6
1541
+ end
1542
+ if s1.last
1543
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1544
+ r1.extend(Label1)
1545
+ r1.extend(Label2)
1546
+ else
1547
+ @index = i1
1548
+ r1 = nil
1549
+ end
1550
+ if r1
1551
+ r0 = r1
1552
+ else
1553
+ if has_terminal?('', false, index)
1554
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 0))
1555
+ r7.extend(Label3)
1556
+ @index += 0
1557
+ else
1558
+ terminal_parse_failure('')
1559
+ r7 = nil
1560
+ end
1561
+ if r7
1562
+ r0 = r7
1563
+ else
1564
+ @index = i0
1565
+ r0 = nil
1566
+ end
1567
+ end
1568
+
1569
+ node_cache[:label][start_index] = r0
1570
+
1571
+ r0
1572
+ end
1573
+
1574
+ module SequencePrimary0
1575
+ def prefix
1576
+ elements[0]
1577
+ end
1578
+
1579
+ def atomic
1580
+ elements[1]
1581
+ end
1582
+ end
1583
+
1584
+ module SequencePrimary1
1585
+ def compile(lexical_address, builder)
1586
+ prefix.compile(lexical_address, builder, self)
1587
+ end
1588
+
1589
+ def prefixed_expression
1590
+ elements[1]
1591
+ end
1592
+
1593
+ def inline_modules
1594
+ atomic.inline_modules
1595
+ end
1596
+
1597
+ def inline_module_name
1598
+ nil
1599
+ end
1600
+ end
1601
+
1602
+ module SequencePrimary2
1603
+ def prefix
1604
+ elements[0]
1605
+ end
1606
+
1607
+ def predicate_block
1608
+ elements[2]
1609
+ end
1610
+ end
1611
+
1612
+ module SequencePrimary3
1613
+ def compile(address, builder, parent_expression=nil)
1614
+ prefix.compile(address, builder, self)
1615
+ end
1616
+ def prefixed_expression
1617
+ predicate_block
1618
+ end
1619
+ def inline_modules
1620
+ []
1621
+ end
1622
+ end
1623
+
1624
+ module SequencePrimary4
1625
+ def atomic
1626
+ elements[0]
1627
+ end
1628
+
1629
+ def suffix
1630
+ elements[1]
1631
+ end
1632
+ end
1633
+
1634
+ module SequencePrimary5
1635
+ def compile(lexical_address, builder)
1636
+ suffix.compile(lexical_address, builder, self)
1637
+ end
1638
+
1639
+ def node_class_name
1640
+ nil
1641
+ end
1642
+
1643
+ def inline_modules
1644
+ atomic.inline_modules
1645
+ end
1646
+
1647
+ def inline_module_name
1648
+ nil
1649
+ end
1650
+ end
1651
+
1652
+ def _nt_sequence_primary
1653
+ start_index = index
1654
+ if node_cache[:sequence_primary].has_key?(index)
1655
+ cached = node_cache[:sequence_primary][index]
1656
+ if cached
1657
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1658
+ @index = cached.interval.end
1659
+ end
1660
+ return cached
1661
+ end
1662
+
1663
+ i0 = index
1664
+ i1, s1 = index, []
1665
+ r2 = _nt_prefix
1666
+ s1 << r2
1667
+ if r2
1668
+ r3 = _nt_atomic
1669
+ s1 << r3
1670
+ end
1671
+ if s1.last
1672
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1673
+ r1.extend(SequencePrimary0)
1674
+ r1.extend(SequencePrimary1)
1675
+ else
1676
+ @index = i1
1677
+ r1 = nil
1678
+ end
1679
+ if r1
1680
+ r0 = r1
1681
+ else
1682
+ i4, s4 = index, []
1683
+ r5 = _nt_prefix
1684
+ s4 << r5
1685
+ if r5
1686
+ r7 = _nt_space
1687
+ if r7
1688
+ r6 = r7
1689
+ else
1690
+ r6 = instantiate_node(SyntaxNode,input, index...index)
1691
+ end
1692
+ s4 << r6
1693
+ if r6
1694
+ r8 = _nt_predicate_block
1695
+ s4 << r8
1696
+ end
1697
+ end
1698
+ if s4.last
1699
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
1700
+ r4.extend(SequencePrimary2)
1701
+ r4.extend(SequencePrimary3)
1702
+ else
1703
+ @index = i4
1704
+ r4 = nil
1705
+ end
1706
+ if r4
1707
+ r0 = r4
1708
+ else
1709
+ i9, s9 = index, []
1710
+ r10 = _nt_atomic
1711
+ s9 << r10
1712
+ if r10
1713
+ r11 = _nt_suffix
1714
+ s9 << r11
1715
+ end
1716
+ if s9.last
1717
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
1718
+ r9.extend(SequencePrimary4)
1719
+ r9.extend(SequencePrimary5)
1720
+ else
1721
+ @index = i9
1722
+ r9 = nil
1723
+ end
1724
+ if r9
1725
+ r0 = r9
1726
+ else
1727
+ r12 = _nt_atomic
1728
+ if r12
1729
+ r0 = r12
1730
+ else
1731
+ @index = i0
1732
+ r0 = nil
1733
+ end
1734
+ end
1735
+ end
1736
+ end
1737
+
1738
+ node_cache[:sequence_primary][start_index] = r0
1739
+
1740
+ r0
1741
+ end
1742
+
1743
+ def _nt_suffix
1744
+ start_index = index
1745
+ if node_cache[:suffix].has_key?(index)
1746
+ cached = node_cache[:suffix][index]
1747
+ if cached
1748
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1749
+ @index = cached.interval.end
1750
+ end
1751
+ return cached
1752
+ end
1753
+
1754
+ i0 = index
1755
+ r1 = _nt_repetition_suffix
1756
+ if r1
1757
+ r0 = r1
1758
+ else
1759
+ r2 = _nt_optional_suffix
1760
+ if r2
1761
+ r0 = r2
1762
+ else
1763
+ @index = i0
1764
+ r0 = nil
1765
+ end
1766
+ end
1767
+
1768
+ node_cache[:suffix][start_index] = r0
1769
+
1770
+ r0
1771
+ end
1772
+
1773
+ def _nt_optional_suffix
1774
+ start_index = index
1775
+ if node_cache[:optional_suffix].has_key?(index)
1776
+ cached = node_cache[:optional_suffix][index]
1777
+ if cached
1778
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1779
+ @index = cached.interval.end
1780
+ end
1781
+ return cached
1782
+ end
1783
+
1784
+ if has_terminal?('?', false, index)
1785
+ r0 = instantiate_node(Optional,input, index...(index + 1))
1786
+ @index += 1
1787
+ else
1788
+ terminal_parse_failure('?')
1789
+ r0 = nil
1790
+ end
1791
+
1792
+ node_cache[:optional_suffix][start_index] = r0
1793
+
1794
+ r0
1795
+ end
1796
+
1797
+ module NodeClassDeclarations0
1798
+ def node_class_expression
1799
+ elements[0]
1800
+ end
1801
+
1802
+ def trailing_inline_module
1803
+ elements[1]
1804
+ end
1805
+ end
1806
+
1807
+ module NodeClassDeclarations1
1808
+ def node_class_name
1809
+ node_class_expression.node_class_name
1810
+ end
1811
+
1812
+ def inline_modules
1813
+ trailing_inline_module.inline_modules
1814
+ end
1815
+
1816
+ def inline_module
1817
+ trailing_inline_module.inline_module
1818
+ end
1819
+
1820
+ def inline_module_name
1821
+ inline_module.module_name if inline_module
1822
+ end
1823
+ end
1824
+
1825
+ def _nt_node_class_declarations
1826
+ start_index = index
1827
+ if node_cache[:node_class_declarations].has_key?(index)
1828
+ cached = node_cache[:node_class_declarations][index]
1829
+ if cached
1830
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1831
+ @index = cached.interval.end
1832
+ end
1833
+ return cached
1834
+ end
1835
+
1836
+ i0, s0 = index, []
1837
+ r1 = _nt_node_class_expression
1838
+ s0 << r1
1839
+ if r1
1840
+ r2 = _nt_trailing_inline_module
1841
+ s0 << r2
1842
+ end
1843
+ if s0.last
1844
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1845
+ r0.extend(NodeClassDeclarations0)
1846
+ r0.extend(NodeClassDeclarations1)
1847
+ else
1848
+ @index = i0
1849
+ r0 = nil
1850
+ end
1851
+
1852
+ node_cache[:node_class_declarations][start_index] = r0
1853
+
1854
+ r0
1855
+ end
1856
+
1857
+ def _nt_repetition_suffix
1858
+ start_index = index
1859
+ if node_cache[:repetition_suffix].has_key?(index)
1860
+ cached = node_cache[:repetition_suffix][index]
1861
+ if cached
1862
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1863
+ @index = cached.interval.end
1864
+ end
1865
+ return cached
1866
+ end
1867
+
1868
+ i0 = index
1869
+ if has_terminal?('+', false, index)
1870
+ r1 = instantiate_node(OneOrMore,input, index...(index + 1))
1871
+ @index += 1
1872
+ else
1873
+ terminal_parse_failure('+')
1874
+ r1 = nil
1875
+ end
1876
+ if r1
1877
+ r0 = r1
1878
+ else
1879
+ if has_terminal?('*', false, index)
1880
+ r2 = instantiate_node(ZeroOrMore,input, index...(index + 1))
1881
+ @index += 1
1882
+ else
1883
+ terminal_parse_failure('*')
1884
+ r2 = nil
1885
+ end
1886
+ if r2
1887
+ r0 = r2
1888
+ else
1889
+ @index = i0
1890
+ r0 = nil
1891
+ end
1892
+ end
1893
+
1894
+ node_cache[:repetition_suffix][start_index] = r0
1895
+
1896
+ r0
1897
+ end
1898
+
1899
+ def _nt_prefix
1900
+ start_index = index
1901
+ if node_cache[:prefix].has_key?(index)
1902
+ cached = node_cache[:prefix][index]
1903
+ if cached
1904
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1905
+ @index = cached.interval.end
1906
+ end
1907
+ return cached
1908
+ end
1909
+
1910
+ i0 = index
1911
+ if has_terminal?('&', false, index)
1912
+ r1 = instantiate_node(AndPredicate,input, index...(index + 1))
1913
+ @index += 1
1914
+ else
1915
+ terminal_parse_failure('&')
1916
+ r1 = nil
1917
+ end
1918
+ if r1
1919
+ r0 = r1
1920
+ else
1921
+ if has_terminal?('!', false, index)
1922
+ r2 = instantiate_node(NotPredicate,input, index...(index + 1))
1923
+ @index += 1
1924
+ else
1925
+ terminal_parse_failure('!')
1926
+ r2 = nil
1927
+ end
1928
+ if r2
1929
+ r0 = r2
1930
+ else
1931
+ if has_terminal?('~', false, index)
1932
+ r3 = instantiate_node(TransientPrefix,input, index...(index + 1))
1933
+ @index += 1
1934
+ else
1935
+ terminal_parse_failure('~')
1936
+ r3 = nil
1937
+ end
1938
+ if r3
1939
+ r0 = r3
1940
+ else
1941
+ @index = i0
1942
+ r0 = nil
1943
+ end
1944
+ end
1945
+ end
1946
+
1947
+ node_cache[:prefix][start_index] = r0
1948
+
1949
+ r0
1950
+ end
1951
+
1952
+ def _nt_atomic
1953
+ start_index = index
1954
+ if node_cache[:atomic].has_key?(index)
1955
+ cached = node_cache[:atomic][index]
1956
+ if cached
1957
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
1958
+ @index = cached.interval.end
1959
+ end
1960
+ return cached
1961
+ end
1962
+
1963
+ i0 = index
1964
+ r1 = _nt_terminal
1965
+ if r1
1966
+ r0 = r1
1967
+ else
1968
+ r2 = _nt_nonterminal
1969
+ if r2
1970
+ r0 = r2
1971
+ else
1972
+ r3 = _nt_parenthesized_expression
1973
+ if r3
1974
+ r0 = r3
1975
+ else
1976
+ @index = i0
1977
+ r0 = nil
1978
+ end
1979
+ end
1980
+ end
1981
+
1982
+ node_cache[:atomic][start_index] = r0
1983
+
1984
+ r0
1985
+ end
1986
+
1987
+ module ParenthesizedExpression0
1988
+ def parsing_expression
1989
+ elements[2]
1990
+ end
1991
+
1992
+ end
1993
+
1994
+ module ParenthesizedExpression1
1995
+ def inline_modules
1996
+ parsing_expression.inline_modules
1997
+ end
1998
+ end
1999
+
2000
+ def _nt_parenthesized_expression
2001
+ start_index = index
2002
+ if node_cache[:parenthesized_expression].has_key?(index)
2003
+ cached = node_cache[:parenthesized_expression][index]
2004
+ if cached
2005
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2006
+ @index = cached.interval.end
2007
+ end
2008
+ return cached
2009
+ end
2010
+
2011
+ i0, s0 = index, []
2012
+ if has_terminal?('(', false, index)
2013
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2014
+ @index += 1
2015
+ else
2016
+ terminal_parse_failure('(')
2017
+ r1 = nil
2018
+ end
2019
+ s0 << r1
2020
+ if r1
2021
+ r3 = _nt_space
2022
+ if r3
2023
+ r2 = r3
2024
+ else
2025
+ r2 = instantiate_node(SyntaxNode,input, index...index)
2026
+ end
2027
+ s0 << r2
2028
+ if r2
2029
+ r4 = _nt_parsing_expression
2030
+ s0 << r4
2031
+ if r4
2032
+ r6 = _nt_space
2033
+ if r6
2034
+ r5 = r6
2035
+ else
2036
+ r5 = instantiate_node(SyntaxNode,input, index...index)
2037
+ end
2038
+ s0 << r5
2039
+ if r5
2040
+ if has_terminal?(')', false, index)
2041
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
2042
+ @index += 1
2043
+ else
2044
+ terminal_parse_failure(')')
2045
+ r7 = nil
2046
+ end
2047
+ s0 << r7
2048
+ end
2049
+ end
2050
+ end
2051
+ end
2052
+ if s0.last
2053
+ r0 = instantiate_node(ParenthesizedExpression,input, i0...index, s0)
2054
+ r0.extend(ParenthesizedExpression0)
2055
+ r0.extend(ParenthesizedExpression1)
2056
+ else
2057
+ @index = i0
2058
+ r0 = nil
2059
+ end
2060
+
2061
+ node_cache[:parenthesized_expression][start_index] = r0
2062
+
2063
+ r0
2064
+ end
2065
+
2066
+ module Nonterminal0
2067
+ def alpha_char
2068
+ elements[0]
2069
+ end
2070
+
2071
+ end
2072
+
2073
+ module Nonterminal1
2074
+ end
2075
+
2076
+ def _nt_nonterminal
2077
+ start_index = index
2078
+ if node_cache[:nonterminal].has_key?(index)
2079
+ cached = node_cache[:nonterminal][index]
2080
+ if cached
2081
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2082
+ @index = cached.interval.end
2083
+ end
2084
+ return cached
2085
+ end
2086
+
2087
+ i0, s0 = index, []
2088
+ i1 = index
2089
+ r2 = _nt_keyword_inside_grammar
2090
+ if r2
2091
+ r1 = nil
2092
+ else
2093
+ @index = i1
2094
+ r1 = instantiate_node(SyntaxNode,input, index...index)
2095
+ end
2096
+ s0 << r1
2097
+ if r1
2098
+ i3, s3 = index, []
2099
+ r4 = _nt_alpha_char
2100
+ s3 << r4
2101
+ if r4
2102
+ s5, i5 = [], index
2103
+ loop do
2104
+ r6 = _nt_alphanumeric_char
2105
+ if r6
2106
+ s5 << r6
2107
+ else
2108
+ break
2109
+ end
2110
+ end
2111
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
2112
+ s3 << r5
2113
+ end
2114
+ if s3.last
2115
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2116
+ r3.extend(Nonterminal0)
2117
+ else
2118
+ @index = i3
2119
+ r3 = nil
2120
+ end
2121
+ s0 << r3
2122
+ end
2123
+ if s0.last
2124
+ r0 = instantiate_node(Nonterminal,input, i0...index, s0)
2125
+ r0.extend(Nonterminal1)
2126
+ else
2127
+ @index = i0
2128
+ r0 = nil
2129
+ end
2130
+
2131
+ node_cache[:nonterminal][start_index] = r0
2132
+
2133
+ r0
2134
+ end
2135
+
2136
+ def _nt_terminal
2137
+ start_index = index
2138
+ if node_cache[:terminal].has_key?(index)
2139
+ cached = node_cache[:terminal][index]
2140
+ if cached
2141
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2142
+ @index = cached.interval.end
2143
+ end
2144
+ return cached
2145
+ end
2146
+
2147
+ i0 = index
2148
+ r1 = _nt_quoted_string
2149
+ if r1
2150
+ r0 = r1
2151
+ else
2152
+ r2 = _nt_character_class
2153
+ if r2
2154
+ r0 = r2
2155
+ else
2156
+ r3 = _nt_anything_symbol
2157
+ if r3
2158
+ r0 = r3
2159
+ else
2160
+ @index = i0
2161
+ r0 = nil
2162
+ end
2163
+ end
2164
+ end
2165
+
2166
+ node_cache[:terminal][start_index] = r0
2167
+
2168
+ r0
2169
+ end
2170
+
2171
+ module QuotedString0
2172
+ def string
2173
+ super.text_value
2174
+ end
2175
+ end
2176
+
2177
+ def _nt_quoted_string
2178
+ start_index = index
2179
+ if node_cache[:quoted_string].has_key?(index)
2180
+ cached = node_cache[:quoted_string][index]
2181
+ if cached
2182
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2183
+ @index = cached.interval.end
2184
+ end
2185
+ return cached
2186
+ end
2187
+
2188
+ i0 = index
2189
+ r1 = _nt_single_quoted_string
2190
+ if r1
2191
+ r0 = r1
2192
+ r0.extend(QuotedString0)
2193
+ else
2194
+ r2 = _nt_double_quoted_string
2195
+ if r2
2196
+ r0 = r2
2197
+ r0.extend(QuotedString0)
2198
+ else
2199
+ @index = i0
2200
+ r0 = nil
2201
+ end
2202
+ end
2203
+
2204
+ node_cache[:quoted_string][start_index] = r0
2205
+
2206
+ r0
2207
+ end
2208
+
2209
+ module DoubleQuotedString0
2210
+ end
2211
+
2212
+ module DoubleQuotedString1
2213
+ def string
2214
+ elements[1]
2215
+ end
2216
+
2217
+ end
2218
+
2219
+ def _nt_double_quoted_string
2220
+ start_index = index
2221
+ if node_cache[:double_quoted_string].has_key?(index)
2222
+ cached = node_cache[:double_quoted_string][index]
2223
+ if cached
2224
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2225
+ @index = cached.interval.end
2226
+ end
2227
+ return cached
2228
+ end
2229
+
2230
+ i0, s0 = index, []
2231
+ if has_terminal?('"', false, index)
2232
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2233
+ @index += 1
2234
+ else
2235
+ terminal_parse_failure('"')
2236
+ r1 = nil
2237
+ end
2238
+ s0 << r1
2239
+ if r1
2240
+ s2, i2 = [], index
2241
+ loop do
2242
+ i3, s3 = index, []
2243
+ i4 = index
2244
+ if has_terminal?('"', false, index)
2245
+ r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
2246
+ @index += 1
2247
+ else
2248
+ terminal_parse_failure('"')
2249
+ r5 = nil
2250
+ end
2251
+ if r5
2252
+ r4 = nil
2253
+ else
2254
+ @index = i4
2255
+ r4 = instantiate_node(SyntaxNode,input, index...index)
2256
+ end
2257
+ s3 << r4
2258
+ if r4
2259
+ i6 = index
2260
+ if has_terminal?("\\\\", false, index)
2261
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 2))
2262
+ @index += 2
2263
+ else
2264
+ terminal_parse_failure("\\\\")
2265
+ r7 = nil
2266
+ end
2267
+ if r7
2268
+ r6 = r7
2269
+ else
2270
+ if has_terminal?('\"', false, index)
2271
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 2))
2272
+ @index += 2
2273
+ else
2274
+ terminal_parse_failure('\"')
2275
+ r8 = nil
2276
+ end
2277
+ if r8
2278
+ r6 = r8
2279
+ else
2280
+ if index < input_length
2281
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2282
+ @index += 1
2283
+ else
2284
+ terminal_parse_failure("any character")
2285
+ r9 = nil
2286
+ end
2287
+ if r9
2288
+ r6 = r9
2289
+ else
2290
+ @index = i6
2291
+ r6 = nil
2292
+ end
2293
+ end
2294
+ end
2295
+ s3 << r6
2296
+ end
2297
+ if s3.last
2298
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2299
+ r3.extend(DoubleQuotedString0)
2300
+ else
2301
+ @index = i3
2302
+ r3 = nil
2303
+ end
2304
+ if r3
2305
+ s2 << r3
2306
+ else
2307
+ break
2308
+ end
2309
+ end
2310
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2311
+ s0 << r2
2312
+ if r2
2313
+ if has_terminal?('"', false, index)
2314
+ r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
2315
+ @index += 1
2316
+ else
2317
+ terminal_parse_failure('"')
2318
+ r10 = nil
2319
+ end
2320
+ s0 << r10
2321
+ end
2322
+ end
2323
+ if s0.last
2324
+ r0 = instantiate_node(Terminal,input, i0...index, s0)
2325
+ r0.extend(DoubleQuotedString1)
2326
+ else
2327
+ @index = i0
2328
+ r0 = nil
2329
+ end
2330
+
2331
+ node_cache[:double_quoted_string][start_index] = r0
2332
+
2333
+ r0
2334
+ end
2335
+
2336
+ module SingleQuotedString0
2337
+ end
2338
+
2339
+ module SingleQuotedString1
2340
+ def string
2341
+ elements[1]
2342
+ end
2343
+
2344
+ end
2345
+
2346
+ def _nt_single_quoted_string
2347
+ start_index = index
2348
+ if node_cache[:single_quoted_string].has_key?(index)
2349
+ cached = node_cache[:single_quoted_string][index]
2350
+ if cached
2351
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2352
+ @index = cached.interval.end
2353
+ end
2354
+ return cached
2355
+ end
2356
+
2357
+ i0, s0 = index, []
2358
+ if has_terminal?("'", false, index)
2359
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2360
+ @index += 1
2361
+ else
2362
+ terminal_parse_failure("'")
2363
+ r1 = nil
2364
+ end
2365
+ s0 << r1
2366
+ if r1
2367
+ s2, i2 = [], index
2368
+ loop do
2369
+ i3, s3 = index, []
2370
+ i4 = index
2371
+ if has_terminal?("'", false, index)
2372
+ r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
2373
+ @index += 1
2374
+ else
2375
+ terminal_parse_failure("'")
2376
+ r5 = nil
2377
+ end
2378
+ if r5
2379
+ r4 = nil
2380
+ else
2381
+ @index = i4
2382
+ r4 = instantiate_node(SyntaxNode,input, index...index)
2383
+ end
2384
+ s3 << r4
2385
+ if r4
2386
+ i6 = index
2387
+ if has_terminal?("\\\\", false, index)
2388
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 2))
2389
+ @index += 2
2390
+ else
2391
+ terminal_parse_failure("\\\\")
2392
+ r7 = nil
2393
+ end
2394
+ if r7
2395
+ r6 = r7
2396
+ else
2397
+ if has_terminal?("\\'", false, index)
2398
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 2))
2399
+ @index += 2
2400
+ else
2401
+ terminal_parse_failure("\\'")
2402
+ r8 = nil
2403
+ end
2404
+ if r8
2405
+ r6 = r8
2406
+ else
2407
+ if index < input_length
2408
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2409
+ @index += 1
2410
+ else
2411
+ terminal_parse_failure("any character")
2412
+ r9 = nil
2413
+ end
2414
+ if r9
2415
+ r6 = r9
2416
+ else
2417
+ @index = i6
2418
+ r6 = nil
2419
+ end
2420
+ end
2421
+ end
2422
+ s3 << r6
2423
+ end
2424
+ if s3.last
2425
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2426
+ r3.extend(SingleQuotedString0)
2427
+ else
2428
+ @index = i3
2429
+ r3 = nil
2430
+ end
2431
+ if r3
2432
+ s2 << r3
2433
+ else
2434
+ break
2435
+ end
2436
+ end
2437
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2438
+ s0 << r2
2439
+ if r2
2440
+ if has_terminal?("'", false, index)
2441
+ r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
2442
+ @index += 1
2443
+ else
2444
+ terminal_parse_failure("'")
2445
+ r10 = nil
2446
+ end
2447
+ s0 << r10
2448
+ end
2449
+ end
2450
+ if s0.last
2451
+ r0 = instantiate_node(Terminal,input, i0...index, s0)
2452
+ r0.extend(SingleQuotedString1)
2453
+ else
2454
+ @index = i0
2455
+ r0 = nil
2456
+ end
2457
+
2458
+ node_cache[:single_quoted_string][start_index] = r0
2459
+
2460
+ r0
2461
+ end
2462
+
2463
+ module CharacterClass0
2464
+ end
2465
+
2466
+ module CharacterClass1
2467
+ end
2468
+
2469
+ module CharacterClass2
2470
+ end
2471
+
2472
+ module CharacterClass3
2473
+ def characters
2474
+ elements[1]
2475
+ end
2476
+
2477
+ end
2478
+
2479
+ module CharacterClass4
2480
+ def characters
2481
+ super.text_value
2482
+ end
2483
+ end
2484
+
2485
+ def _nt_character_class
2486
+ start_index = index
2487
+ if node_cache[:character_class].has_key?(index)
2488
+ cached = node_cache[:character_class][index]
2489
+ if cached
2490
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2491
+ @index = cached.interval.end
2492
+ end
2493
+ return cached
2494
+ end
2495
+
2496
+ i0, s0 = index, []
2497
+ if has_terminal?('[', false, index)
2498
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2499
+ @index += 1
2500
+ else
2501
+ terminal_parse_failure('[')
2502
+ r1 = nil
2503
+ end
2504
+ s0 << r1
2505
+ if r1
2506
+ s2, i2 = [], index
2507
+ loop do
2508
+ i3, s3 = index, []
2509
+ i4 = index
2510
+ if has_terminal?(']', false, index)
2511
+ r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
2512
+ @index += 1
2513
+ else
2514
+ terminal_parse_failure(']')
2515
+ r5 = nil
2516
+ end
2517
+ if r5
2518
+ r4 = nil
2519
+ else
2520
+ @index = i4
2521
+ r4 = instantiate_node(SyntaxNode,input, index...index)
2522
+ end
2523
+ s3 << r4
2524
+ if r4
2525
+ i6 = index
2526
+ i7, s7 = index, []
2527
+ if has_terminal?('\\', false, index)
2528
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
2529
+ @index += 1
2530
+ else
2531
+ terminal_parse_failure('\\')
2532
+ r8 = nil
2533
+ end
2534
+ s7 << r8
2535
+ if r8
2536
+ if index < input_length
2537
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2538
+ @index += 1
2539
+ else
2540
+ terminal_parse_failure("any character")
2541
+ r9 = nil
2542
+ end
2543
+ s7 << r9
2544
+ end
2545
+ if s7.last
2546
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
2547
+ r7.extend(CharacterClass0)
2548
+ else
2549
+ @index = i7
2550
+ r7 = nil
2551
+ end
2552
+ if r7
2553
+ r6 = r7
2554
+ else
2555
+ i10, s10 = index, []
2556
+ i11 = index
2557
+ if has_terminal?('\\', false, index)
2558
+ r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
2559
+ @index += 1
2560
+ else
2561
+ terminal_parse_failure('\\')
2562
+ r12 = nil
2563
+ end
2564
+ if r12
2565
+ r11 = nil
2566
+ else
2567
+ @index = i11
2568
+ r11 = instantiate_node(SyntaxNode,input, index...index)
2569
+ end
2570
+ s10 << r11
2571
+ if r11
2572
+ if index < input_length
2573
+ r13 = instantiate_node(SyntaxNode,input, index...(index + 1))
2574
+ @index += 1
2575
+ else
2576
+ terminal_parse_failure("any character")
2577
+ r13 = nil
2578
+ end
2579
+ s10 << r13
2580
+ end
2581
+ if s10.last
2582
+ r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
2583
+ r10.extend(CharacterClass1)
2584
+ else
2585
+ @index = i10
2586
+ r10 = nil
2587
+ end
2588
+ if r10
2589
+ r6 = r10
2590
+ else
2591
+ @index = i6
2592
+ r6 = nil
2593
+ end
2594
+ end
2595
+ s3 << r6
2596
+ end
2597
+ if s3.last
2598
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
2599
+ r3.extend(CharacterClass2)
2600
+ else
2601
+ @index = i3
2602
+ r3 = nil
2603
+ end
2604
+ if r3
2605
+ s2 << r3
2606
+ else
2607
+ break
2608
+ end
2609
+ end
2610
+ if s2.empty?
2611
+ @index = i2
2612
+ r2 = nil
2613
+ else
2614
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2615
+ end
2616
+ s0 << r2
2617
+ if r2
2618
+ if has_terminal?(']', false, index)
2619
+ r14 = instantiate_node(SyntaxNode,input, index...(index + 1))
2620
+ @index += 1
2621
+ else
2622
+ terminal_parse_failure(']')
2623
+ r14 = nil
2624
+ end
2625
+ s0 << r14
2626
+ end
2627
+ end
2628
+ if s0.last
2629
+ r0 = instantiate_node(CharacterClass,input, i0...index, s0)
2630
+ r0.extend(CharacterClass3)
2631
+ r0.extend(CharacterClass4)
2632
+ else
2633
+ @index = i0
2634
+ r0 = nil
2635
+ end
2636
+
2637
+ node_cache[:character_class][start_index] = r0
2638
+
2639
+ r0
2640
+ end
2641
+
2642
+ def _nt_anything_symbol
2643
+ start_index = index
2644
+ if node_cache[:anything_symbol].has_key?(index)
2645
+ cached = node_cache[:anything_symbol][index]
2646
+ if cached
2647
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2648
+ @index = cached.interval.end
2649
+ end
2650
+ return cached
2651
+ end
2652
+
2653
+ if has_terminal?('.', false, index)
2654
+ r0 = instantiate_node(AnythingSymbol,input, index...(index + 1))
2655
+ @index += 1
2656
+ else
2657
+ terminal_parse_failure('.')
2658
+ r0 = nil
2659
+ end
2660
+
2661
+ node_cache[:anything_symbol][start_index] = r0
2662
+
2663
+ r0
2664
+ end
2665
+
2666
+ module NodeClassExpression0
2667
+ end
2668
+
2669
+ module NodeClassExpression1
2670
+ def space
2671
+ elements[0]
2672
+ end
2673
+
2674
+ end
2675
+
2676
+ module NodeClassExpression2
2677
+ def node_class_name
2678
+ elements[2].text_value
2679
+ end
2680
+ end
2681
+
2682
+ module NodeClassExpression3
2683
+ def node_class_name
2684
+ nil
2685
+ end
2686
+ end
2687
+
2688
+ def _nt_node_class_expression
2689
+ start_index = index
2690
+ if node_cache[:node_class_expression].has_key?(index)
2691
+ cached = node_cache[:node_class_expression][index]
2692
+ if cached
2693
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2694
+ @index = cached.interval.end
2695
+ end
2696
+ return cached
2697
+ end
2698
+
2699
+ i0 = index
2700
+ i1, s1 = index, []
2701
+ r2 = _nt_space
2702
+ s1 << r2
2703
+ if r2
2704
+ if has_terminal?('<', false, index)
2705
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
2706
+ @index += 1
2707
+ else
2708
+ terminal_parse_failure('<')
2709
+ r3 = nil
2710
+ end
2711
+ s1 << r3
2712
+ if r3
2713
+ s4, i4 = [], index
2714
+ loop do
2715
+ i5, s5 = index, []
2716
+ i6 = index
2717
+ if has_terminal?('>', false, index)
2718
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
2719
+ @index += 1
2720
+ else
2721
+ terminal_parse_failure('>')
2722
+ r7 = nil
2723
+ end
2724
+ if r7
2725
+ r6 = nil
2726
+ else
2727
+ @index = i6
2728
+ r6 = instantiate_node(SyntaxNode,input, index...index)
2729
+ end
2730
+ s5 << r6
2731
+ if r6
2732
+ if index < input_length
2733
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
2734
+ @index += 1
2735
+ else
2736
+ terminal_parse_failure("any character")
2737
+ r8 = nil
2738
+ end
2739
+ s5 << r8
2740
+ end
2741
+ if s5.last
2742
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
2743
+ r5.extend(NodeClassExpression0)
2744
+ else
2745
+ @index = i5
2746
+ r5 = nil
2747
+ end
2748
+ if r5
2749
+ s4 << r5
2750
+ else
2751
+ break
2752
+ end
2753
+ end
2754
+ if s4.empty?
2755
+ @index = i4
2756
+ r4 = nil
2757
+ else
2758
+ r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
2759
+ end
2760
+ s1 << r4
2761
+ if r4
2762
+ if has_terminal?('>', false, index)
2763
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
2764
+ @index += 1
2765
+ else
2766
+ terminal_parse_failure('>')
2767
+ r9 = nil
2768
+ end
2769
+ s1 << r9
2770
+ end
2771
+ end
2772
+ end
2773
+ if s1.last
2774
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2775
+ r1.extend(NodeClassExpression1)
2776
+ r1.extend(NodeClassExpression2)
2777
+ else
2778
+ @index = i1
2779
+ r1 = nil
2780
+ end
2781
+ if r1
2782
+ r0 = r1
2783
+ else
2784
+ if has_terminal?('', false, index)
2785
+ r10 = instantiate_node(SyntaxNode,input, index...(index + 0))
2786
+ r10.extend(NodeClassExpression3)
2787
+ @index += 0
2788
+ else
2789
+ terminal_parse_failure('')
2790
+ r10 = nil
2791
+ end
2792
+ if r10
2793
+ r0 = r10
2794
+ else
2795
+ @index = i0
2796
+ r0 = nil
2797
+ end
2798
+ end
2799
+
2800
+ node_cache[:node_class_expression][start_index] = r0
2801
+
2802
+ r0
2803
+ end
2804
+
2805
+ module TrailingInlineModule0
2806
+ def space
2807
+ elements[0]
2808
+ end
2809
+
2810
+ def inline_module
2811
+ elements[1]
2812
+ end
2813
+ end
2814
+
2815
+ module TrailingInlineModule1
2816
+ def inline_modules
2817
+ [inline_module]
2818
+ end
2819
+
2820
+ def inline_module_name
2821
+ inline_module.module_name
2822
+ end
2823
+ end
2824
+
2825
+ module TrailingInlineModule2
2826
+ def inline_modules
2827
+ []
2828
+ end
2829
+
2830
+ def inline_module
2831
+ nil
2832
+ end
2833
+
2834
+ def inline_module_name
2835
+ nil
2836
+ end
2837
+ end
2838
+
2839
+ def _nt_trailing_inline_module
2840
+ start_index = index
2841
+ if node_cache[:trailing_inline_module].has_key?(index)
2842
+ cached = node_cache[:trailing_inline_module][index]
2843
+ if cached
2844
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2845
+ @index = cached.interval.end
2846
+ end
2847
+ return cached
2848
+ end
2849
+
2850
+ i0 = index
2851
+ i1, s1 = index, []
2852
+ r2 = _nt_space
2853
+ s1 << r2
2854
+ if r2
2855
+ r3 = _nt_inline_module
2856
+ s1 << r3
2857
+ end
2858
+ if s1.last
2859
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2860
+ r1.extend(TrailingInlineModule0)
2861
+ r1.extend(TrailingInlineModule1)
2862
+ else
2863
+ @index = i1
2864
+ r1 = nil
2865
+ end
2866
+ if r1
2867
+ r0 = r1
2868
+ else
2869
+ if has_terminal?('', false, index)
2870
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 0))
2871
+ r4.extend(TrailingInlineModule2)
2872
+ @index += 0
2873
+ else
2874
+ terminal_parse_failure('')
2875
+ r4 = nil
2876
+ end
2877
+ if r4
2878
+ r0 = r4
2879
+ else
2880
+ @index = i0
2881
+ r0 = nil
2882
+ end
2883
+ end
2884
+
2885
+ node_cache[:trailing_inline_module][start_index] = r0
2886
+
2887
+ r0
2888
+ end
2889
+
2890
+ module PredicateBlock0
2891
+ def inline_module
2892
+ elements[1]
2893
+ end
2894
+ end
2895
+
2896
+ def _nt_predicate_block
2897
+ start_index = index
2898
+ if node_cache[:predicate_block].has_key?(index)
2899
+ cached = node_cache[:predicate_block][index]
2900
+ if cached
2901
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2902
+ @index = cached.interval.end
2903
+ end
2904
+ return cached
2905
+ end
2906
+
2907
+ i0, s0 = index, []
2908
+ if has_terminal?('', false, index)
2909
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 0))
2910
+ @index += 0
2911
+ else
2912
+ terminal_parse_failure('')
2913
+ r1 = nil
2914
+ end
2915
+ s0 << r1
2916
+ if r1
2917
+ r2 = _nt_inline_module
2918
+ s0 << r2
2919
+ end
2920
+ if s0.last
2921
+ r0 = instantiate_node(PredicateBlock,input, i0...index, s0)
2922
+ r0.extend(PredicateBlock0)
2923
+ else
2924
+ @index = i0
2925
+ r0 = nil
2926
+ end
2927
+
2928
+ node_cache[:predicate_block][start_index] = r0
2929
+
2930
+ r0
2931
+ end
2932
+
2933
+ module InlineModule0
2934
+ end
2935
+
2936
+ module InlineModule1
2937
+ end
2938
+
2939
+ def _nt_inline_module
2940
+ start_index = index
2941
+ if node_cache[:inline_module].has_key?(index)
2942
+ cached = node_cache[:inline_module][index]
2943
+ if cached
2944
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
2945
+ @index = cached.interval.end
2946
+ end
2947
+ return cached
2948
+ end
2949
+
2950
+ i0, s0 = index, []
2951
+ if has_terminal?('{', false, index)
2952
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
2953
+ @index += 1
2954
+ else
2955
+ terminal_parse_failure('{')
2956
+ r1 = nil
2957
+ end
2958
+ s0 << r1
2959
+ if r1
2960
+ s2, i2 = [], index
2961
+ loop do
2962
+ i3 = index
2963
+ r4 = _nt_inline_module
2964
+ if r4
2965
+ r3 = r4
2966
+ else
2967
+ i5, s5 = index, []
2968
+ i6 = index
2969
+ if has_terminal?('\G[{}]', true, index)
2970
+ r7 = true
2971
+ @index += 1
2972
+ else
2973
+ r7 = nil
2974
+ end
2975
+ if r7
2976
+ r6 = nil
2977
+ else
2978
+ @index = i6
2979
+ r6 = instantiate_node(SyntaxNode,input, index...index)
2980
+ end
2981
+ s5 << r6
2982
+ if r6
2983
+ if index < input_length
2984
+ r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
2985
+ @index += 1
2986
+ else
2987
+ terminal_parse_failure("any character")
2988
+ r8 = nil
2989
+ end
2990
+ s5 << r8
2991
+ end
2992
+ if s5.last
2993
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
2994
+ r5.extend(InlineModule0)
2995
+ else
2996
+ @index = i5
2997
+ r5 = nil
2998
+ end
2999
+ if r5
3000
+ r3 = r5
3001
+ else
3002
+ @index = i3
3003
+ r3 = nil
3004
+ end
3005
+ end
3006
+ if r3
3007
+ s2 << r3
3008
+ else
3009
+ break
3010
+ end
3011
+ end
3012
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
3013
+ s0 << r2
3014
+ if r2
3015
+ if has_terminal?('}', false, index)
3016
+ r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
3017
+ @index += 1
3018
+ else
3019
+ terminal_parse_failure('}')
3020
+ r9 = nil
3021
+ end
3022
+ s0 << r9
3023
+ end
3024
+ end
3025
+ if s0.last
3026
+ r0 = instantiate_node(InlineModule,input, i0...index, s0)
3027
+ r0.extend(InlineModule1)
3028
+ else
3029
+ @index = i0
3030
+ r0 = nil
3031
+ end
3032
+
3033
+ node_cache[:inline_module][start_index] = r0
3034
+
3035
+ r0
3036
+ end
3037
+
3038
+ module KeywordInsideGrammar0
3039
+ end
3040
+
3041
+ def _nt_keyword_inside_grammar
3042
+ start_index = index
3043
+ if node_cache[:keyword_inside_grammar].has_key?(index)
3044
+ cached = node_cache[:keyword_inside_grammar][index]
3045
+ if cached
3046
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3047
+ @index = cached.interval.end
3048
+ end
3049
+ return cached
3050
+ end
3051
+
3052
+ i0, s0 = index, []
3053
+ i1 = index
3054
+ if has_terminal?('rule', false, index)
3055
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 4))
3056
+ @index += 4
3057
+ else
3058
+ terminal_parse_failure('rule')
3059
+ r2 = nil
3060
+ end
3061
+ if r2
3062
+ r1 = r2
3063
+ else
3064
+ if has_terminal?('end', false, index)
3065
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 3))
3066
+ @index += 3
3067
+ else
3068
+ terminal_parse_failure('end')
3069
+ r3 = nil
3070
+ end
3071
+ if r3
3072
+ r1 = r3
3073
+ else
3074
+ @index = i1
3075
+ r1 = nil
3076
+ end
3077
+ end
3078
+ s0 << r1
3079
+ if r1
3080
+ i4 = index
3081
+ r5 = _nt_non_space_char
3082
+ if r5
3083
+ r4 = nil
3084
+ else
3085
+ @index = i4
3086
+ r4 = instantiate_node(SyntaxNode,input, index...index)
3087
+ end
3088
+ s0 << r4
3089
+ end
3090
+ if s0.last
3091
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
3092
+ r0.extend(KeywordInsideGrammar0)
3093
+ else
3094
+ @index = i0
3095
+ r0 = nil
3096
+ end
3097
+
3098
+ node_cache[:keyword_inside_grammar][start_index] = r0
3099
+
3100
+ r0
3101
+ end
3102
+
3103
+ module NonSpaceChar0
3104
+ end
3105
+
3106
+ def _nt_non_space_char
3107
+ start_index = index
3108
+ if node_cache[:non_space_char].has_key?(index)
3109
+ cached = node_cache[:non_space_char][index]
3110
+ if cached
3111
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3112
+ @index = cached.interval.end
3113
+ end
3114
+ return cached
3115
+ end
3116
+
3117
+ i0, s0 = index, []
3118
+ i1 = index
3119
+ r2 = _nt_space
3120
+ if r2
3121
+ r1 = nil
3122
+ else
3123
+ @index = i1
3124
+ r1 = instantiate_node(SyntaxNode,input, index...index)
3125
+ end
3126
+ s0 << r1
3127
+ if r1
3128
+ if index < input_length
3129
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
3130
+ @index += 1
3131
+ else
3132
+ terminal_parse_failure("any character")
3133
+ r3 = nil
3134
+ end
3135
+ s0 << r3
3136
+ end
3137
+ if s0.last
3138
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
3139
+ r0.extend(NonSpaceChar0)
3140
+ else
3141
+ @index = i0
3142
+ r0 = nil
3143
+ end
3144
+
3145
+ node_cache[:non_space_char][start_index] = r0
3146
+
3147
+ r0
3148
+ end
3149
+
3150
+ def _nt_alpha_char
3151
+ start_index = index
3152
+ if node_cache[:alpha_char].has_key?(index)
3153
+ cached = node_cache[:alpha_char][index]
3154
+ if cached
3155
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3156
+ @index = cached.interval.end
3157
+ end
3158
+ return cached
3159
+ end
3160
+
3161
+ if has_terminal?('\G[A-Za-z_]', true, index)
3162
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
3163
+ @index += 1
3164
+ else
3165
+ r0 = nil
3166
+ end
3167
+
3168
+ node_cache[:alpha_char][start_index] = r0
3169
+
3170
+ r0
3171
+ end
3172
+
3173
+ def _nt_alphanumeric_char
3174
+ start_index = index
3175
+ if node_cache[:alphanumeric_char].has_key?(index)
3176
+ cached = node_cache[:alphanumeric_char][index]
3177
+ if cached
3178
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3179
+ @index = cached.interval.end
3180
+ end
3181
+ return cached
3182
+ end
3183
+
3184
+ i0 = index
3185
+ r1 = _nt_alpha_char
3186
+ if r1
3187
+ r0 = r1
3188
+ else
3189
+ if has_terminal?('\G[0-9]', true, index)
3190
+ r2 = true
3191
+ @index += 1
3192
+ else
3193
+ r2 = nil
3194
+ end
3195
+ if r2
3196
+ r0 = r2
3197
+ else
3198
+ @index = i0
3199
+ r0 = nil
3200
+ end
3201
+ end
3202
+
3203
+ node_cache[:alphanumeric_char][start_index] = r0
3204
+
3205
+ r0
3206
+ end
3207
+
3208
+ def _nt_space
3209
+ start_index = index
3210
+ if node_cache[:space].has_key?(index)
3211
+ cached = node_cache[:space][index]
3212
+ if cached
3213
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3214
+ @index = cached.interval.end
3215
+ end
3216
+ return cached
3217
+ end
3218
+
3219
+ s0, i0 = [], index
3220
+ loop do
3221
+ i1 = index
3222
+ r2 = _nt_white
3223
+ if r2
3224
+ r1 = r2
3225
+ else
3226
+ r3 = _nt_comment_to_eol
3227
+ if r3
3228
+ r1 = r3
3229
+ else
3230
+ @index = i1
3231
+ r1 = nil
3232
+ end
3233
+ end
3234
+ if r1
3235
+ s0 << r1
3236
+ else
3237
+ break
3238
+ end
3239
+ end
3240
+ if s0.empty?
3241
+ @index = i0
3242
+ r0 = nil
3243
+ else
3244
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
3245
+ end
3246
+
3247
+ node_cache[:space][start_index] = r0
3248
+
3249
+ r0
3250
+ end
3251
+
3252
+ module CommentToEol0
3253
+ end
3254
+
3255
+ module CommentToEol1
3256
+ end
3257
+
3258
+ def _nt_comment_to_eol
3259
+ start_index = index
3260
+ if node_cache[:comment_to_eol].has_key?(index)
3261
+ cached = node_cache[:comment_to_eol][index]
3262
+ if cached
3263
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3264
+ @index = cached.interval.end
3265
+ end
3266
+ return cached
3267
+ end
3268
+
3269
+ i0, s0 = index, []
3270
+ if has_terminal?('#', false, index)
3271
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
3272
+ @index += 1
3273
+ else
3274
+ terminal_parse_failure('#')
3275
+ r1 = nil
3276
+ end
3277
+ s0 << r1
3278
+ if r1
3279
+ s2, i2 = [], index
3280
+ loop do
3281
+ i3, s3 = index, []
3282
+ i4 = index
3283
+ if has_terminal?("\n", false, index)
3284
+ r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
3285
+ @index += 1
3286
+ else
3287
+ terminal_parse_failure("\n")
3288
+ r5 = nil
3289
+ end
3290
+ if r5
3291
+ r4 = nil
3292
+ else
3293
+ @index = i4
3294
+ r4 = instantiate_node(SyntaxNode,input, index...index)
3295
+ end
3296
+ s3 << r4
3297
+ if r4
3298
+ if index < input_length
3299
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
3300
+ @index += 1
3301
+ else
3302
+ terminal_parse_failure("any character")
3303
+ r6 = nil
3304
+ end
3305
+ s3 << r6
3306
+ end
3307
+ if s3.last
3308
+ r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
3309
+ r3.extend(CommentToEol0)
3310
+ else
3311
+ @index = i3
3312
+ r3 = nil
3313
+ end
3314
+ if r3
3315
+ s2 << r3
3316
+ else
3317
+ break
3318
+ end
3319
+ end
3320
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
3321
+ s0 << r2
3322
+ end
3323
+ if s0.last
3324
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
3325
+ r0.extend(CommentToEol1)
3326
+ else
3327
+ @index = i0
3328
+ r0 = nil
3329
+ end
3330
+
3331
+ node_cache[:comment_to_eol][start_index] = r0
3332
+
3333
+ r0
3334
+ end
3335
+
3336
+ def _nt_white
3337
+ start_index = index
3338
+ if node_cache[:white].has_key?(index)
3339
+ cached = node_cache[:white][index]
3340
+ if cached
3341
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
3342
+ @index = cached.interval.end
3343
+ end
3344
+ return cached
3345
+ end
3346
+
3347
+ if has_terminal?('\G[ \\t\\n\\r]', true, index)
3348
+ r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
3349
+ @index += 1
3350
+ else
3351
+ r0 = nil
3352
+ end
3353
+
3354
+ node_cache[:white][start_index] = r0
3355
+
3356
+ r0
3357
+ end
3358
+
3359
+ end
3360
+
3361
+ class MetagrammarParser < Treetop::Runtime::CompiledParser
3362
+ include Metagrammar
3363
+ end
3364
+
3365
+ end
3366
+ end