less 1.1.13 → 1.2.9

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