treetop 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +3 -0
- data/Rakefile +35 -0
- data/bin/tt +25 -0
- data/lib/treetop.rb +10 -6
- data/lib/treetop/compiler.rb +7 -0
- data/lib/treetop/compiler/grammar_compiler.rb +21 -0
- data/lib/treetop/compiler/lexical_address_space.rb +17 -0
- data/lib/treetop/compiler/load_grammar.rb +7 -0
- data/lib/treetop/compiler/metagrammar.rb +2441 -0
- data/lib/treetop/compiler/metagrammar.treetop +384 -0
- data/lib/treetop/compiler/node_classes.rb +18 -0
- data/lib/treetop/compiler/node_classes/anything_symbol.rb +10 -0
- data/lib/treetop/compiler/node_classes/atomic_expression.rb +9 -0
- data/lib/treetop/compiler/node_classes/character_class.rb +10 -0
- data/lib/treetop/compiler/node_classes/choice.rb +31 -0
- data/lib/treetop/compiler/node_classes/declaration_sequence.rb +24 -0
- data/lib/treetop/compiler/node_classes/grammar.rb +28 -0
- data/lib/treetop/compiler/node_classes/inline_module.rb +27 -0
- data/lib/treetop/compiler/node_classes/nonterminal.rb +11 -0
- data/lib/treetop/compiler/node_classes/optional.rb +19 -0
- data/lib/treetop/compiler/node_classes/parenthesized_expression.rb +9 -0
- data/lib/treetop/compiler/node_classes/parsing_expression.rb +132 -0
- data/lib/treetop/compiler/node_classes/parsing_rule.rb +55 -0
- data/lib/treetop/compiler/node_classes/predicate.rb +45 -0
- data/lib/treetop/compiler/node_classes/repetition.rb +56 -0
- data/lib/treetop/compiler/node_classes/sequence.rb +64 -0
- data/lib/treetop/compiler/node_classes/terminal.rb +10 -0
- data/lib/treetop/compiler/node_classes/treetop_file.rb +9 -0
- data/lib/treetop/compiler/ruby_builder.rb +109 -0
- data/lib/treetop/ruby_extensions.rb +2 -0
- data/lib/treetop/ruby_extensions/string.rb +19 -0
- data/lib/treetop/runtime.rb +9 -0
- data/lib/treetop/runtime/compiled_parser.rb +66 -0
- data/lib/treetop/runtime/node_cache.rb +27 -0
- data/lib/treetop/runtime/parse_cache.rb +19 -0
- data/lib/treetop/runtime/parse_failure.rb +32 -0
- data/lib/treetop/runtime/parse_result.rb +30 -0
- data/lib/treetop/runtime/syntax_node.rb +53 -0
- data/lib/treetop/runtime/terminal_parse_failure.rb +33 -0
- data/lib/treetop/runtime/terminal_syntax_node.rb +12 -0
- data/test/compilation_target/target.rb +143 -0
- data/test/compilation_target/target.treetop +15 -0
- data/test/compilation_target/target_test.rb +56 -0
- data/test/compiler/and_predicate_test.rb +33 -0
- data/test/compiler/anything_symbol_test.rb +24 -0
- data/test/compiler/character_class_test.rb +45 -0
- data/test/compiler/choice_test.rb +49 -0
- data/test/compiler/circular_compilation_test.rb +20 -0
- data/test/compiler/failure_propagation_functional_test.rb +20 -0
- data/test/compiler/grammar_compiler_test.rb +58 -0
- data/test/compiler/grammar_test.rb +33 -0
- data/test/compiler/nonterminal_symbol_test.rb +15 -0
- data/test/compiler/not_predicate_test.rb +35 -0
- data/test/compiler/one_or_more_test.rb +30 -0
- data/test/compiler/optional_test.rb +32 -0
- data/test/compiler/parsing_rule_test.rb +30 -0
- data/test/compiler/sequence_test.rb +68 -0
- data/test/compiler/terminal_symbol_test.rb +35 -0
- data/test/compiler/test_grammar.treetop +7 -0
- data/test/compiler/zero_or_more_test.rb +51 -0
- data/test/composition/a.treetop +11 -0
- data/test/composition/b.treetop +11 -0
- data/test/composition/c.treetop +10 -0
- data/test/composition/d.treetop +10 -0
- data/test/composition/grammar_composition_test.rb +23 -0
- data/test/parser/syntax_node_test.rb +53 -0
- data/test/parser/terminal_parse_failure_test.rb +22 -0
- data/test/ruby_extensions/string_test.rb +33 -0
- data/test/screw/Rakefile +16 -0
- data/test/screw/unit.rb +37 -0
- data/test/screw/unit/assertion_failed_error.rb +14 -0
- data/test/screw/unit/assertions.rb +615 -0
- data/test/screw/unit/auto_runner.rb +227 -0
- data/test/screw/unit/collector.rb +45 -0
- data/test/screw/unit/collector/dir.rb +107 -0
- data/test/screw/unit/collector/objectspace.rb +28 -0
- data/test/screw/unit/error.rb +48 -0
- data/test/screw/unit/failure.rb +45 -0
- data/test/screw/unit/sugar.rb +25 -0
- data/test/screw/unit/test_case.rb +176 -0
- data/test/screw/unit/test_result.rb +73 -0
- data/test/screw/unit/test_suite.rb +70 -0
- data/test/screw/unit/ui.rb +4 -0
- data/test/screw/unit/ui/console/test_runner.rb +118 -0
- data/test/screw/unit/ui/fox/test_runner.rb +268 -0
- data/test/screw/unit/ui/gtk/test_runner.rb +416 -0
- data/test/screw/unit/ui/gtk2/testrunner.rb +465 -0
- data/test/screw/unit/ui/test_runner_mediator.rb +58 -0
- data/test/screw/unit/ui/test_runner_utilities.rb +46 -0
- data/test/screw/unit/ui/tk/test_runner.rb +260 -0
- data/test/screw/unit/util.rb +4 -0
- data/test/screw/unit/util/backtrace_filter.rb +40 -0
- data/test/screw/unit/util/observable.rb +82 -0
- data/test/screw/unit/util/proc_wrapper.rb +48 -0
- data/test/test_helper.rb +89 -0
- metadata +127 -69
- data/lib/treetop/api.rb +0 -3
- data/lib/treetop/api/load_grammar.rb +0 -16
- data/lib/treetop/api/malformed_grammar_exception.rb +0 -9
- data/lib/treetop/grammar.rb +0 -7
- data/lib/treetop/grammar/grammar.rb +0 -48
- data/lib/treetop/grammar/grammar_builder.rb +0 -35
- data/lib/treetop/grammar/parsing_expression_builder.rb +0 -5
- data/lib/treetop/grammar/parsing_expression_builder_helper.rb +0 -121
- data/lib/treetop/grammar/parsing_expressions.rb +0 -18
- data/lib/treetop/grammar/parsing_expressions/and_predicate.rb +0 -17
- data/lib/treetop/grammar/parsing_expressions/anything_symbol.rb +0 -20
- data/lib/treetop/grammar/parsing_expressions/character_class.rb +0 -24
- data/lib/treetop/grammar/parsing_expressions/node_instantiating_parsing_expression.rb +0 -14
- data/lib/treetop/grammar/parsing_expressions/node_propagating_parsing_expression.rb +0 -4
- data/lib/treetop/grammar/parsing_expressions/nonterminal_symbol.rb +0 -42
- data/lib/treetop/grammar/parsing_expressions/not_predicate.rb +0 -18
- data/lib/treetop/grammar/parsing_expressions/one_or_more.rb +0 -12
- data/lib/treetop/grammar/parsing_expressions/optional.rb +0 -14
- data/lib/treetop/grammar/parsing_expressions/ordered_choice.rb +0 -27
- data/lib/treetop/grammar/parsing_expressions/parsing_expression.rb +0 -36
- data/lib/treetop/grammar/parsing_expressions/predicate.rb +0 -25
- data/lib/treetop/grammar/parsing_expressions/repeating_parsing_expression.rb +0 -29
- data/lib/treetop/grammar/parsing_expressions/sequence.rb +0 -41
- data/lib/treetop/grammar/parsing_expressions/terminal_parsing_expression.rb +0 -11
- data/lib/treetop/grammar/parsing_expressions/terminal_symbol.rb +0 -31
- data/lib/treetop/grammar/parsing_expressions/zero_or_more.rb +0 -11
- data/lib/treetop/grammar/parsing_rule.rb +0 -10
- data/lib/treetop/metagrammar.rb +0 -2
- data/lib/treetop/metagrammar/metagrammar.rb +0 -14
- data/lib/treetop/metagrammar/metagrammar.treetop +0 -320
- data/lib/treetop/parser.rb +0 -11
- data/lib/treetop/parser/node_cache.rb +0 -25
- data/lib/treetop/parser/parse_cache.rb +0 -17
- data/lib/treetop/parser/parse_failure.rb +0 -22
- data/lib/treetop/parser/parse_result.rb +0 -26
- data/lib/treetop/parser/parser.rb +0 -24
- data/lib/treetop/parser/sequence_syntax_node.rb +0 -14
- data/lib/treetop/parser/syntax_node.rb +0 -31
- data/lib/treetop/parser/terminal_parse_failure.rb +0 -18
- data/lib/treetop/parser/terminal_syntax_node.rb +0 -7
- data/lib/treetop/protometagrammar.rb +0 -16
- data/lib/treetop/protometagrammar/anything_symbol_expression_builder.rb +0 -13
- data/lib/treetop/protometagrammar/block_expression_builder.rb +0 -17
- data/lib/treetop/protometagrammar/character_class_expression_builder.rb +0 -25
- data/lib/treetop/protometagrammar/grammar_expression_builder.rb +0 -38
- data/lib/treetop/protometagrammar/nonterminal_symbol_expression_builder.rb +0 -45
- data/lib/treetop/protometagrammar/ordered_choice_expression_builder.rb +0 -21
- data/lib/treetop/protometagrammar/parsing_rule_expression_builder.rb +0 -23
- data/lib/treetop/protometagrammar/parsing_rule_sequence_expression_builder.rb +0 -14
- data/lib/treetop/protometagrammar/prefix_expression_builder.rb +0 -25
- data/lib/treetop/protometagrammar/primary_expression_builder.rb +0 -71
- data/lib/treetop/protometagrammar/protometagrammar.rb +0 -25
- data/lib/treetop/protometagrammar/sequence_expression_builder.rb +0 -37
- data/lib/treetop/protometagrammar/suffix_expression_builder.rb +0 -33
- data/lib/treetop/protometagrammar/terminal_symbol_expression_builder.rb +0 -52
- data/lib/treetop/protometagrammar/trailing_block_expression_builder.rb +0 -30
- data/lib/treetop/ruby_extension.rb +0 -11
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
dir = File.dirname(__FILE__)
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake'
|
5
|
+
require 'spec/rake/spectask'
|
6
|
+
Gem::manage_gems
|
7
|
+
require 'rake/gempackagetask'
|
8
|
+
require 'rake/testtask'
|
9
|
+
|
10
|
+
task :default => :test
|
11
|
+
|
12
|
+
Rake::TestTask.new do |t|
|
13
|
+
t.pattern = 'test/**/*test.rb'
|
14
|
+
end
|
15
|
+
|
16
|
+
gemspec = Gem::Specification.new do |s|
|
17
|
+
s.name = "treetop"
|
18
|
+
s.version = "1.0.0"
|
19
|
+
s.author = "Nathan Sobo"
|
20
|
+
s.email = "nathansobo@gmail.com"
|
21
|
+
s.homepage = "http://functionalform.blogspot.com"
|
22
|
+
s.platform = Gem::Platform::RUBY
|
23
|
+
s.summary = "A Ruby-based text parsing and interpretation DSL"
|
24
|
+
s.files = FileList["README", "Rakefile", "{test,lib,bin}/**/*"].to_a
|
25
|
+
s.bindir = "bin"
|
26
|
+
s.executables = ["tt"]
|
27
|
+
s.require_path = "lib"
|
28
|
+
s.autorequire = "treetop"
|
29
|
+
s.has_rdoc = false
|
30
|
+
s.add_dependency "facets"
|
31
|
+
end
|
32
|
+
|
33
|
+
Rake::GemPackageTask.new(gemspec) do |pkg|
|
34
|
+
pkg.need_tar = true
|
35
|
+
end
|
data/bin/tt
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
gem 'treetop'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
6
|
+
require 'treetop'
|
7
|
+
|
8
|
+
if ARGV.empty?
|
9
|
+
puts "Usage:\n\ntt foo.treetop bar.treetop ...\n or\ntt foo.treetop -o alternate_name.rb\n\n"
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
compiler = Treetop::Compiler::GrammarCompiler.new
|
14
|
+
|
15
|
+
# explicit output file name option
|
16
|
+
if ARGV.size == 3 && ARGV[1] == '-o'
|
17
|
+
compiler.compile(ARGV[0], ARGV[2])
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
# list of input files option
|
22
|
+
treetop_files = ARGV
|
23
|
+
treetop_files.each do |treetop_file_path|
|
24
|
+
compiler.compile(treetop_file_path)
|
25
|
+
end
|
data/lib/treetop.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'facet/string/tab'
|
3
|
+
require 'facet/string/camelize'
|
4
|
+
|
5
|
+
dir = File.dirname(__FILE__)
|
6
|
+
|
7
|
+
TREETOP_ROOT = File.join(dir, 'treetop')
|
8
|
+
require File.join(TREETOP_ROOT, "ruby_extensions")
|
9
|
+
require File.join(TREETOP_ROOT, "runtime")
|
10
|
+
require File.join(TREETOP_ROOT, "compiler")
|
@@ -0,0 +1,7 @@
|
|
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])
|
6
|
+
require File.join(dir, *%w[compiler grammar_compiler])
|
7
|
+
require File.join(dir, *%w[compiler load_grammar])
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Treetop
|
2
|
+
module Compiler
|
3
|
+
class GrammarCompiler
|
4
|
+
def compile(source_path, target_path = source_path.gsub(/treetop\Z/, 'rb'))
|
5
|
+
File.open(target_path, 'w') do |target_file|
|
6
|
+
target_file.write(ruby_source(source_path))
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def ruby_source(source_path)
|
11
|
+
File.open(source_path) do |source_file|
|
12
|
+
result = MetagrammarParser.new.parse(source_file.read)
|
13
|
+
if result.failure?
|
14
|
+
raise RuntimeError.new(result.nested_failures.map {|failure| failure.to_s}.join("\n"))
|
15
|
+
end
|
16
|
+
result.compile
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,2441 @@
|
|
1
|
+
module Treetop
|
2
|
+
module Compiler
|
3
|
+
module Metagrammar
|
4
|
+
include ::Treetop::Runtime
|
5
|
+
|
6
|
+
def root
|
7
|
+
_nt_treetop_file
|
8
|
+
end
|
9
|
+
|
10
|
+
module TreetopFile0
|
11
|
+
def compile
|
12
|
+
prefix.text_value + module_or_grammar.compile + suffix.text_value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module TreetopFile1
|
17
|
+
def prefix
|
18
|
+
elements[0]
|
19
|
+
end
|
20
|
+
|
21
|
+
def module_or_grammar
|
22
|
+
elements[1]
|
23
|
+
end
|
24
|
+
|
25
|
+
def suffix
|
26
|
+
elements[2]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def _nt_treetop_file
|
31
|
+
start_index = index
|
32
|
+
cached = node_cache[:treetop_file][index]
|
33
|
+
if cached
|
34
|
+
@index = cached.interval.end
|
35
|
+
return cached
|
36
|
+
end
|
37
|
+
|
38
|
+
i0, s0, nr0 = index, [], []
|
39
|
+
r2 = _nt_space
|
40
|
+
if r2.success?
|
41
|
+
r1 = r2
|
42
|
+
else
|
43
|
+
r1 = SyntaxNode.new(input, index...index, r2.nested_failures)
|
44
|
+
end
|
45
|
+
s0 << r1
|
46
|
+
if r1.success?
|
47
|
+
i3, nr3 = index, []
|
48
|
+
r4 = _nt_module_declaration
|
49
|
+
nr3 << r4
|
50
|
+
if r4.success?
|
51
|
+
r3 = r4
|
52
|
+
r4.update_nested_results(nr3)
|
53
|
+
else
|
54
|
+
r5 = _nt_grammar
|
55
|
+
nr3 << r5
|
56
|
+
if r5.success?
|
57
|
+
r3 = r5
|
58
|
+
r5.update_nested_results(nr3)
|
59
|
+
else
|
60
|
+
self.index = i3
|
61
|
+
r3 = ParseFailure.new(input, i3, nr3)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
s0 << r3
|
65
|
+
if r3.success?
|
66
|
+
r7 = _nt_space
|
67
|
+
if r7.success?
|
68
|
+
r6 = r7
|
69
|
+
else
|
70
|
+
r6 = SyntaxNode.new(input, index...index, r7.nested_failures)
|
71
|
+
end
|
72
|
+
s0 << r6
|
73
|
+
end
|
74
|
+
end
|
75
|
+
if s0.last.success?
|
76
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
77
|
+
r0.extend(TreetopFile1)
|
78
|
+
r0.extend(TreetopFile0)
|
79
|
+
else
|
80
|
+
self.index = i0
|
81
|
+
r0 = ParseFailure.new(input, i0, s0)
|
82
|
+
end
|
83
|
+
|
84
|
+
node_cache[:treetop_file][start_index] = r0
|
85
|
+
|
86
|
+
return r0
|
87
|
+
end
|
88
|
+
|
89
|
+
module ModuleDeclaration0
|
90
|
+
def space
|
91
|
+
elements[1]
|
92
|
+
end
|
93
|
+
|
94
|
+
def space
|
95
|
+
elements[4]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
module ModuleDeclaration1
|
100
|
+
def space
|
101
|
+
elements[0]
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
module ModuleDeclaration2
|
107
|
+
def compile
|
108
|
+
prefix.text_value + module_contents.compile + suffix.text_value
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
module ModuleDeclaration3
|
113
|
+
def prefix
|
114
|
+
elements[0]
|
115
|
+
end
|
116
|
+
|
117
|
+
def module_contents
|
118
|
+
elements[1]
|
119
|
+
end
|
120
|
+
|
121
|
+
def suffix
|
122
|
+
elements[2]
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def _nt_module_declaration
|
127
|
+
start_index = index
|
128
|
+
cached = node_cache[:module_declaration][index]
|
129
|
+
if cached
|
130
|
+
@index = cached.interval.end
|
131
|
+
return cached
|
132
|
+
end
|
133
|
+
|
134
|
+
i0, s0, nr0 = index, [], []
|
135
|
+
i1, s1, nr1 = index, [], []
|
136
|
+
r2 = parse_terminal('module', SyntaxNode)
|
137
|
+
s1 << r2
|
138
|
+
if r2.success?
|
139
|
+
r3 = _nt_space
|
140
|
+
s1 << r3
|
141
|
+
if r3.success?
|
142
|
+
r4 = parse_char_class(/[A-Z]/, 'A-Z', SyntaxNode)
|
143
|
+
s1 << r4
|
144
|
+
if r4.success?
|
145
|
+
s5, nr5, i5 = [], [], index
|
146
|
+
loop do
|
147
|
+
r6 = _nt_alphanumeric_char
|
148
|
+
nr5 << r6
|
149
|
+
if r6.success?
|
150
|
+
s5 << r6
|
151
|
+
else
|
152
|
+
break
|
153
|
+
end
|
154
|
+
end
|
155
|
+
r5 = SyntaxNode.new(input, i5...index, s5, nr5)
|
156
|
+
s1 << r5
|
157
|
+
if r5.success?
|
158
|
+
r7 = _nt_space
|
159
|
+
s1 << r7
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
if s1.last.success?
|
165
|
+
r1 = (SyntaxNode).new(input, i1...index, s1)
|
166
|
+
r1.extend(ModuleDeclaration0)
|
167
|
+
else
|
168
|
+
self.index = i1
|
169
|
+
r1 = ParseFailure.new(input, i1, s1)
|
170
|
+
end
|
171
|
+
s0 << r1
|
172
|
+
if r1.success?
|
173
|
+
i8, nr8 = index, []
|
174
|
+
r9 = _nt_module_declaration
|
175
|
+
nr8 << r9
|
176
|
+
if r9.success?
|
177
|
+
r8 = r9
|
178
|
+
r9.update_nested_results(nr8)
|
179
|
+
else
|
180
|
+
r10 = _nt_grammar
|
181
|
+
nr8 << r10
|
182
|
+
if r10.success?
|
183
|
+
r8 = r10
|
184
|
+
r10.update_nested_results(nr8)
|
185
|
+
else
|
186
|
+
self.index = i8
|
187
|
+
r8 = ParseFailure.new(input, i8, nr8)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
s0 << r8
|
191
|
+
if r8.success?
|
192
|
+
i11, s11, nr11 = index, [], []
|
193
|
+
r12 = _nt_space
|
194
|
+
s11 << r12
|
195
|
+
if r12.success?
|
196
|
+
r13 = parse_terminal('end', SyntaxNode)
|
197
|
+
s11 << r13
|
198
|
+
end
|
199
|
+
if s11.last.success?
|
200
|
+
r11 = (SyntaxNode).new(input, i11...index, s11)
|
201
|
+
r11.extend(ModuleDeclaration1)
|
202
|
+
else
|
203
|
+
self.index = i11
|
204
|
+
r11 = ParseFailure.new(input, i11, s11)
|
205
|
+
end
|
206
|
+
s0 << r11
|
207
|
+
end
|
208
|
+
end
|
209
|
+
if s0.last.success?
|
210
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
211
|
+
r0.extend(ModuleDeclaration3)
|
212
|
+
r0.extend(ModuleDeclaration2)
|
213
|
+
else
|
214
|
+
self.index = i0
|
215
|
+
r0 = ParseFailure.new(input, i0, s0)
|
216
|
+
end
|
217
|
+
|
218
|
+
node_cache[:module_declaration][start_index] = r0
|
219
|
+
|
220
|
+
return r0
|
221
|
+
end
|
222
|
+
|
223
|
+
module Grammar0
|
224
|
+
def space
|
225
|
+
elements[1]
|
226
|
+
end
|
227
|
+
|
228
|
+
def grammar_name
|
229
|
+
elements[2]
|
230
|
+
end
|
231
|
+
|
232
|
+
def space
|
233
|
+
elements[3]
|
234
|
+
end
|
235
|
+
|
236
|
+
def declaration_sequence
|
237
|
+
elements[4]
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
def _nt_grammar
|
243
|
+
start_index = index
|
244
|
+
cached = node_cache[:grammar][index]
|
245
|
+
if cached
|
246
|
+
@index = cached.interval.end
|
247
|
+
return cached
|
248
|
+
end
|
249
|
+
|
250
|
+
i0, s0, nr0 = index, [], []
|
251
|
+
r1 = parse_terminal('grammar', SyntaxNode)
|
252
|
+
s0 << r1
|
253
|
+
if r1.success?
|
254
|
+
r2 = _nt_space
|
255
|
+
s0 << r2
|
256
|
+
if r2.success?
|
257
|
+
r3 = _nt_grammar_name
|
258
|
+
s0 << r3
|
259
|
+
if r3.success?
|
260
|
+
r4 = _nt_space
|
261
|
+
s0 << r4
|
262
|
+
if r4.success?
|
263
|
+
r5 = _nt_declaration_sequence
|
264
|
+
s0 << r5
|
265
|
+
if r5.success?
|
266
|
+
r7 = _nt_space
|
267
|
+
if r7.success?
|
268
|
+
r6 = r7
|
269
|
+
else
|
270
|
+
r6 = SyntaxNode.new(input, index...index, r7.nested_failures)
|
271
|
+
end
|
272
|
+
s0 << r6
|
273
|
+
if r6.success?
|
274
|
+
r8 = parse_terminal('end', SyntaxNode)
|
275
|
+
s0 << r8
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
if s0.last.success?
|
283
|
+
r0 = (Grammar).new(input, i0...index, s0)
|
284
|
+
r0.extend(Grammar0)
|
285
|
+
else
|
286
|
+
self.index = i0
|
287
|
+
r0 = ParseFailure.new(input, i0, s0)
|
288
|
+
end
|
289
|
+
|
290
|
+
node_cache[:grammar][start_index] = r0
|
291
|
+
|
292
|
+
return r0
|
293
|
+
end
|
294
|
+
|
295
|
+
module GrammarName0
|
296
|
+
end
|
297
|
+
|
298
|
+
def _nt_grammar_name
|
299
|
+
start_index = index
|
300
|
+
cached = node_cache[:grammar_name][index]
|
301
|
+
if cached
|
302
|
+
@index = cached.interval.end
|
303
|
+
return cached
|
304
|
+
end
|
305
|
+
|
306
|
+
i0, s0, nr0 = index, [], []
|
307
|
+
r1 = parse_char_class(/[A-Z]/, 'A-Z', SyntaxNode)
|
308
|
+
s0 << r1
|
309
|
+
if r1.success?
|
310
|
+
s2, nr2, i2 = [], [], index
|
311
|
+
loop do
|
312
|
+
r3 = _nt_alphanumeric_char
|
313
|
+
nr2 << r3
|
314
|
+
if r3.success?
|
315
|
+
s2 << r3
|
316
|
+
else
|
317
|
+
break
|
318
|
+
end
|
319
|
+
end
|
320
|
+
r2 = SyntaxNode.new(input, i2...index, s2, nr2)
|
321
|
+
s0 << r2
|
322
|
+
end
|
323
|
+
if s0.last.success?
|
324
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
325
|
+
r0.extend(GrammarName0)
|
326
|
+
else
|
327
|
+
self.index = i0
|
328
|
+
r0 = ParseFailure.new(input, i0, s0)
|
329
|
+
end
|
330
|
+
|
331
|
+
node_cache[:grammar_name][start_index] = r0
|
332
|
+
|
333
|
+
return r0
|
334
|
+
end
|
335
|
+
|
336
|
+
module DeclarationSequence0
|
337
|
+
def space
|
338
|
+
elements[0]
|
339
|
+
end
|
340
|
+
|
341
|
+
def declaration
|
342
|
+
elements[1]
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
module DeclarationSequence1
|
347
|
+
def declarations
|
348
|
+
[head] + tail
|
349
|
+
end
|
350
|
+
|
351
|
+
def tail
|
352
|
+
super.elements.map { |elt| elt.declaration }
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
module DeclarationSequence2
|
357
|
+
def head
|
358
|
+
elements[0]
|
359
|
+
end
|
360
|
+
|
361
|
+
def tail
|
362
|
+
elements[1]
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
module DeclarationSequence3
|
367
|
+
def compile(builder)
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
def _nt_declaration_sequence
|
372
|
+
start_index = index
|
373
|
+
cached = node_cache[:declaration_sequence][index]
|
374
|
+
if cached
|
375
|
+
@index = cached.interval.end
|
376
|
+
return cached
|
377
|
+
end
|
378
|
+
|
379
|
+
i0, nr0 = index, []
|
380
|
+
i1, s1, nr1 = index, [], []
|
381
|
+
r2 = _nt_declaration
|
382
|
+
s1 << r2
|
383
|
+
if r2.success?
|
384
|
+
s3, nr3, i3 = [], [], index
|
385
|
+
loop do
|
386
|
+
i4, s4, nr4 = index, [], []
|
387
|
+
r5 = _nt_space
|
388
|
+
s4 << r5
|
389
|
+
if r5.success?
|
390
|
+
r6 = _nt_declaration
|
391
|
+
s4 << r6
|
392
|
+
end
|
393
|
+
if s4.last.success?
|
394
|
+
r4 = (SyntaxNode).new(input, i4...index, s4)
|
395
|
+
r4.extend(DeclarationSequence0)
|
396
|
+
else
|
397
|
+
self.index = i4
|
398
|
+
r4 = ParseFailure.new(input, i4, s4)
|
399
|
+
end
|
400
|
+
nr3 << r4
|
401
|
+
if r4.success?
|
402
|
+
s3 << r4
|
403
|
+
else
|
404
|
+
break
|
405
|
+
end
|
406
|
+
end
|
407
|
+
r3 = SyntaxNode.new(input, i3...index, s3, nr3)
|
408
|
+
s1 << r3
|
409
|
+
end
|
410
|
+
if s1.last.success?
|
411
|
+
r1 = (DeclarationSequence).new(input, i1...index, s1)
|
412
|
+
r1.extend(DeclarationSequence2)
|
413
|
+
r1.extend(DeclarationSequence1)
|
414
|
+
else
|
415
|
+
self.index = i1
|
416
|
+
r1 = ParseFailure.new(input, i1, s1)
|
417
|
+
end
|
418
|
+
nr0 << r1
|
419
|
+
if r1.success?
|
420
|
+
r0 = r1
|
421
|
+
r1.update_nested_results(nr0)
|
422
|
+
else
|
423
|
+
r7 = parse_terminal('', SyntaxNode, DeclarationSequence3)
|
424
|
+
nr0 << r7
|
425
|
+
if r7.success?
|
426
|
+
r0 = r7
|
427
|
+
r7.update_nested_results(nr0)
|
428
|
+
else
|
429
|
+
self.index = i0
|
430
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
node_cache[:declaration_sequence][start_index] = r0
|
435
|
+
|
436
|
+
return r0
|
437
|
+
end
|
438
|
+
|
439
|
+
def _nt_declaration
|
440
|
+
start_index = index
|
441
|
+
cached = node_cache[:declaration][index]
|
442
|
+
if cached
|
443
|
+
@index = cached.interval.end
|
444
|
+
return cached
|
445
|
+
end
|
446
|
+
|
447
|
+
i0, nr0 = index, []
|
448
|
+
r1 = _nt_parsing_rule
|
449
|
+
nr0 << r1
|
450
|
+
if r1.success?
|
451
|
+
r0 = r1
|
452
|
+
r1.update_nested_results(nr0)
|
453
|
+
else
|
454
|
+
r2 = _nt_include_declaration
|
455
|
+
nr0 << r2
|
456
|
+
if r2.success?
|
457
|
+
r0 = r2
|
458
|
+
r2.update_nested_results(nr0)
|
459
|
+
else
|
460
|
+
self.index = i0
|
461
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
node_cache[:declaration][start_index] = r0
|
466
|
+
|
467
|
+
return r0
|
468
|
+
end
|
469
|
+
|
470
|
+
module IncludeDeclaration0
|
471
|
+
def compile(builder)
|
472
|
+
builder << text_value
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
476
|
+
module IncludeDeclaration1
|
477
|
+
def space
|
478
|
+
elements[1]
|
479
|
+
end
|
480
|
+
|
481
|
+
end
|
482
|
+
|
483
|
+
def _nt_include_declaration
|
484
|
+
start_index = index
|
485
|
+
cached = node_cache[:include_declaration][index]
|
486
|
+
if cached
|
487
|
+
@index = cached.interval.end
|
488
|
+
return cached
|
489
|
+
end
|
490
|
+
|
491
|
+
i0, s0, nr0 = index, [], []
|
492
|
+
r1 = parse_terminal('include', SyntaxNode)
|
493
|
+
s0 << r1
|
494
|
+
if r1.success?
|
495
|
+
r2 = _nt_space
|
496
|
+
s0 << r2
|
497
|
+
if r2.success?
|
498
|
+
r3 = parse_char_class(/[A-Z]/, 'A-Z', SyntaxNode)
|
499
|
+
s0 << r3
|
500
|
+
if r3.success?
|
501
|
+
s4, nr4, i4 = [], [], index
|
502
|
+
loop do
|
503
|
+
r5 = _nt_alphanumeric_char
|
504
|
+
nr4 << r5
|
505
|
+
if r5.success?
|
506
|
+
s4 << r5
|
507
|
+
else
|
508
|
+
break
|
509
|
+
end
|
510
|
+
end
|
511
|
+
r4 = SyntaxNode.new(input, i4...index, s4, nr4)
|
512
|
+
s0 << r4
|
513
|
+
end
|
514
|
+
end
|
515
|
+
end
|
516
|
+
if s0.last.success?
|
517
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
518
|
+
r0.extend(IncludeDeclaration1)
|
519
|
+
r0.extend(IncludeDeclaration0)
|
520
|
+
else
|
521
|
+
self.index = i0
|
522
|
+
r0 = ParseFailure.new(input, i0, s0)
|
523
|
+
end
|
524
|
+
|
525
|
+
node_cache[:include_declaration][start_index] = r0
|
526
|
+
|
527
|
+
return r0
|
528
|
+
end
|
529
|
+
|
530
|
+
module ParsingRule0
|
531
|
+
def space
|
532
|
+
elements[1]
|
533
|
+
end
|
534
|
+
|
535
|
+
def nonterminal
|
536
|
+
elements[2]
|
537
|
+
end
|
538
|
+
|
539
|
+
def space
|
540
|
+
elements[3]
|
541
|
+
end
|
542
|
+
|
543
|
+
def parsing_expression
|
544
|
+
elements[4]
|
545
|
+
end
|
546
|
+
|
547
|
+
def space
|
548
|
+
elements[5]
|
549
|
+
end
|
550
|
+
|
551
|
+
end
|
552
|
+
|
553
|
+
def _nt_parsing_rule
|
554
|
+
start_index = index
|
555
|
+
cached = node_cache[:parsing_rule][index]
|
556
|
+
if cached
|
557
|
+
@index = cached.interval.end
|
558
|
+
return cached
|
559
|
+
end
|
560
|
+
|
561
|
+
i0, s0, nr0 = index, [], []
|
562
|
+
r1 = parse_terminal('rule', SyntaxNode)
|
563
|
+
s0 << r1
|
564
|
+
if r1.success?
|
565
|
+
r2 = _nt_space
|
566
|
+
s0 << r2
|
567
|
+
if r2.success?
|
568
|
+
r3 = _nt_nonterminal
|
569
|
+
s0 << r3
|
570
|
+
if r3.success?
|
571
|
+
r4 = _nt_space
|
572
|
+
s0 << r4
|
573
|
+
if r4.success?
|
574
|
+
r5 = _nt_parsing_expression
|
575
|
+
s0 << r5
|
576
|
+
if r5.success?
|
577
|
+
r6 = _nt_space
|
578
|
+
s0 << r6
|
579
|
+
if r6.success?
|
580
|
+
r7 = parse_terminal('end', SyntaxNode)
|
581
|
+
s0 << r7
|
582
|
+
end
|
583
|
+
end
|
584
|
+
end
|
585
|
+
end
|
586
|
+
end
|
587
|
+
end
|
588
|
+
if s0.last.success?
|
589
|
+
r0 = (ParsingRule).new(input, i0...index, s0)
|
590
|
+
r0.extend(ParsingRule0)
|
591
|
+
else
|
592
|
+
self.index = i0
|
593
|
+
r0 = ParseFailure.new(input, i0, s0)
|
594
|
+
end
|
595
|
+
|
596
|
+
node_cache[:parsing_rule][start_index] = r0
|
597
|
+
|
598
|
+
return r0
|
599
|
+
end
|
600
|
+
|
601
|
+
def _nt_parsing_expression
|
602
|
+
start_index = index
|
603
|
+
cached = node_cache[:parsing_expression][index]
|
604
|
+
if cached
|
605
|
+
@index = cached.interval.end
|
606
|
+
return cached
|
607
|
+
end
|
608
|
+
|
609
|
+
i0, nr0 = index, []
|
610
|
+
r1 = _nt_choice
|
611
|
+
nr0 << r1
|
612
|
+
if r1.success?
|
613
|
+
r0 = r1
|
614
|
+
r1.update_nested_results(nr0)
|
615
|
+
else
|
616
|
+
r2 = _nt_sequence
|
617
|
+
nr0 << r2
|
618
|
+
if r2.success?
|
619
|
+
r0 = r2
|
620
|
+
r2.update_nested_results(nr0)
|
621
|
+
else
|
622
|
+
r3 = _nt_primary
|
623
|
+
nr0 << r3
|
624
|
+
if r3.success?
|
625
|
+
r0 = r3
|
626
|
+
r3.update_nested_results(nr0)
|
627
|
+
else
|
628
|
+
self.index = i0
|
629
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
630
|
+
end
|
631
|
+
end
|
632
|
+
end
|
633
|
+
|
634
|
+
node_cache[:parsing_expression][start_index] = r0
|
635
|
+
|
636
|
+
return r0
|
637
|
+
end
|
638
|
+
|
639
|
+
module Choice0
|
640
|
+
def alternative
|
641
|
+
elements[3]
|
642
|
+
end
|
643
|
+
end
|
644
|
+
|
645
|
+
module Choice1
|
646
|
+
def alternatives
|
647
|
+
[head] + tail
|
648
|
+
end
|
649
|
+
|
650
|
+
def tail
|
651
|
+
super.elements.map {|elt| elt.alternative}
|
652
|
+
end
|
653
|
+
|
654
|
+
def inline_modules
|
655
|
+
(alternatives.map {|alt| alt.inline_modules }).flatten
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
module Choice2
|
660
|
+
def head
|
661
|
+
elements[0]
|
662
|
+
end
|
663
|
+
|
664
|
+
def tail
|
665
|
+
elements[1]
|
666
|
+
end
|
667
|
+
end
|
668
|
+
|
669
|
+
def _nt_choice
|
670
|
+
start_index = index
|
671
|
+
cached = node_cache[:choice][index]
|
672
|
+
if cached
|
673
|
+
@index = cached.interval.end
|
674
|
+
return cached
|
675
|
+
end
|
676
|
+
|
677
|
+
i0, s0, nr0 = index, [], []
|
678
|
+
r1 = _nt_alternative
|
679
|
+
s0 << r1
|
680
|
+
if r1.success?
|
681
|
+
s2, nr2, i2 = [], [], index
|
682
|
+
loop do
|
683
|
+
i3, s3, nr3 = index, [], []
|
684
|
+
r5 = _nt_space
|
685
|
+
if r5.success?
|
686
|
+
r4 = r5
|
687
|
+
else
|
688
|
+
r4 = SyntaxNode.new(input, index...index, r5.nested_failures)
|
689
|
+
end
|
690
|
+
s3 << r4
|
691
|
+
if r4.success?
|
692
|
+
r6 = parse_terminal('/', SyntaxNode)
|
693
|
+
s3 << r6
|
694
|
+
if r6.success?
|
695
|
+
r8 = _nt_space
|
696
|
+
if r8.success?
|
697
|
+
r7 = r8
|
698
|
+
else
|
699
|
+
r7 = SyntaxNode.new(input, index...index, r8.nested_failures)
|
700
|
+
end
|
701
|
+
s3 << r7
|
702
|
+
if r7.success?
|
703
|
+
r9 = _nt_alternative
|
704
|
+
s3 << r9
|
705
|
+
end
|
706
|
+
end
|
707
|
+
end
|
708
|
+
if s3.last.success?
|
709
|
+
r3 = (SyntaxNode).new(input, i3...index, s3)
|
710
|
+
r3.extend(Choice0)
|
711
|
+
else
|
712
|
+
self.index = i3
|
713
|
+
r3 = ParseFailure.new(input, i3, s3)
|
714
|
+
end
|
715
|
+
nr2 << r3
|
716
|
+
if r3.success?
|
717
|
+
s2 << r3
|
718
|
+
else
|
719
|
+
break
|
720
|
+
end
|
721
|
+
end
|
722
|
+
if s2.empty?
|
723
|
+
self.index = i2
|
724
|
+
r2 = ParseFailure.new(input, i2, nr2)
|
725
|
+
else
|
726
|
+
r2 = SyntaxNode.new(input, i2...index, s2, nr2)
|
727
|
+
end
|
728
|
+
s0 << r2
|
729
|
+
end
|
730
|
+
if s0.last.success?
|
731
|
+
r0 = (Choice).new(input, i0...index, s0)
|
732
|
+
r0.extend(Choice2)
|
733
|
+
r0.extend(Choice1)
|
734
|
+
else
|
735
|
+
self.index = i0
|
736
|
+
r0 = ParseFailure.new(input, i0, s0)
|
737
|
+
end
|
738
|
+
|
739
|
+
node_cache[:choice][start_index] = r0
|
740
|
+
|
741
|
+
return r0
|
742
|
+
end
|
743
|
+
|
744
|
+
module Sequence0
|
745
|
+
def space
|
746
|
+
elements[0]
|
747
|
+
end
|
748
|
+
|
749
|
+
def labeled_sequence_primary
|
750
|
+
elements[1]
|
751
|
+
end
|
752
|
+
end
|
753
|
+
|
754
|
+
module Sequence1
|
755
|
+
def sequence_elements
|
756
|
+
[head] + tail
|
757
|
+
end
|
758
|
+
|
759
|
+
def tail
|
760
|
+
super.elements.map {|elt| elt.labeled_sequence_primary }
|
761
|
+
end
|
762
|
+
|
763
|
+
def inline_modules
|
764
|
+
(sequence_elements.map {|elt| elt.inline_modules}).flatten +
|
765
|
+
[sequence_element_accessor_module] +
|
766
|
+
node_class_declarations.inline_modules
|
767
|
+
end
|
768
|
+
|
769
|
+
def inline_module_name
|
770
|
+
node_class_declarations.inline_module_name
|
771
|
+
end
|
772
|
+
end
|
773
|
+
|
774
|
+
module Sequence2
|
775
|
+
def head
|
776
|
+
elements[0]
|
777
|
+
end
|
778
|
+
|
779
|
+
def tail
|
780
|
+
elements[1]
|
781
|
+
end
|
782
|
+
|
783
|
+
def node_class_declarations
|
784
|
+
elements[2]
|
785
|
+
end
|
786
|
+
end
|
787
|
+
|
788
|
+
def _nt_sequence
|
789
|
+
start_index = index
|
790
|
+
cached = node_cache[:sequence][index]
|
791
|
+
if cached
|
792
|
+
@index = cached.interval.end
|
793
|
+
return cached
|
794
|
+
end
|
795
|
+
|
796
|
+
i0, s0, nr0 = index, [], []
|
797
|
+
r1 = _nt_labeled_sequence_primary
|
798
|
+
s0 << r1
|
799
|
+
if r1.success?
|
800
|
+
s2, nr2, i2 = [], [], index
|
801
|
+
loop do
|
802
|
+
i3, s3, nr3 = index, [], []
|
803
|
+
r4 = _nt_space
|
804
|
+
s3 << r4
|
805
|
+
if r4.success?
|
806
|
+
r5 = _nt_labeled_sequence_primary
|
807
|
+
s3 << r5
|
808
|
+
end
|
809
|
+
if s3.last.success?
|
810
|
+
r3 = (SyntaxNode).new(input, i3...index, s3)
|
811
|
+
r3.extend(Sequence0)
|
812
|
+
else
|
813
|
+
self.index = i3
|
814
|
+
r3 = ParseFailure.new(input, i3, s3)
|
815
|
+
end
|
816
|
+
nr2 << r3
|
817
|
+
if r3.success?
|
818
|
+
s2 << r3
|
819
|
+
else
|
820
|
+
break
|
821
|
+
end
|
822
|
+
end
|
823
|
+
if s2.empty?
|
824
|
+
self.index = i2
|
825
|
+
r2 = ParseFailure.new(input, i2, nr2)
|
826
|
+
else
|
827
|
+
r2 = SyntaxNode.new(input, i2...index, s2, nr2)
|
828
|
+
end
|
829
|
+
s0 << r2
|
830
|
+
if r2.success?
|
831
|
+
r6 = _nt_node_class_declarations
|
832
|
+
s0 << r6
|
833
|
+
end
|
834
|
+
end
|
835
|
+
if s0.last.success?
|
836
|
+
r0 = (Sequence).new(input, i0...index, s0)
|
837
|
+
r0.extend(Sequence2)
|
838
|
+
r0.extend(Sequence1)
|
839
|
+
else
|
840
|
+
self.index = i0
|
841
|
+
r0 = ParseFailure.new(input, i0, s0)
|
842
|
+
end
|
843
|
+
|
844
|
+
node_cache[:sequence][start_index] = r0
|
845
|
+
|
846
|
+
return r0
|
847
|
+
end
|
848
|
+
|
849
|
+
def _nt_alternative
|
850
|
+
start_index = index
|
851
|
+
cached = node_cache[:alternative][index]
|
852
|
+
if cached
|
853
|
+
@index = cached.interval.end
|
854
|
+
return cached
|
855
|
+
end
|
856
|
+
|
857
|
+
i0, nr0 = index, []
|
858
|
+
r1 = _nt_sequence
|
859
|
+
nr0 << r1
|
860
|
+
if r1.success?
|
861
|
+
r0 = r1
|
862
|
+
r1.update_nested_results(nr0)
|
863
|
+
else
|
864
|
+
r2 = _nt_primary
|
865
|
+
nr0 << r2
|
866
|
+
if r2.success?
|
867
|
+
r0 = r2
|
868
|
+
r2.update_nested_results(nr0)
|
869
|
+
else
|
870
|
+
self.index = i0
|
871
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
872
|
+
end
|
873
|
+
end
|
874
|
+
|
875
|
+
node_cache[:alternative][start_index] = r0
|
876
|
+
|
877
|
+
return r0
|
878
|
+
end
|
879
|
+
|
880
|
+
module Primary0
|
881
|
+
def compile(address, builder)
|
882
|
+
prefix.compile(address, builder, self)
|
883
|
+
end
|
884
|
+
|
885
|
+
def predicated_expression
|
886
|
+
atomic
|
887
|
+
end
|
888
|
+
|
889
|
+
def inline_modules
|
890
|
+
atomic.inline_modules
|
891
|
+
end
|
892
|
+
|
893
|
+
def inline_module_name
|
894
|
+
nil
|
895
|
+
end
|
896
|
+
end
|
897
|
+
|
898
|
+
module Primary1
|
899
|
+
def prefix
|
900
|
+
elements[0]
|
901
|
+
end
|
902
|
+
|
903
|
+
def atomic
|
904
|
+
elements[1]
|
905
|
+
end
|
906
|
+
end
|
907
|
+
|
908
|
+
module Primary2
|
909
|
+
def compile(address, builder)
|
910
|
+
suffix.compile(address, builder, self)
|
911
|
+
end
|
912
|
+
|
913
|
+
def optional_expression
|
914
|
+
atomic
|
915
|
+
end
|
916
|
+
|
917
|
+
def node_class
|
918
|
+
node_class_declarations.node_class
|
919
|
+
end
|
920
|
+
|
921
|
+
def inline_modules
|
922
|
+
atomic.inline_modules + node_class_declarations.inline_modules
|
923
|
+
end
|
924
|
+
|
925
|
+
def inline_module_name
|
926
|
+
node_class_declarations.inline_module_name
|
927
|
+
end
|
928
|
+
end
|
929
|
+
|
930
|
+
module Primary3
|
931
|
+
def atomic
|
932
|
+
elements[0]
|
933
|
+
end
|
934
|
+
|
935
|
+
def suffix
|
936
|
+
elements[1]
|
937
|
+
end
|
938
|
+
|
939
|
+
def node_class_declarations
|
940
|
+
elements[2]
|
941
|
+
end
|
942
|
+
end
|
943
|
+
|
944
|
+
module Primary4
|
945
|
+
def compile(address, builder)
|
946
|
+
atomic.compile(address, builder, self)
|
947
|
+
end
|
948
|
+
|
949
|
+
def node_class
|
950
|
+
node_class_declarations.node_class
|
951
|
+
end
|
952
|
+
|
953
|
+
def inline_modules
|
954
|
+
atomic.inline_modules + node_class_declarations.inline_modules
|
955
|
+
end
|
956
|
+
|
957
|
+
def inline_module_name
|
958
|
+
node_class_declarations.inline_module_name
|
959
|
+
end
|
960
|
+
end
|
961
|
+
|
962
|
+
module Primary5
|
963
|
+
def atomic
|
964
|
+
elements[0]
|
965
|
+
end
|
966
|
+
|
967
|
+
def node_class_declarations
|
968
|
+
elements[1]
|
969
|
+
end
|
970
|
+
end
|
971
|
+
|
972
|
+
def _nt_primary
|
973
|
+
start_index = index
|
974
|
+
cached = node_cache[:primary][index]
|
975
|
+
if cached
|
976
|
+
@index = cached.interval.end
|
977
|
+
return cached
|
978
|
+
end
|
979
|
+
|
980
|
+
i0, nr0 = index, []
|
981
|
+
i1, s1, nr1 = index, [], []
|
982
|
+
r2 = _nt_prefix
|
983
|
+
s1 << r2
|
984
|
+
if r2.success?
|
985
|
+
r3 = _nt_atomic
|
986
|
+
s1 << r3
|
987
|
+
end
|
988
|
+
if s1.last.success?
|
989
|
+
r1 = (SyntaxNode).new(input, i1...index, s1)
|
990
|
+
r1.extend(Primary1)
|
991
|
+
r1.extend(Primary0)
|
992
|
+
else
|
993
|
+
self.index = i1
|
994
|
+
r1 = ParseFailure.new(input, i1, s1)
|
995
|
+
end
|
996
|
+
nr0 << r1
|
997
|
+
if r1.success?
|
998
|
+
r0 = r1
|
999
|
+
r1.update_nested_results(nr0)
|
1000
|
+
else
|
1001
|
+
i4, s4, nr4 = index, [], []
|
1002
|
+
r5 = _nt_atomic
|
1003
|
+
s4 << r5
|
1004
|
+
if r5.success?
|
1005
|
+
r6 = _nt_suffix
|
1006
|
+
s4 << r6
|
1007
|
+
if r6.success?
|
1008
|
+
r7 = _nt_node_class_declarations
|
1009
|
+
s4 << r7
|
1010
|
+
end
|
1011
|
+
end
|
1012
|
+
if s4.last.success?
|
1013
|
+
r4 = (SyntaxNode).new(input, i4...index, s4)
|
1014
|
+
r4.extend(Primary3)
|
1015
|
+
r4.extend(Primary2)
|
1016
|
+
else
|
1017
|
+
self.index = i4
|
1018
|
+
r4 = ParseFailure.new(input, i4, s4)
|
1019
|
+
end
|
1020
|
+
nr0 << r4
|
1021
|
+
if r4.success?
|
1022
|
+
r0 = r4
|
1023
|
+
r4.update_nested_results(nr0)
|
1024
|
+
else
|
1025
|
+
i8, s8, nr8 = index, [], []
|
1026
|
+
r9 = _nt_atomic
|
1027
|
+
s8 << r9
|
1028
|
+
if r9.success?
|
1029
|
+
r10 = _nt_node_class_declarations
|
1030
|
+
s8 << r10
|
1031
|
+
end
|
1032
|
+
if s8.last.success?
|
1033
|
+
r8 = (SyntaxNode).new(input, i8...index, s8)
|
1034
|
+
r8.extend(Primary5)
|
1035
|
+
r8.extend(Primary4)
|
1036
|
+
else
|
1037
|
+
self.index = i8
|
1038
|
+
r8 = ParseFailure.new(input, i8, s8)
|
1039
|
+
end
|
1040
|
+
nr0 << r8
|
1041
|
+
if r8.success?
|
1042
|
+
r0 = r8
|
1043
|
+
r8.update_nested_results(nr0)
|
1044
|
+
else
|
1045
|
+
self.index = i0
|
1046
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
1047
|
+
end
|
1048
|
+
end
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
node_cache[:primary][start_index] = r0
|
1052
|
+
|
1053
|
+
return r0
|
1054
|
+
end
|
1055
|
+
|
1056
|
+
module LabeledSequencePrimary0
|
1057
|
+
def compile(lexical_address, builder)
|
1058
|
+
sequence_primary.compile(lexical_address, builder)
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
def inline_modules
|
1062
|
+
sequence_primary.inline_modules
|
1063
|
+
end
|
1064
|
+
|
1065
|
+
def label_name
|
1066
|
+
if label.name
|
1067
|
+
label.name
|
1068
|
+
elsif sequence_primary.instance_of?(Nonterminal)
|
1069
|
+
sequence_primary.text_value
|
1070
|
+
else
|
1071
|
+
nil
|
1072
|
+
end
|
1073
|
+
end
|
1074
|
+
end
|
1075
|
+
|
1076
|
+
module LabeledSequencePrimary1
|
1077
|
+
def label
|
1078
|
+
elements[0]
|
1079
|
+
end
|
1080
|
+
|
1081
|
+
def sequence_primary
|
1082
|
+
elements[1]
|
1083
|
+
end
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
def _nt_labeled_sequence_primary
|
1087
|
+
start_index = index
|
1088
|
+
cached = node_cache[:labeled_sequence_primary][index]
|
1089
|
+
if cached
|
1090
|
+
@index = cached.interval.end
|
1091
|
+
return cached
|
1092
|
+
end
|
1093
|
+
|
1094
|
+
i0, s0, nr0 = index, [], []
|
1095
|
+
r1 = _nt_label
|
1096
|
+
s0 << r1
|
1097
|
+
if r1.success?
|
1098
|
+
r2 = _nt_sequence_primary
|
1099
|
+
s0 << r2
|
1100
|
+
end
|
1101
|
+
if s0.last.success?
|
1102
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
1103
|
+
r0.extend(LabeledSequencePrimary1)
|
1104
|
+
r0.extend(LabeledSequencePrimary0)
|
1105
|
+
else
|
1106
|
+
self.index = i0
|
1107
|
+
r0 = ParseFailure.new(input, i0, s0)
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
node_cache[:labeled_sequence_primary][start_index] = r0
|
1111
|
+
|
1112
|
+
return r0
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
module Label0
|
1116
|
+
def alpha_char
|
1117
|
+
elements[0]
|
1118
|
+
end
|
1119
|
+
|
1120
|
+
end
|
1121
|
+
|
1122
|
+
module Label1
|
1123
|
+
def name
|
1124
|
+
elements[0].text_value
|
1125
|
+
end
|
1126
|
+
end
|
1127
|
+
|
1128
|
+
module Label2
|
1129
|
+
end
|
1130
|
+
|
1131
|
+
module Label3
|
1132
|
+
def name
|
1133
|
+
nil
|
1134
|
+
end
|
1135
|
+
end
|
1136
|
+
|
1137
|
+
def _nt_label
|
1138
|
+
start_index = index
|
1139
|
+
cached = node_cache[:label][index]
|
1140
|
+
if cached
|
1141
|
+
@index = cached.interval.end
|
1142
|
+
return cached
|
1143
|
+
end
|
1144
|
+
|
1145
|
+
i0, nr0 = index, []
|
1146
|
+
i1, s1, nr1 = index, [], []
|
1147
|
+
i2, s2, nr2 = index, [], []
|
1148
|
+
r3 = _nt_alpha_char
|
1149
|
+
s2 << r3
|
1150
|
+
if r3.success?
|
1151
|
+
s4, nr4, i4 = [], [], index
|
1152
|
+
loop do
|
1153
|
+
r5 = _nt_alphanumeric_char
|
1154
|
+
nr4 << r5
|
1155
|
+
if r5.success?
|
1156
|
+
s4 << r5
|
1157
|
+
else
|
1158
|
+
break
|
1159
|
+
end
|
1160
|
+
end
|
1161
|
+
r4 = SyntaxNode.new(input, i4...index, s4, nr4)
|
1162
|
+
s2 << r4
|
1163
|
+
end
|
1164
|
+
if s2.last.success?
|
1165
|
+
r2 = (SyntaxNode).new(input, i2...index, s2)
|
1166
|
+
r2.extend(Label0)
|
1167
|
+
else
|
1168
|
+
self.index = i2
|
1169
|
+
r2 = ParseFailure.new(input, i2, s2)
|
1170
|
+
end
|
1171
|
+
s1 << r2
|
1172
|
+
if r2.success?
|
1173
|
+
r6 = parse_terminal(':', SyntaxNode)
|
1174
|
+
s1 << r6
|
1175
|
+
end
|
1176
|
+
if s1.last.success?
|
1177
|
+
r1 = (SyntaxNode).new(input, i1...index, s1)
|
1178
|
+
r1.extend(Label2)
|
1179
|
+
r1.extend(Label1)
|
1180
|
+
else
|
1181
|
+
self.index = i1
|
1182
|
+
r1 = ParseFailure.new(input, i1, s1)
|
1183
|
+
end
|
1184
|
+
nr0 << r1
|
1185
|
+
if r1.success?
|
1186
|
+
r0 = r1
|
1187
|
+
r1.update_nested_results(nr0)
|
1188
|
+
else
|
1189
|
+
r7 = parse_terminal('', SyntaxNode, Label3)
|
1190
|
+
nr0 << r7
|
1191
|
+
if r7.success?
|
1192
|
+
r0 = r7
|
1193
|
+
r7.update_nested_results(nr0)
|
1194
|
+
else
|
1195
|
+
self.index = i0
|
1196
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
1197
|
+
end
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
node_cache[:label][start_index] = r0
|
1201
|
+
|
1202
|
+
return r0
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
module SequencePrimary0
|
1206
|
+
def compile(lexical_address, builder)
|
1207
|
+
prefix.compile(lexical_address, builder, self)
|
1208
|
+
end
|
1209
|
+
|
1210
|
+
def predicated_expression
|
1211
|
+
elements[1]
|
1212
|
+
end
|
1213
|
+
|
1214
|
+
def inline_modules
|
1215
|
+
atomic.inline_modules
|
1216
|
+
end
|
1217
|
+
|
1218
|
+
def inline_module_name
|
1219
|
+
nil
|
1220
|
+
end
|
1221
|
+
end
|
1222
|
+
|
1223
|
+
module SequencePrimary1
|
1224
|
+
def prefix
|
1225
|
+
elements[0]
|
1226
|
+
end
|
1227
|
+
|
1228
|
+
def atomic
|
1229
|
+
elements[1]
|
1230
|
+
end
|
1231
|
+
end
|
1232
|
+
|
1233
|
+
module SequencePrimary2
|
1234
|
+
def compile(lexical_address, builder)
|
1235
|
+
suffix.compile(lexical_address, builder, self)
|
1236
|
+
end
|
1237
|
+
|
1238
|
+
def node_class
|
1239
|
+
'SyntaxNode'
|
1240
|
+
end
|
1241
|
+
|
1242
|
+
def inline_modules
|
1243
|
+
atomic.inline_modules
|
1244
|
+
end
|
1245
|
+
|
1246
|
+
def inline_module_name
|
1247
|
+
nil
|
1248
|
+
end
|
1249
|
+
end
|
1250
|
+
|
1251
|
+
module SequencePrimary3
|
1252
|
+
def atomic
|
1253
|
+
elements[0]
|
1254
|
+
end
|
1255
|
+
|
1256
|
+
def suffix
|
1257
|
+
elements[1]
|
1258
|
+
end
|
1259
|
+
end
|
1260
|
+
|
1261
|
+
def _nt_sequence_primary
|
1262
|
+
start_index = index
|
1263
|
+
cached = node_cache[:sequence_primary][index]
|
1264
|
+
if cached
|
1265
|
+
@index = cached.interval.end
|
1266
|
+
return cached
|
1267
|
+
end
|
1268
|
+
|
1269
|
+
i0, nr0 = index, []
|
1270
|
+
i1, s1, nr1 = index, [], []
|
1271
|
+
r2 = _nt_prefix
|
1272
|
+
s1 << r2
|
1273
|
+
if r2.success?
|
1274
|
+
r3 = _nt_atomic
|
1275
|
+
s1 << r3
|
1276
|
+
end
|
1277
|
+
if s1.last.success?
|
1278
|
+
r1 = (SyntaxNode).new(input, i1...index, s1)
|
1279
|
+
r1.extend(SequencePrimary1)
|
1280
|
+
r1.extend(SequencePrimary0)
|
1281
|
+
else
|
1282
|
+
self.index = i1
|
1283
|
+
r1 = ParseFailure.new(input, i1, s1)
|
1284
|
+
end
|
1285
|
+
nr0 << r1
|
1286
|
+
if r1.success?
|
1287
|
+
r0 = r1
|
1288
|
+
r1.update_nested_results(nr0)
|
1289
|
+
else
|
1290
|
+
i4, s4, nr4 = index, [], []
|
1291
|
+
r5 = _nt_atomic
|
1292
|
+
s4 << r5
|
1293
|
+
if r5.success?
|
1294
|
+
r6 = _nt_suffix
|
1295
|
+
s4 << r6
|
1296
|
+
end
|
1297
|
+
if s4.last.success?
|
1298
|
+
r4 = (SyntaxNode).new(input, i4...index, s4)
|
1299
|
+
r4.extend(SequencePrimary3)
|
1300
|
+
r4.extend(SequencePrimary2)
|
1301
|
+
else
|
1302
|
+
self.index = i4
|
1303
|
+
r4 = ParseFailure.new(input, i4, s4)
|
1304
|
+
end
|
1305
|
+
nr0 << r4
|
1306
|
+
if r4.success?
|
1307
|
+
r0 = r4
|
1308
|
+
r4.update_nested_results(nr0)
|
1309
|
+
else
|
1310
|
+
r7 = _nt_atomic
|
1311
|
+
nr0 << r7
|
1312
|
+
if r7.success?
|
1313
|
+
r0 = r7
|
1314
|
+
r7.update_nested_results(nr0)
|
1315
|
+
else
|
1316
|
+
self.index = i0
|
1317
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
1318
|
+
end
|
1319
|
+
end
|
1320
|
+
end
|
1321
|
+
|
1322
|
+
node_cache[:sequence_primary][start_index] = r0
|
1323
|
+
|
1324
|
+
return r0
|
1325
|
+
end
|
1326
|
+
|
1327
|
+
def _nt_suffix
|
1328
|
+
start_index = index
|
1329
|
+
cached = node_cache[:suffix][index]
|
1330
|
+
if cached
|
1331
|
+
@index = cached.interval.end
|
1332
|
+
return cached
|
1333
|
+
end
|
1334
|
+
|
1335
|
+
i0, nr0 = index, []
|
1336
|
+
r1 = _nt_repetition_suffix
|
1337
|
+
nr0 << r1
|
1338
|
+
if r1.success?
|
1339
|
+
r0 = r1
|
1340
|
+
r1.update_nested_results(nr0)
|
1341
|
+
else
|
1342
|
+
r2 = _nt_optional_suffix
|
1343
|
+
nr0 << r2
|
1344
|
+
if r2.success?
|
1345
|
+
r0 = r2
|
1346
|
+
r2.update_nested_results(nr0)
|
1347
|
+
else
|
1348
|
+
self.index = i0
|
1349
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
1350
|
+
end
|
1351
|
+
end
|
1352
|
+
|
1353
|
+
node_cache[:suffix][start_index] = r0
|
1354
|
+
|
1355
|
+
return r0
|
1356
|
+
end
|
1357
|
+
|
1358
|
+
def _nt_optional_suffix
|
1359
|
+
start_index = index
|
1360
|
+
cached = node_cache[:optional_suffix][index]
|
1361
|
+
if cached
|
1362
|
+
@index = cached.interval.end
|
1363
|
+
return cached
|
1364
|
+
end
|
1365
|
+
|
1366
|
+
r0 = parse_terminal('?', Optional)
|
1367
|
+
|
1368
|
+
node_cache[:optional_suffix][start_index] = r0
|
1369
|
+
|
1370
|
+
return r0
|
1371
|
+
end
|
1372
|
+
|
1373
|
+
module NodeClassDeclarations0
|
1374
|
+
def node_class
|
1375
|
+
node_class_expression.node_class
|
1376
|
+
end
|
1377
|
+
|
1378
|
+
def inline_modules
|
1379
|
+
trailing_inline_module.inline_modules
|
1380
|
+
end
|
1381
|
+
|
1382
|
+
def inline_module
|
1383
|
+
trailing_inline_module.inline_module
|
1384
|
+
end
|
1385
|
+
|
1386
|
+
def inline_module_name
|
1387
|
+
inline_module.module_name if inline_module
|
1388
|
+
end
|
1389
|
+
end
|
1390
|
+
|
1391
|
+
module NodeClassDeclarations1
|
1392
|
+
def node_class_expression
|
1393
|
+
elements[0]
|
1394
|
+
end
|
1395
|
+
|
1396
|
+
def trailing_inline_module
|
1397
|
+
elements[1]
|
1398
|
+
end
|
1399
|
+
end
|
1400
|
+
|
1401
|
+
def _nt_node_class_declarations
|
1402
|
+
start_index = index
|
1403
|
+
cached = node_cache[:node_class_declarations][index]
|
1404
|
+
if cached
|
1405
|
+
@index = cached.interval.end
|
1406
|
+
return cached
|
1407
|
+
end
|
1408
|
+
|
1409
|
+
i0, s0, nr0 = index, [], []
|
1410
|
+
r1 = _nt_node_class_expression
|
1411
|
+
s0 << r1
|
1412
|
+
if r1.success?
|
1413
|
+
r2 = _nt_trailing_inline_module
|
1414
|
+
s0 << r2
|
1415
|
+
end
|
1416
|
+
if s0.last.success?
|
1417
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
1418
|
+
r0.extend(NodeClassDeclarations1)
|
1419
|
+
r0.extend(NodeClassDeclarations0)
|
1420
|
+
else
|
1421
|
+
self.index = i0
|
1422
|
+
r0 = ParseFailure.new(input, i0, s0)
|
1423
|
+
end
|
1424
|
+
|
1425
|
+
node_cache[:node_class_declarations][start_index] = r0
|
1426
|
+
|
1427
|
+
return r0
|
1428
|
+
end
|
1429
|
+
|
1430
|
+
def _nt_repetition_suffix
|
1431
|
+
start_index = index
|
1432
|
+
cached = node_cache[:repetition_suffix][index]
|
1433
|
+
if cached
|
1434
|
+
@index = cached.interval.end
|
1435
|
+
return cached
|
1436
|
+
end
|
1437
|
+
|
1438
|
+
i0, nr0 = index, []
|
1439
|
+
r1 = parse_terminal('+', OneOrMore)
|
1440
|
+
nr0 << r1
|
1441
|
+
if r1.success?
|
1442
|
+
r0 = r1
|
1443
|
+
r1.update_nested_results(nr0)
|
1444
|
+
else
|
1445
|
+
r2 = parse_terminal('*', ZeroOrMore)
|
1446
|
+
nr0 << r2
|
1447
|
+
if r2.success?
|
1448
|
+
r0 = r2
|
1449
|
+
r2.update_nested_results(nr0)
|
1450
|
+
else
|
1451
|
+
self.index = i0
|
1452
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
1453
|
+
end
|
1454
|
+
end
|
1455
|
+
|
1456
|
+
node_cache[:repetition_suffix][start_index] = r0
|
1457
|
+
|
1458
|
+
return r0
|
1459
|
+
end
|
1460
|
+
|
1461
|
+
def _nt_prefix
|
1462
|
+
start_index = index
|
1463
|
+
cached = node_cache[:prefix][index]
|
1464
|
+
if cached
|
1465
|
+
@index = cached.interval.end
|
1466
|
+
return cached
|
1467
|
+
end
|
1468
|
+
|
1469
|
+
i0, nr0 = index, []
|
1470
|
+
r1 = parse_terminal('&', AndPredicate)
|
1471
|
+
nr0 << r1
|
1472
|
+
if r1.success?
|
1473
|
+
r0 = r1
|
1474
|
+
r1.update_nested_results(nr0)
|
1475
|
+
else
|
1476
|
+
r2 = parse_terminal('!', NotPredicate)
|
1477
|
+
nr0 << r2
|
1478
|
+
if r2.success?
|
1479
|
+
r0 = r2
|
1480
|
+
r2.update_nested_results(nr0)
|
1481
|
+
else
|
1482
|
+
self.index = i0
|
1483
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
1484
|
+
end
|
1485
|
+
end
|
1486
|
+
|
1487
|
+
node_cache[:prefix][start_index] = r0
|
1488
|
+
|
1489
|
+
return r0
|
1490
|
+
end
|
1491
|
+
|
1492
|
+
def _nt_atomic
|
1493
|
+
start_index = index
|
1494
|
+
cached = node_cache[:atomic][index]
|
1495
|
+
if cached
|
1496
|
+
@index = cached.interval.end
|
1497
|
+
return cached
|
1498
|
+
end
|
1499
|
+
|
1500
|
+
i0, nr0 = index, []
|
1501
|
+
r1 = _nt_terminal
|
1502
|
+
nr0 << r1
|
1503
|
+
if r1.success?
|
1504
|
+
r0 = r1
|
1505
|
+
r1.update_nested_results(nr0)
|
1506
|
+
else
|
1507
|
+
r2 = _nt_nonterminal
|
1508
|
+
nr0 << r2
|
1509
|
+
if r2.success?
|
1510
|
+
r0 = r2
|
1511
|
+
r2.update_nested_results(nr0)
|
1512
|
+
else
|
1513
|
+
r3 = _nt_parenthesized_expression
|
1514
|
+
nr0 << r3
|
1515
|
+
if r3.success?
|
1516
|
+
r0 = r3
|
1517
|
+
r3.update_nested_results(nr0)
|
1518
|
+
else
|
1519
|
+
self.index = i0
|
1520
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
1521
|
+
end
|
1522
|
+
end
|
1523
|
+
end
|
1524
|
+
|
1525
|
+
node_cache[:atomic][start_index] = r0
|
1526
|
+
|
1527
|
+
return r0
|
1528
|
+
end
|
1529
|
+
|
1530
|
+
module ParenthesizedExpression0
|
1531
|
+
def inline_modules
|
1532
|
+
parsing_expression.inline_modules
|
1533
|
+
end
|
1534
|
+
end
|
1535
|
+
|
1536
|
+
module ParenthesizedExpression1
|
1537
|
+
def parsing_expression
|
1538
|
+
elements[2]
|
1539
|
+
end
|
1540
|
+
|
1541
|
+
end
|
1542
|
+
|
1543
|
+
def _nt_parenthesized_expression
|
1544
|
+
start_index = index
|
1545
|
+
cached = node_cache[:parenthesized_expression][index]
|
1546
|
+
if cached
|
1547
|
+
@index = cached.interval.end
|
1548
|
+
return cached
|
1549
|
+
end
|
1550
|
+
|
1551
|
+
i0, s0, nr0 = index, [], []
|
1552
|
+
r1 = parse_terminal('(', SyntaxNode)
|
1553
|
+
s0 << r1
|
1554
|
+
if r1.success?
|
1555
|
+
r3 = _nt_space
|
1556
|
+
if r3.success?
|
1557
|
+
r2 = r3
|
1558
|
+
else
|
1559
|
+
r2 = SyntaxNode.new(input, index...index, r3.nested_failures)
|
1560
|
+
end
|
1561
|
+
s0 << r2
|
1562
|
+
if r2.success?
|
1563
|
+
r4 = _nt_parsing_expression
|
1564
|
+
s0 << r4
|
1565
|
+
if r4.success?
|
1566
|
+
r6 = _nt_space
|
1567
|
+
if r6.success?
|
1568
|
+
r5 = r6
|
1569
|
+
else
|
1570
|
+
r5 = SyntaxNode.new(input, index...index, r6.nested_failures)
|
1571
|
+
end
|
1572
|
+
s0 << r5
|
1573
|
+
if r5.success?
|
1574
|
+
r7 = parse_terminal(')', SyntaxNode)
|
1575
|
+
s0 << r7
|
1576
|
+
end
|
1577
|
+
end
|
1578
|
+
end
|
1579
|
+
end
|
1580
|
+
if s0.last.success?
|
1581
|
+
r0 = (ParenthesizedExpression).new(input, i0...index, s0)
|
1582
|
+
r0.extend(ParenthesizedExpression1)
|
1583
|
+
r0.extend(ParenthesizedExpression0)
|
1584
|
+
else
|
1585
|
+
self.index = i0
|
1586
|
+
r0 = ParseFailure.new(input, i0, s0)
|
1587
|
+
end
|
1588
|
+
|
1589
|
+
node_cache[:parenthesized_expression][start_index] = r0
|
1590
|
+
|
1591
|
+
return r0
|
1592
|
+
end
|
1593
|
+
|
1594
|
+
module Nonterminal0
|
1595
|
+
def alpha_char
|
1596
|
+
elements[0]
|
1597
|
+
end
|
1598
|
+
|
1599
|
+
end
|
1600
|
+
|
1601
|
+
module Nonterminal1
|
1602
|
+
end
|
1603
|
+
|
1604
|
+
def _nt_nonterminal
|
1605
|
+
start_index = index
|
1606
|
+
cached = node_cache[:nonterminal][index]
|
1607
|
+
if cached
|
1608
|
+
@index = cached.interval.end
|
1609
|
+
return cached
|
1610
|
+
end
|
1611
|
+
|
1612
|
+
i0, s0, nr0 = index, [], []
|
1613
|
+
i1 = index
|
1614
|
+
r2 = _nt_keyword_inside_grammar
|
1615
|
+
if r2.success?
|
1616
|
+
r1 = ParseFailure.new(input, i1, r2.nested_failures)
|
1617
|
+
else
|
1618
|
+
self.index = i1
|
1619
|
+
r1 = SyntaxNode.new(input, index...index, r2.nested_failures)
|
1620
|
+
end
|
1621
|
+
s0 << r1
|
1622
|
+
if r1.success?
|
1623
|
+
i3, s3, nr3 = index, [], []
|
1624
|
+
r4 = _nt_alpha_char
|
1625
|
+
s3 << r4
|
1626
|
+
if r4.success?
|
1627
|
+
s5, nr5, i5 = [], [], index
|
1628
|
+
loop do
|
1629
|
+
r6 = _nt_alphanumeric_char
|
1630
|
+
nr5 << r6
|
1631
|
+
if r6.success?
|
1632
|
+
s5 << r6
|
1633
|
+
else
|
1634
|
+
break
|
1635
|
+
end
|
1636
|
+
end
|
1637
|
+
r5 = SyntaxNode.new(input, i5...index, s5, nr5)
|
1638
|
+
s3 << r5
|
1639
|
+
end
|
1640
|
+
if s3.last.success?
|
1641
|
+
r3 = (SyntaxNode).new(input, i3...index, s3)
|
1642
|
+
r3.extend(Nonterminal0)
|
1643
|
+
else
|
1644
|
+
self.index = i3
|
1645
|
+
r3 = ParseFailure.new(input, i3, s3)
|
1646
|
+
end
|
1647
|
+
s0 << r3
|
1648
|
+
end
|
1649
|
+
if s0.last.success?
|
1650
|
+
r0 = (Nonterminal).new(input, i0...index, s0)
|
1651
|
+
r0.extend(Nonterminal1)
|
1652
|
+
else
|
1653
|
+
self.index = i0
|
1654
|
+
r0 = ParseFailure.new(input, i0, s0)
|
1655
|
+
end
|
1656
|
+
|
1657
|
+
node_cache[:nonterminal][start_index] = r0
|
1658
|
+
|
1659
|
+
return r0
|
1660
|
+
end
|
1661
|
+
|
1662
|
+
def _nt_terminal
|
1663
|
+
start_index = index
|
1664
|
+
cached = node_cache[:terminal][index]
|
1665
|
+
if cached
|
1666
|
+
@index = cached.interval.end
|
1667
|
+
return cached
|
1668
|
+
end
|
1669
|
+
|
1670
|
+
i0, nr0 = index, []
|
1671
|
+
r1 = _nt_single_quoted_string
|
1672
|
+
nr0 << r1
|
1673
|
+
if r1.success?
|
1674
|
+
r0 = r1
|
1675
|
+
r1.update_nested_results(nr0)
|
1676
|
+
else
|
1677
|
+
r2 = _nt_double_quoted_string
|
1678
|
+
nr0 << r2
|
1679
|
+
if r2.success?
|
1680
|
+
r0 = r2
|
1681
|
+
r2.update_nested_results(nr0)
|
1682
|
+
else
|
1683
|
+
r3 = _nt_character_class
|
1684
|
+
nr0 << r3
|
1685
|
+
if r3.success?
|
1686
|
+
r0 = r3
|
1687
|
+
r3.update_nested_results(nr0)
|
1688
|
+
else
|
1689
|
+
r4 = _nt_anything_symbol
|
1690
|
+
nr0 << r4
|
1691
|
+
if r4.success?
|
1692
|
+
r0 = r4
|
1693
|
+
r4.update_nested_results(nr0)
|
1694
|
+
else
|
1695
|
+
self.index = i0
|
1696
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
1697
|
+
end
|
1698
|
+
end
|
1699
|
+
end
|
1700
|
+
end
|
1701
|
+
|
1702
|
+
node_cache[:terminal][start_index] = r0
|
1703
|
+
|
1704
|
+
return r0
|
1705
|
+
end
|
1706
|
+
|
1707
|
+
module DoubleQuotedString0
|
1708
|
+
end
|
1709
|
+
|
1710
|
+
module DoubleQuotedString1
|
1711
|
+
end
|
1712
|
+
|
1713
|
+
def _nt_double_quoted_string
|
1714
|
+
start_index = index
|
1715
|
+
cached = node_cache[:double_quoted_string][index]
|
1716
|
+
if cached
|
1717
|
+
@index = cached.interval.end
|
1718
|
+
return cached
|
1719
|
+
end
|
1720
|
+
|
1721
|
+
i0, s0, nr0 = index, [], []
|
1722
|
+
r1 = parse_terminal('"', SyntaxNode)
|
1723
|
+
s0 << r1
|
1724
|
+
if r1.success?
|
1725
|
+
s2, nr2, i2 = [], [], index
|
1726
|
+
loop do
|
1727
|
+
i3, s3, nr3 = index, [], []
|
1728
|
+
i4 = index
|
1729
|
+
r5 = parse_terminal('"', SyntaxNode)
|
1730
|
+
if r5.success?
|
1731
|
+
r4 = ParseFailure.new(input, i4, r5.nested_failures)
|
1732
|
+
else
|
1733
|
+
self.index = i4
|
1734
|
+
r4 = SyntaxNode.new(input, index...index, r5.nested_failures)
|
1735
|
+
end
|
1736
|
+
s3 << r4
|
1737
|
+
if r4.success?
|
1738
|
+
i6, nr6 = index, []
|
1739
|
+
r7 = parse_terminal("\\\\", SyntaxNode)
|
1740
|
+
nr6 << r7
|
1741
|
+
if r7.success?
|
1742
|
+
r6 = r7
|
1743
|
+
r7.update_nested_results(nr6)
|
1744
|
+
else
|
1745
|
+
r8 = parse_terminal('\"', SyntaxNode)
|
1746
|
+
nr6 << r8
|
1747
|
+
if r8.success?
|
1748
|
+
r6 = r8
|
1749
|
+
r8.update_nested_results(nr6)
|
1750
|
+
else
|
1751
|
+
r9 = parse_anything(SyntaxNode)
|
1752
|
+
nr6 << r9
|
1753
|
+
if r9.success?
|
1754
|
+
r6 = r9
|
1755
|
+
r9.update_nested_results(nr6)
|
1756
|
+
else
|
1757
|
+
self.index = i6
|
1758
|
+
r6 = ParseFailure.new(input, i6, nr6)
|
1759
|
+
end
|
1760
|
+
end
|
1761
|
+
end
|
1762
|
+
s3 << r6
|
1763
|
+
end
|
1764
|
+
if s3.last.success?
|
1765
|
+
r3 = (SyntaxNode).new(input, i3...index, s3)
|
1766
|
+
r3.extend(DoubleQuotedString0)
|
1767
|
+
else
|
1768
|
+
self.index = i3
|
1769
|
+
r3 = ParseFailure.new(input, i3, s3)
|
1770
|
+
end
|
1771
|
+
nr2 << r3
|
1772
|
+
if r3.success?
|
1773
|
+
s2 << r3
|
1774
|
+
else
|
1775
|
+
break
|
1776
|
+
end
|
1777
|
+
end
|
1778
|
+
r2 = SyntaxNode.new(input, i2...index, s2, nr2)
|
1779
|
+
s0 << r2
|
1780
|
+
if r2.success?
|
1781
|
+
r10 = parse_terminal('"', SyntaxNode)
|
1782
|
+
s0 << r10
|
1783
|
+
end
|
1784
|
+
end
|
1785
|
+
if s0.last.success?
|
1786
|
+
r0 = (Terminal).new(input, i0...index, s0)
|
1787
|
+
r0.extend(DoubleQuotedString1)
|
1788
|
+
else
|
1789
|
+
self.index = i0
|
1790
|
+
r0 = ParseFailure.new(input, i0, s0)
|
1791
|
+
end
|
1792
|
+
|
1793
|
+
node_cache[:double_quoted_string][start_index] = r0
|
1794
|
+
|
1795
|
+
return r0
|
1796
|
+
end
|
1797
|
+
|
1798
|
+
module SingleQuotedString0
|
1799
|
+
end
|
1800
|
+
|
1801
|
+
module SingleQuotedString1
|
1802
|
+
end
|
1803
|
+
|
1804
|
+
def _nt_single_quoted_string
|
1805
|
+
start_index = index
|
1806
|
+
cached = node_cache[:single_quoted_string][index]
|
1807
|
+
if cached
|
1808
|
+
@index = cached.interval.end
|
1809
|
+
return cached
|
1810
|
+
end
|
1811
|
+
|
1812
|
+
i0, s0, nr0 = index, [], []
|
1813
|
+
r1 = parse_terminal("'", SyntaxNode)
|
1814
|
+
s0 << r1
|
1815
|
+
if r1.success?
|
1816
|
+
s2, nr2, i2 = [], [], index
|
1817
|
+
loop do
|
1818
|
+
i3, s3, nr3 = index, [], []
|
1819
|
+
i4 = index
|
1820
|
+
r5 = parse_terminal("'", SyntaxNode)
|
1821
|
+
if r5.success?
|
1822
|
+
r4 = ParseFailure.new(input, i4, r5.nested_failures)
|
1823
|
+
else
|
1824
|
+
self.index = i4
|
1825
|
+
r4 = SyntaxNode.new(input, index...index, r5.nested_failures)
|
1826
|
+
end
|
1827
|
+
s3 << r4
|
1828
|
+
if r4.success?
|
1829
|
+
i6, nr6 = index, []
|
1830
|
+
r7 = parse_terminal("\\\\", SyntaxNode)
|
1831
|
+
nr6 << r7
|
1832
|
+
if r7.success?
|
1833
|
+
r6 = r7
|
1834
|
+
r7.update_nested_results(nr6)
|
1835
|
+
else
|
1836
|
+
r8 = parse_terminal("\\'", SyntaxNode)
|
1837
|
+
nr6 << r8
|
1838
|
+
if r8.success?
|
1839
|
+
r6 = r8
|
1840
|
+
r8.update_nested_results(nr6)
|
1841
|
+
else
|
1842
|
+
r9 = parse_anything(SyntaxNode)
|
1843
|
+
nr6 << r9
|
1844
|
+
if r9.success?
|
1845
|
+
r6 = r9
|
1846
|
+
r9.update_nested_results(nr6)
|
1847
|
+
else
|
1848
|
+
self.index = i6
|
1849
|
+
r6 = ParseFailure.new(input, i6, nr6)
|
1850
|
+
end
|
1851
|
+
end
|
1852
|
+
end
|
1853
|
+
s3 << r6
|
1854
|
+
end
|
1855
|
+
if s3.last.success?
|
1856
|
+
r3 = (SyntaxNode).new(input, i3...index, s3)
|
1857
|
+
r3.extend(SingleQuotedString0)
|
1858
|
+
else
|
1859
|
+
self.index = i3
|
1860
|
+
r3 = ParseFailure.new(input, i3, s3)
|
1861
|
+
end
|
1862
|
+
nr2 << r3
|
1863
|
+
if r3.success?
|
1864
|
+
s2 << r3
|
1865
|
+
else
|
1866
|
+
break
|
1867
|
+
end
|
1868
|
+
end
|
1869
|
+
r2 = SyntaxNode.new(input, i2...index, s2, nr2)
|
1870
|
+
s0 << r2
|
1871
|
+
if r2.success?
|
1872
|
+
r10 = parse_terminal("'", SyntaxNode)
|
1873
|
+
s0 << r10
|
1874
|
+
end
|
1875
|
+
end
|
1876
|
+
if s0.last.success?
|
1877
|
+
r0 = (Terminal).new(input, i0...index, s0)
|
1878
|
+
r0.extend(SingleQuotedString1)
|
1879
|
+
else
|
1880
|
+
self.index = i0
|
1881
|
+
r0 = ParseFailure.new(input, i0, s0)
|
1882
|
+
end
|
1883
|
+
|
1884
|
+
node_cache[:single_quoted_string][start_index] = r0
|
1885
|
+
|
1886
|
+
return r0
|
1887
|
+
end
|
1888
|
+
|
1889
|
+
module CharacterClass0
|
1890
|
+
end
|
1891
|
+
|
1892
|
+
module CharacterClass1
|
1893
|
+
end
|
1894
|
+
|
1895
|
+
def _nt_character_class
|
1896
|
+
start_index = index
|
1897
|
+
cached = node_cache[:character_class][index]
|
1898
|
+
if cached
|
1899
|
+
@index = cached.interval.end
|
1900
|
+
return cached
|
1901
|
+
end
|
1902
|
+
|
1903
|
+
i0, s0, nr0 = index, [], []
|
1904
|
+
r1 = parse_terminal('[', SyntaxNode)
|
1905
|
+
s0 << r1
|
1906
|
+
if r1.success?
|
1907
|
+
s2, nr2, i2 = [], [], index
|
1908
|
+
loop do
|
1909
|
+
i3, s3, nr3 = index, [], []
|
1910
|
+
i4 = index
|
1911
|
+
r5 = parse_terminal(']', SyntaxNode)
|
1912
|
+
if r5.success?
|
1913
|
+
r4 = ParseFailure.new(input, i4, r5.nested_failures)
|
1914
|
+
else
|
1915
|
+
self.index = i4
|
1916
|
+
r4 = SyntaxNode.new(input, index...index, r5.nested_failures)
|
1917
|
+
end
|
1918
|
+
s3 << r4
|
1919
|
+
if r4.success?
|
1920
|
+
i6, nr6 = index, []
|
1921
|
+
r7 = parse_terminal('\]', SyntaxNode)
|
1922
|
+
nr6 << r7
|
1923
|
+
if r7.success?
|
1924
|
+
r6 = r7
|
1925
|
+
r7.update_nested_results(nr6)
|
1926
|
+
else
|
1927
|
+
r8 = parse_anything(SyntaxNode)
|
1928
|
+
nr6 << r8
|
1929
|
+
if r8.success?
|
1930
|
+
r6 = r8
|
1931
|
+
r8.update_nested_results(nr6)
|
1932
|
+
else
|
1933
|
+
self.index = i6
|
1934
|
+
r6 = ParseFailure.new(input, i6, nr6)
|
1935
|
+
end
|
1936
|
+
end
|
1937
|
+
s3 << r6
|
1938
|
+
end
|
1939
|
+
if s3.last.success?
|
1940
|
+
r3 = (SyntaxNode).new(input, i3...index, s3)
|
1941
|
+
r3.extend(CharacterClass0)
|
1942
|
+
else
|
1943
|
+
self.index = i3
|
1944
|
+
r3 = ParseFailure.new(input, i3, s3)
|
1945
|
+
end
|
1946
|
+
nr2 << r3
|
1947
|
+
if r3.success?
|
1948
|
+
s2 << r3
|
1949
|
+
else
|
1950
|
+
break
|
1951
|
+
end
|
1952
|
+
end
|
1953
|
+
if s2.empty?
|
1954
|
+
self.index = i2
|
1955
|
+
r2 = ParseFailure.new(input, i2, nr2)
|
1956
|
+
else
|
1957
|
+
r2 = SyntaxNode.new(input, i2...index, s2, nr2)
|
1958
|
+
end
|
1959
|
+
s0 << r2
|
1960
|
+
if r2.success?
|
1961
|
+
r9 = parse_terminal(']', SyntaxNode)
|
1962
|
+
s0 << r9
|
1963
|
+
end
|
1964
|
+
end
|
1965
|
+
if s0.last.success?
|
1966
|
+
r0 = (CharacterClass).new(input, i0...index, s0)
|
1967
|
+
r0.extend(CharacterClass1)
|
1968
|
+
else
|
1969
|
+
self.index = i0
|
1970
|
+
r0 = ParseFailure.new(input, i0, s0)
|
1971
|
+
end
|
1972
|
+
|
1973
|
+
node_cache[:character_class][start_index] = r0
|
1974
|
+
|
1975
|
+
return r0
|
1976
|
+
end
|
1977
|
+
|
1978
|
+
def _nt_anything_symbol
|
1979
|
+
start_index = index
|
1980
|
+
cached = node_cache[:anything_symbol][index]
|
1981
|
+
if cached
|
1982
|
+
@index = cached.interval.end
|
1983
|
+
return cached
|
1984
|
+
end
|
1985
|
+
|
1986
|
+
r0 = parse_terminal('.', AnythingSymbol)
|
1987
|
+
|
1988
|
+
node_cache[:anything_symbol][start_index] = r0
|
1989
|
+
|
1990
|
+
return r0
|
1991
|
+
end
|
1992
|
+
|
1993
|
+
module NodeClassExpression0
|
1994
|
+
end
|
1995
|
+
|
1996
|
+
module NodeClassExpression1
|
1997
|
+
def node_class
|
1998
|
+
elements[2].text_value
|
1999
|
+
end
|
2000
|
+
end
|
2001
|
+
|
2002
|
+
module NodeClassExpression2
|
2003
|
+
def space
|
2004
|
+
elements[0]
|
2005
|
+
end
|
2006
|
+
|
2007
|
+
end
|
2008
|
+
|
2009
|
+
module NodeClassExpression3
|
2010
|
+
def node_class
|
2011
|
+
'SyntaxNode'
|
2012
|
+
end
|
2013
|
+
end
|
2014
|
+
|
2015
|
+
def _nt_node_class_expression
|
2016
|
+
start_index = index
|
2017
|
+
cached = node_cache[:node_class_expression][index]
|
2018
|
+
if cached
|
2019
|
+
@index = cached.interval.end
|
2020
|
+
return cached
|
2021
|
+
end
|
2022
|
+
|
2023
|
+
i0, nr0 = index, []
|
2024
|
+
i1, s1, nr1 = index, [], []
|
2025
|
+
r2 = _nt_space
|
2026
|
+
s1 << r2
|
2027
|
+
if r2.success?
|
2028
|
+
r3 = parse_terminal('<', SyntaxNode)
|
2029
|
+
s1 << r3
|
2030
|
+
if r3.success?
|
2031
|
+
s4, nr4, i4 = [], [], index
|
2032
|
+
loop do
|
2033
|
+
i5, s5, nr5 = index, [], []
|
2034
|
+
i6 = index
|
2035
|
+
r7 = parse_terminal('>', SyntaxNode)
|
2036
|
+
if r7.success?
|
2037
|
+
r6 = ParseFailure.new(input, i6, r7.nested_failures)
|
2038
|
+
else
|
2039
|
+
self.index = i6
|
2040
|
+
r6 = SyntaxNode.new(input, index...index, r7.nested_failures)
|
2041
|
+
end
|
2042
|
+
s5 << r6
|
2043
|
+
if r6.success?
|
2044
|
+
r8 = parse_anything(SyntaxNode)
|
2045
|
+
s5 << r8
|
2046
|
+
end
|
2047
|
+
if s5.last.success?
|
2048
|
+
r5 = (SyntaxNode).new(input, i5...index, s5)
|
2049
|
+
r5.extend(NodeClassExpression0)
|
2050
|
+
else
|
2051
|
+
self.index = i5
|
2052
|
+
r5 = ParseFailure.new(input, i5, s5)
|
2053
|
+
end
|
2054
|
+
nr4 << r5
|
2055
|
+
if r5.success?
|
2056
|
+
s4 << r5
|
2057
|
+
else
|
2058
|
+
break
|
2059
|
+
end
|
2060
|
+
end
|
2061
|
+
if s4.empty?
|
2062
|
+
self.index = i4
|
2063
|
+
r4 = ParseFailure.new(input, i4, nr4)
|
2064
|
+
else
|
2065
|
+
r4 = SyntaxNode.new(input, i4...index, s4, nr4)
|
2066
|
+
end
|
2067
|
+
s1 << r4
|
2068
|
+
if r4.success?
|
2069
|
+
r9 = parse_terminal('>', SyntaxNode)
|
2070
|
+
s1 << r9
|
2071
|
+
end
|
2072
|
+
end
|
2073
|
+
end
|
2074
|
+
if s1.last.success?
|
2075
|
+
r1 = (SyntaxNode).new(input, i1...index, s1)
|
2076
|
+
r1.extend(NodeClassExpression2)
|
2077
|
+
r1.extend(NodeClassExpression1)
|
2078
|
+
else
|
2079
|
+
self.index = i1
|
2080
|
+
r1 = ParseFailure.new(input, i1, s1)
|
2081
|
+
end
|
2082
|
+
nr0 << r1
|
2083
|
+
if r1.success?
|
2084
|
+
r0 = r1
|
2085
|
+
r1.update_nested_results(nr0)
|
2086
|
+
else
|
2087
|
+
r10 = parse_terminal('', SyntaxNode, NodeClassExpression3)
|
2088
|
+
nr0 << r10
|
2089
|
+
if r10.success?
|
2090
|
+
r0 = r10
|
2091
|
+
r10.update_nested_results(nr0)
|
2092
|
+
else
|
2093
|
+
self.index = i0
|
2094
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
2095
|
+
end
|
2096
|
+
end
|
2097
|
+
|
2098
|
+
node_cache[:node_class_expression][start_index] = r0
|
2099
|
+
|
2100
|
+
return r0
|
2101
|
+
end
|
2102
|
+
|
2103
|
+
module TrailingInlineModule0
|
2104
|
+
def inline_modules
|
2105
|
+
[inline_module]
|
2106
|
+
end
|
2107
|
+
|
2108
|
+
def inline_module_name
|
2109
|
+
inline_module.module_name
|
2110
|
+
end
|
2111
|
+
end
|
2112
|
+
|
2113
|
+
module TrailingInlineModule1
|
2114
|
+
def space
|
2115
|
+
elements[0]
|
2116
|
+
end
|
2117
|
+
|
2118
|
+
def inline_module
|
2119
|
+
elements[1]
|
2120
|
+
end
|
2121
|
+
end
|
2122
|
+
|
2123
|
+
module TrailingInlineModule2
|
2124
|
+
def inline_modules
|
2125
|
+
[]
|
2126
|
+
end
|
2127
|
+
|
2128
|
+
def inline_module
|
2129
|
+
nil
|
2130
|
+
end
|
2131
|
+
|
2132
|
+
def inline_module_name
|
2133
|
+
nil
|
2134
|
+
end
|
2135
|
+
end
|
2136
|
+
|
2137
|
+
def _nt_trailing_inline_module
|
2138
|
+
start_index = index
|
2139
|
+
cached = node_cache[:trailing_inline_module][index]
|
2140
|
+
if cached
|
2141
|
+
@index = cached.interval.end
|
2142
|
+
return cached
|
2143
|
+
end
|
2144
|
+
|
2145
|
+
i0, nr0 = index, []
|
2146
|
+
i1, s1, nr1 = index, [], []
|
2147
|
+
r2 = _nt_space
|
2148
|
+
s1 << r2
|
2149
|
+
if r2.success?
|
2150
|
+
r3 = _nt_inline_module
|
2151
|
+
s1 << r3
|
2152
|
+
end
|
2153
|
+
if s1.last.success?
|
2154
|
+
r1 = (SyntaxNode).new(input, i1...index, s1)
|
2155
|
+
r1.extend(TrailingInlineModule1)
|
2156
|
+
r1.extend(TrailingInlineModule0)
|
2157
|
+
else
|
2158
|
+
self.index = i1
|
2159
|
+
r1 = ParseFailure.new(input, i1, s1)
|
2160
|
+
end
|
2161
|
+
nr0 << r1
|
2162
|
+
if r1.success?
|
2163
|
+
r0 = r1
|
2164
|
+
r1.update_nested_results(nr0)
|
2165
|
+
else
|
2166
|
+
r4 = parse_terminal('', SyntaxNode, TrailingInlineModule2)
|
2167
|
+
nr0 << r4
|
2168
|
+
if r4.success?
|
2169
|
+
r0 = r4
|
2170
|
+
r4.update_nested_results(nr0)
|
2171
|
+
else
|
2172
|
+
self.index = i0
|
2173
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
2174
|
+
end
|
2175
|
+
end
|
2176
|
+
|
2177
|
+
node_cache[:trailing_inline_module][start_index] = r0
|
2178
|
+
|
2179
|
+
return r0
|
2180
|
+
end
|
2181
|
+
|
2182
|
+
module InlineModule0
|
2183
|
+
end
|
2184
|
+
|
2185
|
+
module InlineModule1
|
2186
|
+
end
|
2187
|
+
|
2188
|
+
def _nt_inline_module
|
2189
|
+
start_index = index
|
2190
|
+
cached = node_cache[:inline_module][index]
|
2191
|
+
if cached
|
2192
|
+
@index = cached.interval.end
|
2193
|
+
return cached
|
2194
|
+
end
|
2195
|
+
|
2196
|
+
i0, s0, nr0 = index, [], []
|
2197
|
+
r1 = parse_terminal('{', SyntaxNode)
|
2198
|
+
s0 << r1
|
2199
|
+
if r1.success?
|
2200
|
+
s2, nr2, i2 = [], [], index
|
2201
|
+
loop do
|
2202
|
+
i3, nr3 = index, []
|
2203
|
+
r4 = _nt_inline_module
|
2204
|
+
nr3 << r4
|
2205
|
+
if r4.success?
|
2206
|
+
r3 = r4
|
2207
|
+
r4.update_nested_results(nr3)
|
2208
|
+
else
|
2209
|
+
i5, s5, nr5 = index, [], []
|
2210
|
+
i6 = index
|
2211
|
+
r7 = parse_char_class(/[{}]/, '{}', SyntaxNode)
|
2212
|
+
if r7.success?
|
2213
|
+
r6 = ParseFailure.new(input, i6, r7.nested_failures)
|
2214
|
+
else
|
2215
|
+
self.index = i6
|
2216
|
+
r6 = SyntaxNode.new(input, index...index, r7.nested_failures)
|
2217
|
+
end
|
2218
|
+
s5 << r6
|
2219
|
+
if r6.success?
|
2220
|
+
r8 = parse_anything(SyntaxNode)
|
2221
|
+
s5 << r8
|
2222
|
+
end
|
2223
|
+
if s5.last.success?
|
2224
|
+
r5 = (SyntaxNode).new(input, i5...index, s5)
|
2225
|
+
r5.extend(InlineModule0)
|
2226
|
+
else
|
2227
|
+
self.index = i5
|
2228
|
+
r5 = ParseFailure.new(input, i5, s5)
|
2229
|
+
end
|
2230
|
+
nr3 << r5
|
2231
|
+
if r5.success?
|
2232
|
+
r3 = r5
|
2233
|
+
r5.update_nested_results(nr3)
|
2234
|
+
else
|
2235
|
+
self.index = i3
|
2236
|
+
r3 = ParseFailure.new(input, i3, nr3)
|
2237
|
+
end
|
2238
|
+
end
|
2239
|
+
nr2 << r3
|
2240
|
+
if r3.success?
|
2241
|
+
s2 << r3
|
2242
|
+
else
|
2243
|
+
break
|
2244
|
+
end
|
2245
|
+
end
|
2246
|
+
r2 = SyntaxNode.new(input, i2...index, s2, nr2)
|
2247
|
+
s0 << r2
|
2248
|
+
if r2.success?
|
2249
|
+
r9 = parse_terminal('}', SyntaxNode)
|
2250
|
+
s0 << r9
|
2251
|
+
end
|
2252
|
+
end
|
2253
|
+
if s0.last.success?
|
2254
|
+
r0 = (InlineModule).new(input, i0...index, s0)
|
2255
|
+
r0.extend(InlineModule1)
|
2256
|
+
else
|
2257
|
+
self.index = i0
|
2258
|
+
r0 = ParseFailure.new(input, i0, s0)
|
2259
|
+
end
|
2260
|
+
|
2261
|
+
node_cache[:inline_module][start_index] = r0
|
2262
|
+
|
2263
|
+
return r0
|
2264
|
+
end
|
2265
|
+
|
2266
|
+
module KeywordInsideGrammar0
|
2267
|
+
end
|
2268
|
+
|
2269
|
+
def _nt_keyword_inside_grammar
|
2270
|
+
start_index = index
|
2271
|
+
cached = node_cache[:keyword_inside_grammar][index]
|
2272
|
+
if cached
|
2273
|
+
@index = cached.interval.end
|
2274
|
+
return cached
|
2275
|
+
end
|
2276
|
+
|
2277
|
+
i0, s0, nr0 = index, [], []
|
2278
|
+
i1, nr1 = index, []
|
2279
|
+
r2 = parse_terminal('rule', SyntaxNode)
|
2280
|
+
nr1 << r2
|
2281
|
+
if r2.success?
|
2282
|
+
r1 = r2
|
2283
|
+
r2.update_nested_results(nr1)
|
2284
|
+
else
|
2285
|
+
r3 = parse_terminal('end', SyntaxNode)
|
2286
|
+
nr1 << r3
|
2287
|
+
if r3.success?
|
2288
|
+
r1 = r3
|
2289
|
+
r3.update_nested_results(nr1)
|
2290
|
+
else
|
2291
|
+
self.index = i1
|
2292
|
+
r1 = ParseFailure.new(input, i1, nr1)
|
2293
|
+
end
|
2294
|
+
end
|
2295
|
+
s0 << r1
|
2296
|
+
if r1.success?
|
2297
|
+
i4 = index
|
2298
|
+
r5 = _nt_non_space_char
|
2299
|
+
if r5.success?
|
2300
|
+
r4 = ParseFailure.new(input, i4, r5.nested_failures)
|
2301
|
+
else
|
2302
|
+
self.index = i4
|
2303
|
+
r4 = SyntaxNode.new(input, index...index, r5.nested_failures)
|
2304
|
+
end
|
2305
|
+
s0 << r4
|
2306
|
+
end
|
2307
|
+
if s0.last.success?
|
2308
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
2309
|
+
r0.extend(KeywordInsideGrammar0)
|
2310
|
+
else
|
2311
|
+
self.index = i0
|
2312
|
+
r0 = ParseFailure.new(input, i0, s0)
|
2313
|
+
end
|
2314
|
+
|
2315
|
+
node_cache[:keyword_inside_grammar][start_index] = r0
|
2316
|
+
|
2317
|
+
return r0
|
2318
|
+
end
|
2319
|
+
|
2320
|
+
module NonSpaceChar0
|
2321
|
+
end
|
2322
|
+
|
2323
|
+
def _nt_non_space_char
|
2324
|
+
start_index = index
|
2325
|
+
cached = node_cache[:non_space_char][index]
|
2326
|
+
if cached
|
2327
|
+
@index = cached.interval.end
|
2328
|
+
return cached
|
2329
|
+
end
|
2330
|
+
|
2331
|
+
i0, s0, nr0 = index, [], []
|
2332
|
+
i1 = index
|
2333
|
+
r2 = _nt_space
|
2334
|
+
if r2.success?
|
2335
|
+
r1 = ParseFailure.new(input, i1, r2.nested_failures)
|
2336
|
+
else
|
2337
|
+
self.index = i1
|
2338
|
+
r1 = SyntaxNode.new(input, index...index, r2.nested_failures)
|
2339
|
+
end
|
2340
|
+
s0 << r1
|
2341
|
+
if r1.success?
|
2342
|
+
r3 = parse_anything(SyntaxNode)
|
2343
|
+
s0 << r3
|
2344
|
+
end
|
2345
|
+
if s0.last.success?
|
2346
|
+
r0 = (SyntaxNode).new(input, i0...index, s0)
|
2347
|
+
r0.extend(NonSpaceChar0)
|
2348
|
+
else
|
2349
|
+
self.index = i0
|
2350
|
+
r0 = ParseFailure.new(input, i0, s0)
|
2351
|
+
end
|
2352
|
+
|
2353
|
+
node_cache[:non_space_char][start_index] = r0
|
2354
|
+
|
2355
|
+
return r0
|
2356
|
+
end
|
2357
|
+
|
2358
|
+
def _nt_alpha_char
|
2359
|
+
start_index = index
|
2360
|
+
cached = node_cache[:alpha_char][index]
|
2361
|
+
if cached
|
2362
|
+
@index = cached.interval.end
|
2363
|
+
return cached
|
2364
|
+
end
|
2365
|
+
|
2366
|
+
r0 = parse_char_class(/[A-Za-z_]/, 'A-Za-z_', SyntaxNode)
|
2367
|
+
|
2368
|
+
node_cache[:alpha_char][start_index] = r0
|
2369
|
+
|
2370
|
+
return r0
|
2371
|
+
end
|
2372
|
+
|
2373
|
+
def _nt_alphanumeric_char
|
2374
|
+
start_index = index
|
2375
|
+
cached = node_cache[:alphanumeric_char][index]
|
2376
|
+
if cached
|
2377
|
+
@index = cached.interval.end
|
2378
|
+
return cached
|
2379
|
+
end
|
2380
|
+
|
2381
|
+
i0, nr0 = index, []
|
2382
|
+
r1 = _nt_alpha_char
|
2383
|
+
nr0 << r1
|
2384
|
+
if r1.success?
|
2385
|
+
r0 = r1
|
2386
|
+
r1.update_nested_results(nr0)
|
2387
|
+
else
|
2388
|
+
r2 = parse_char_class(/[0-9]/, '0-9', SyntaxNode)
|
2389
|
+
nr0 << r2
|
2390
|
+
if r2.success?
|
2391
|
+
r0 = r2
|
2392
|
+
r2.update_nested_results(nr0)
|
2393
|
+
else
|
2394
|
+
self.index = i0
|
2395
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
2396
|
+
end
|
2397
|
+
end
|
2398
|
+
|
2399
|
+
node_cache[:alphanumeric_char][start_index] = r0
|
2400
|
+
|
2401
|
+
return r0
|
2402
|
+
end
|
2403
|
+
|
2404
|
+
def _nt_space
|
2405
|
+
start_index = index
|
2406
|
+
cached = node_cache[:space][index]
|
2407
|
+
if cached
|
2408
|
+
@index = cached.interval.end
|
2409
|
+
return cached
|
2410
|
+
end
|
2411
|
+
|
2412
|
+
s0, nr0, i0 = [], [], index
|
2413
|
+
loop do
|
2414
|
+
r1 = parse_char_class(/[ \t\n\r]/, ' \t\n\r', SyntaxNode)
|
2415
|
+
nr0 << r1
|
2416
|
+
if r1.success?
|
2417
|
+
s0 << r1
|
2418
|
+
else
|
2419
|
+
break
|
2420
|
+
end
|
2421
|
+
end
|
2422
|
+
if s0.empty?
|
2423
|
+
self.index = i0
|
2424
|
+
r0 = ParseFailure.new(input, i0, nr0)
|
2425
|
+
else
|
2426
|
+
r0 = SyntaxNode.new(input, i0...index, s0, nr0)
|
2427
|
+
end
|
2428
|
+
|
2429
|
+
node_cache[:space][start_index] = r0
|
2430
|
+
|
2431
|
+
return r0
|
2432
|
+
end
|
2433
|
+
|
2434
|
+
end
|
2435
|
+
|
2436
|
+
class MetagrammarParser < ::Treetop::Runtime::CompiledParser
|
2437
|
+
include Metagrammar
|
2438
|
+
end
|
2439
|
+
|
2440
|
+
end
|
2441
|
+
end
|