soroban 0.7.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -3
- data/README.md +4 -4
- data/Soroban.gemspec +3 -3
- data/VERSION +1 -1
- data/lib/soroban.rb +1 -2
- data/lib/soroban/cell.rb +47 -18
- data/lib/soroban/errors.rb +20 -0
- data/lib/soroban/functions.rb +31 -21
- data/lib/soroban/functions/and.rb +4 -2
- data/lib/soroban/functions/average.rb +2 -2
- data/lib/soroban/functions/exp.rb +1 -3
- data/lib/soroban/functions/if.rb +1 -1
- data/lib/soroban/functions/ln.rb +1 -3
- data/lib/soroban/functions/max.rb +2 -2
- data/lib/soroban/functions/min.rb +2 -2
- data/lib/soroban/functions/not.rb +1 -3
- data/lib/soroban/functions/or.rb +4 -2
- data/lib/soroban/functions/sum.rb +2 -2
- data/lib/soroban/functions/vlookup.rb +2 -2
- data/lib/soroban/helpers.rb +62 -38
- data/lib/soroban/import.rb +4 -1
- data/lib/soroban/import/ruby_xl_importer.rb +21 -15
- data/lib/soroban/import/ruby_xl_patch.rb +2 -0
- data/lib/soroban/label_walker.rb +10 -9
- data/lib/soroban/parser.rb +6 -4
- data/lib/soroban/parser/grammar.rb +1474 -1472
- data/lib/soroban/parser/grammar.treetop +71 -67
- data/lib/soroban/parser/nodes.rb +49 -47
- data/lib/soroban/parser/rewrite.rb +20 -13
- data/lib/soroban/sheet.rb +33 -29
- data/lib/soroban/value_walker.rb +19 -19
- data/spec/documentation_spec.rb +31 -43
- data/spec/import_spec.rb +5 -13
- data/spec/soroban_spec.rb +6 -2
- data/spec/spec_helper.rb +8 -0
- metadata +6 -6
- data/lib/soroban/error.rb +0 -20
data/lib/soroban/import.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
require 'soroban/helpers'
|
2
|
+
require 'soroban/sheet'
|
3
|
+
require 'soroban/label_walker'
|
4
|
+
|
1
5
|
module Soroban
|
6
|
+
|
2
7
|
module Import
|
3
8
|
|
4
9
|
# Use the RubyXL gem to load an xlsx file, returning a new Soroban::Sheet
|
5
10
|
# object. Specify the path to the xlsx file, the index of the sheet to be
|
6
11
|
# imported, and a hash of name => label bindings.
|
7
12
|
def self.rubyXL(path, sheet, bindings)
|
8
|
-
require 'rubyXL'
|
9
|
-
require 'soroban/import/ruby_xl_patch'
|
10
13
|
RubyXLImporter.new(path, sheet, bindings).import
|
11
14
|
end
|
12
15
|
|
@@ -15,41 +18,44 @@ module Soroban
|
|
15
18
|
class RubyXLImporter
|
16
19
|
|
17
20
|
def initialize(path, index, bindings)
|
18
|
-
@
|
21
|
+
@_path, @_index, @_bindings = path, index, bindings
|
22
|
+
@_sheet = nil
|
23
|
+
@_model = nil
|
19
24
|
end
|
20
25
|
|
21
26
|
def import
|
22
|
-
workbook = RubyXL::Parser.parse(@
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
26
|
-
if Soroban::range?(label_or_range)
|
27
|
-
LabelWalker.new(label_or_range).each do |label|
|
27
|
+
workbook = RubyXL::Parser.parse(@_path)
|
28
|
+
@_sheet = workbook.worksheets[@_index]
|
29
|
+
@_model = Soroban::Sheet.new
|
30
|
+
@_bindings.values.each do |label_or_range|
|
31
|
+
if Soroban::Helpers::range?(label_or_range)
|
32
|
+
Soroban::LabelWalker.new(label_or_range).each do |label|
|
28
33
|
_addCell(label)
|
29
34
|
end
|
30
35
|
else
|
31
36
|
_addCell(label_or_range)
|
32
37
|
end
|
33
38
|
end
|
34
|
-
while label = @
|
39
|
+
while label = @_model.missing.first
|
35
40
|
_addCell(label)
|
36
41
|
end
|
37
|
-
@
|
38
|
-
return @
|
42
|
+
@_model.bind(@_bindings)
|
43
|
+
return @_model
|
39
44
|
end
|
40
45
|
|
41
46
|
private
|
42
47
|
|
43
48
|
def _addCell(label)
|
44
|
-
row, col = Soroban::getPos(label)
|
45
|
-
cell = @
|
49
|
+
row, col = Soroban::Helpers::getPos(label)
|
50
|
+
cell = @_sheet[row][col]
|
46
51
|
data = cell.formula rescue nil
|
47
52
|
data = "=#{data}" unless data.nil?
|
48
53
|
data ||= cell.value.to_s rescue nil
|
49
|
-
@
|
54
|
+
@_model.set(label.to_sym => data)
|
50
55
|
end
|
51
56
|
|
52
57
|
end
|
53
58
|
|
54
59
|
end
|
60
|
+
|
55
61
|
end
|
data/lib/soroban/label_walker.rb
CHANGED
@@ -1,30 +1,31 @@
|
|
1
|
+
require 'soroban/helpers'
|
2
|
+
|
1
3
|
module Soroban
|
2
4
|
|
3
|
-
# An enumerable that allows cells in a range to be visited.
|
5
|
+
# An enumerable that allows the labels for cells in a range to be visited.
|
4
6
|
class LabelWalker
|
5
|
-
|
6
7
|
include Enumerable
|
7
8
|
|
8
9
|
# Create a new walker from a supplied range.
|
9
10
|
def initialize(range)
|
10
|
-
@
|
11
|
+
@_fc, @_fr, @_tc, @_tr = Soroban::Helpers.getRange(range)
|
11
12
|
end
|
12
13
|
|
13
|
-
# Yield the label of each cell referenced by the supplied range.
|
14
|
+
# Yield the label of each cell referenced by the supplied range. For a range
|
15
|
+
# of the form "A1:B4", this will yield "A1", "A2", "A3", ..., "B3", "B4".
|
14
16
|
def each
|
15
|
-
col, row = @
|
17
|
+
col, row = @_fc, @_fr
|
16
18
|
while true do
|
17
19
|
yield "#{col}#{row}"
|
18
|
-
break if row == @
|
19
|
-
if row == @
|
20
|
-
row = @
|
20
|
+
break if row == @_tr && col == @_tc
|
21
|
+
if row == @_tr
|
22
|
+
row = @_fr
|
21
23
|
col = col.next
|
22
24
|
else
|
23
25
|
row = row.next
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
27
|
-
|
28
29
|
end
|
29
30
|
|
30
31
|
end
|
data/lib/soroban/parser.rb
CHANGED
@@ -6,10 +6,12 @@ require 'soroban/parser/grammar'
|
|
6
6
|
|
7
7
|
module Soroban
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
class Parser
|
10
|
+
# A Treetop parser for Excel formulas that can generate valid Ruby expression
|
11
|
+
# via a rewrite operation, and which can build an array of referenced labels.
|
12
|
+
def self.instance
|
13
|
+
@@parser ||= ExcelParser.new
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
17
|
end
|
@@ -2,989 +2,991 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
module Soroban
|
5
|
-
|
5
|
+
module Excel
|
6
|
+
include Treetop::Runtime
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
module Formula0
|
12
|
-
def logical
|
13
|
-
elements[2]
|
8
|
+
def root
|
9
|
+
@root ||= :formula
|
14
10
|
end
|
15
|
-
end
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
cached = node_cache[:formula][index]
|
21
|
-
if cached
|
22
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
23
|
-
@index = cached.interval.end
|
12
|
+
module Formula0
|
13
|
+
def logical
|
14
|
+
elements[2]
|
24
15
|
end
|
25
|
-
return cached
|
26
16
|
end
|
27
17
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
18
|
+
def _nt_formula
|
19
|
+
start_index = index
|
20
|
+
if node_cache[:formula].has_key?(index)
|
21
|
+
cached = node_cache[:formula][index]
|
22
|
+
if cached
|
23
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
24
|
+
@index = cached.interval.end
|
25
|
+
end
|
26
|
+
return cached
|
27
|
+
end
|
28
|
+
|
29
|
+
i0 = index
|
30
|
+
i1, s1 = index, []
|
31
|
+
if has_terminal?('=', false, index)
|
32
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
33
|
+
@index += 1
|
42
34
|
else
|
43
|
-
|
35
|
+
terminal_parse_failure('=')
|
36
|
+
r2 = nil
|
37
|
+
end
|
38
|
+
s1 << r2
|
39
|
+
if r2
|
40
|
+
r4 = _nt_space
|
41
|
+
if r4
|
42
|
+
r3 = r4
|
43
|
+
else
|
44
|
+
r3 = instantiate_node(SyntaxNode,input, index...index)
|
45
|
+
end
|
46
|
+
s1 << r3
|
47
|
+
if r3
|
48
|
+
r5 = _nt_logical
|
49
|
+
s1 << r5
|
50
|
+
end
|
44
51
|
end
|
45
|
-
s1
|
46
|
-
|
47
|
-
|
48
|
-
|
52
|
+
if s1.last
|
53
|
+
r1 = instantiate_node(Formula,input, i1...index, s1)
|
54
|
+
r1.extend(Formula0)
|
55
|
+
else
|
56
|
+
@index = i1
|
57
|
+
r1 = nil
|
49
58
|
end
|
50
|
-
|
51
|
-
|
52
|
-
r1 = instantiate_node(Formula,input, i1...index, s1)
|
53
|
-
r1.extend(Formula0)
|
54
|
-
else
|
55
|
-
@index = i1
|
56
|
-
r1 = nil
|
57
|
-
end
|
58
|
-
if r1
|
59
|
-
r0 = r1
|
60
|
-
else
|
61
|
-
r6 = _nt_string
|
62
|
-
if r6
|
63
|
-
r0 = r6
|
59
|
+
if r1
|
60
|
+
r0 = r1
|
64
61
|
else
|
65
|
-
|
66
|
-
if
|
67
|
-
r0 =
|
62
|
+
r6 = _nt_string
|
63
|
+
if r6
|
64
|
+
r0 = r6
|
68
65
|
else
|
69
|
-
|
70
|
-
if
|
71
|
-
r0 =
|
66
|
+
r7 = _nt_number
|
67
|
+
if r7
|
68
|
+
r0 = r7
|
72
69
|
else
|
73
|
-
|
74
|
-
|
70
|
+
r8 = _nt_boolean
|
71
|
+
if r8
|
72
|
+
r0 = r8
|
73
|
+
else
|
74
|
+
@index = i0
|
75
|
+
r0 = nil
|
76
|
+
end
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
78
|
-
end
|
79
|
-
|
80
|
-
node_cache[:formula][start_index] = r0
|
81
80
|
|
82
|
-
|
83
|
-
end
|
81
|
+
node_cache[:formula][start_index] = r0
|
84
82
|
|
85
|
-
|
86
|
-
def and
|
87
|
-
elements[3]
|
83
|
+
r0
|
88
84
|
end
|
89
|
-
end
|
90
85
|
|
91
|
-
|
92
|
-
|
93
|
-
|
86
|
+
module Logical0
|
87
|
+
def and
|
88
|
+
elements[3]
|
89
|
+
end
|
94
90
|
end
|
95
91
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
start_index = index
|
100
|
-
if node_cache[:logical].has_key?(index)
|
101
|
-
cached = node_cache[:logical][index]
|
102
|
-
if cached
|
103
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
104
|
-
@index = cached.interval.end
|
92
|
+
module Logical1
|
93
|
+
def and
|
94
|
+
elements[0]
|
105
95
|
end
|
106
|
-
|
96
|
+
|
107
97
|
end
|
108
98
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
r5 = _nt_space
|
117
|
-
if r5
|
118
|
-
r4 = r5
|
119
|
-
else
|
120
|
-
r4 = instantiate_node(SyntaxNode,input, index...index)
|
99
|
+
def _nt_logical
|
100
|
+
start_index = index
|
101
|
+
if node_cache[:logical].has_key?(index)
|
102
|
+
cached = node_cache[:logical][index]
|
103
|
+
if cached
|
104
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
105
|
+
@index = cached.interval.end
|
121
106
|
end
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
107
|
+
return cached
|
108
|
+
end
|
109
|
+
|
110
|
+
i0, s0 = index, []
|
111
|
+
r1 = _nt_and
|
112
|
+
s0 << r1
|
113
|
+
if r1
|
114
|
+
s2, i2 = [], index
|
115
|
+
loop do
|
116
|
+
i3, s3 = index, []
|
117
|
+
r5 = _nt_space
|
118
|
+
if r5
|
119
|
+
r4 = r5
|
127
120
|
else
|
128
|
-
|
129
|
-
r6 = nil
|
121
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
130
122
|
end
|
131
|
-
s3 <<
|
132
|
-
if
|
133
|
-
|
134
|
-
|
135
|
-
|
123
|
+
s3 << r4
|
124
|
+
if r4
|
125
|
+
if has_terminal?('or', false, index)
|
126
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
127
|
+
@index += 2
|
136
128
|
else
|
137
|
-
|
129
|
+
terminal_parse_failure('or')
|
130
|
+
r6 = nil
|
138
131
|
end
|
139
|
-
s3 <<
|
140
|
-
if
|
141
|
-
|
142
|
-
|
132
|
+
s3 << r6
|
133
|
+
if r6
|
134
|
+
r8 = _nt_space
|
135
|
+
if r8
|
136
|
+
r7 = r8
|
137
|
+
else
|
138
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
139
|
+
end
|
140
|
+
s3 << r7
|
141
|
+
if r7
|
142
|
+
r9 = _nt_and
|
143
|
+
s3 << r9
|
144
|
+
end
|
143
145
|
end
|
144
146
|
end
|
147
|
+
if s3.last
|
148
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
149
|
+
r3.extend(Logical0)
|
150
|
+
else
|
151
|
+
@index = i3
|
152
|
+
r3 = nil
|
153
|
+
end
|
154
|
+
if r3
|
155
|
+
s2 << r3
|
156
|
+
else
|
157
|
+
break
|
158
|
+
end
|
145
159
|
end
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
else
|
156
|
-
break
|
157
|
-
end
|
160
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
161
|
+
s0 << r2
|
162
|
+
end
|
163
|
+
if s0.last
|
164
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
165
|
+
r0.extend(Logical1)
|
166
|
+
else
|
167
|
+
@index = i0
|
168
|
+
r0 = nil
|
158
169
|
end
|
159
|
-
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
160
|
-
s0 << r2
|
161
|
-
end
|
162
|
-
if s0.last
|
163
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
164
|
-
r0.extend(Logical1)
|
165
|
-
else
|
166
|
-
@index = i0
|
167
|
-
r0 = nil
|
168
|
-
end
|
169
|
-
|
170
|
-
node_cache[:logical][start_index] = r0
|
171
170
|
|
172
|
-
|
173
|
-
end
|
171
|
+
node_cache[:logical][start_index] = r0
|
174
172
|
|
175
|
-
|
176
|
-
def truthval
|
177
|
-
elements[3]
|
173
|
+
r0
|
178
174
|
end
|
179
|
-
end
|
180
175
|
|
181
|
-
|
182
|
-
|
183
|
-
|
176
|
+
module And0
|
177
|
+
def truthval
|
178
|
+
elements[3]
|
179
|
+
end
|
184
180
|
end
|
185
181
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
start_index = index
|
190
|
-
if node_cache[:and].has_key?(index)
|
191
|
-
cached = node_cache[:and][index]
|
192
|
-
if cached
|
193
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
194
|
-
@index = cached.interval.end
|
182
|
+
module And1
|
183
|
+
def truthval
|
184
|
+
elements[0]
|
195
185
|
end
|
196
|
-
|
186
|
+
|
197
187
|
end
|
198
188
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
r5 = _nt_space
|
207
|
-
if r5
|
208
|
-
r4 = r5
|
209
|
-
else
|
210
|
-
r4 = instantiate_node(SyntaxNode,input, index...index)
|
189
|
+
def _nt_and
|
190
|
+
start_index = index
|
191
|
+
if node_cache[:and].has_key?(index)
|
192
|
+
cached = node_cache[:and][index]
|
193
|
+
if cached
|
194
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
195
|
+
@index = cached.interval.end
|
211
196
|
end
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
197
|
+
return cached
|
198
|
+
end
|
199
|
+
|
200
|
+
i0, s0 = index, []
|
201
|
+
r1 = _nt_truthval
|
202
|
+
s0 << r1
|
203
|
+
if r1
|
204
|
+
s2, i2 = [], index
|
205
|
+
loop do
|
206
|
+
i3, s3 = index, []
|
207
|
+
r5 = _nt_space
|
208
|
+
if r5
|
209
|
+
r4 = r5
|
217
210
|
else
|
218
|
-
|
219
|
-
r6 = nil
|
211
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
220
212
|
end
|
221
|
-
s3 <<
|
222
|
-
if
|
223
|
-
|
224
|
-
|
225
|
-
|
213
|
+
s3 << r4
|
214
|
+
if r4
|
215
|
+
if has_terminal?('and', false, index)
|
216
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 3))
|
217
|
+
@index += 3
|
226
218
|
else
|
227
|
-
|
219
|
+
terminal_parse_failure('and')
|
220
|
+
r6 = nil
|
228
221
|
end
|
229
|
-
s3 <<
|
230
|
-
if
|
231
|
-
|
232
|
-
|
222
|
+
s3 << r6
|
223
|
+
if r6
|
224
|
+
r8 = _nt_space
|
225
|
+
if r8
|
226
|
+
r7 = r8
|
227
|
+
else
|
228
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
229
|
+
end
|
230
|
+
s3 << r7
|
231
|
+
if r7
|
232
|
+
r9 = _nt_truthval
|
233
|
+
s3 << r9
|
234
|
+
end
|
233
235
|
end
|
234
236
|
end
|
237
|
+
if s3.last
|
238
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
239
|
+
r3.extend(And0)
|
240
|
+
else
|
241
|
+
@index = i3
|
242
|
+
r3 = nil
|
243
|
+
end
|
244
|
+
if r3
|
245
|
+
s2 << r3
|
246
|
+
else
|
247
|
+
break
|
248
|
+
end
|
235
249
|
end
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
else
|
246
|
-
break
|
247
|
-
end
|
250
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
251
|
+
s0 << r2
|
252
|
+
end
|
253
|
+
if s0.last
|
254
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
255
|
+
r0.extend(And1)
|
256
|
+
else
|
257
|
+
@index = i0
|
258
|
+
r0 = nil
|
248
259
|
end
|
249
|
-
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
250
|
-
s0 << r2
|
251
|
-
end
|
252
|
-
if s0.last
|
253
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
254
|
-
r0.extend(And1)
|
255
|
-
else
|
256
|
-
@index = i0
|
257
|
-
r0 = nil
|
258
|
-
end
|
259
|
-
|
260
|
-
node_cache[:and][start_index] = r0
|
261
260
|
|
262
|
-
|
263
|
-
end
|
261
|
+
node_cache[:and][start_index] = r0
|
264
262
|
|
265
|
-
|
266
|
-
def logical
|
267
|
-
elements[2]
|
263
|
+
r0
|
268
264
|
end
|
269
265
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
start_index = index
|
274
|
-
if node_cache[:truthval].has_key?(index)
|
275
|
-
cached = node_cache[:truthval][index]
|
276
|
-
if cached
|
277
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
278
|
-
@index = cached.interval.end
|
266
|
+
module Truthval0
|
267
|
+
def logical
|
268
|
+
elements[2]
|
279
269
|
end
|
280
|
-
|
270
|
+
|
281
271
|
end
|
282
272
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
273
|
+
def _nt_truthval
|
274
|
+
start_index = index
|
275
|
+
if node_cache[:truthval].has_key?(index)
|
276
|
+
cached = node_cache[:truthval][index]
|
277
|
+
if cached
|
278
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
279
|
+
@index = cached.interval.end
|
280
|
+
end
|
281
|
+
return cached
|
282
|
+
end
|
283
|
+
|
284
|
+
i0 = index
|
285
|
+
r1 = _nt_comparison
|
286
|
+
if r1
|
287
|
+
r0 = r1
|
292
288
|
else
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
if r3
|
298
|
-
r5 = _nt_space
|
299
|
-
if r5
|
300
|
-
r4 = r5
|
289
|
+
i2, s2 = index, []
|
290
|
+
if has_terminal?('(', false, index)
|
291
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
292
|
+
@index += 1
|
301
293
|
else
|
302
|
-
|
294
|
+
terminal_parse_failure('(')
|
295
|
+
r3 = nil
|
303
296
|
end
|
304
|
-
s2 <<
|
305
|
-
if
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
s2 <<
|
316
|
-
if
|
317
|
-
|
318
|
-
|
319
|
-
|
297
|
+
s2 << r3
|
298
|
+
if r3
|
299
|
+
r5 = _nt_space
|
300
|
+
if r5
|
301
|
+
r4 = r5
|
302
|
+
else
|
303
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
304
|
+
end
|
305
|
+
s2 << r4
|
306
|
+
if r4
|
307
|
+
r6 = _nt_logical
|
308
|
+
s2 << r6
|
309
|
+
if r6
|
310
|
+
r8 = _nt_space
|
311
|
+
if r8
|
312
|
+
r7 = r8
|
320
313
|
else
|
321
|
-
|
322
|
-
|
314
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
315
|
+
end
|
316
|
+
s2 << r7
|
317
|
+
if r7
|
318
|
+
if has_terminal?(')', false, index)
|
319
|
+
r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
320
|
+
@index += 1
|
321
|
+
else
|
322
|
+
terminal_parse_failure(')')
|
323
|
+
r9 = nil
|
324
|
+
end
|
325
|
+
s2 << r9
|
323
326
|
end
|
324
|
-
s2 << r9
|
325
327
|
end
|
326
328
|
end
|
327
329
|
end
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
r2.extend(Truthval0)
|
332
|
-
else
|
333
|
-
@index = i2
|
334
|
-
r2 = nil
|
335
|
-
end
|
336
|
-
if r2
|
337
|
-
r0 = r2
|
338
|
-
else
|
339
|
-
r10 = _nt_boolean
|
340
|
-
if r10
|
341
|
-
r0 = r10
|
330
|
+
if s2.last
|
331
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
332
|
+
r2.extend(Truthval0)
|
342
333
|
else
|
343
|
-
@index =
|
344
|
-
|
334
|
+
@index = i2
|
335
|
+
r2 = nil
|
336
|
+
end
|
337
|
+
if r2
|
338
|
+
r0 = r2
|
339
|
+
else
|
340
|
+
r10 = _nt_boolean
|
341
|
+
if r10
|
342
|
+
r0 = r10
|
343
|
+
else
|
344
|
+
@index = i0
|
345
|
+
r0 = nil
|
346
|
+
end
|
345
347
|
end
|
346
348
|
end
|
347
|
-
end
|
348
349
|
|
349
|
-
|
350
|
+
node_cache[:truthval][start_index] = r0
|
350
351
|
|
351
|
-
|
352
|
-
|
352
|
+
r0
|
353
|
+
end
|
353
354
|
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
355
|
+
def _nt_boolean
|
356
|
+
start_index = index
|
357
|
+
if node_cache[:boolean].has_key?(index)
|
358
|
+
cached = node_cache[:boolean][index]
|
359
|
+
if cached
|
360
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
361
|
+
@index = cached.interval.end
|
362
|
+
end
|
363
|
+
return cached
|
361
364
|
end
|
362
|
-
return cached
|
363
|
-
end
|
364
365
|
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
else
|
370
|
-
terminal_parse_failure('true')
|
371
|
-
r1 = nil
|
372
|
-
end
|
373
|
-
if r1
|
374
|
-
r0 = r1
|
375
|
-
else
|
376
|
-
if has_terminal?('false', false, index)
|
377
|
-
r2 = instantiate_node(SyntaxNode,input, index...(index + 5))
|
378
|
-
@index += 5
|
366
|
+
i0 = index
|
367
|
+
if has_terminal?('true', false, index)
|
368
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 4))
|
369
|
+
@index += 4
|
379
370
|
else
|
380
|
-
terminal_parse_failure('
|
381
|
-
|
371
|
+
terminal_parse_failure('true')
|
372
|
+
r1 = nil
|
382
373
|
end
|
383
|
-
if
|
384
|
-
r0 =
|
374
|
+
if r1
|
375
|
+
r0 = r1
|
385
376
|
else
|
386
|
-
if has_terminal?('
|
387
|
-
|
388
|
-
@index +=
|
377
|
+
if has_terminal?('false', false, index)
|
378
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 5))
|
379
|
+
@index += 5
|
389
380
|
else
|
390
|
-
terminal_parse_failure('
|
391
|
-
|
381
|
+
terminal_parse_failure('false')
|
382
|
+
r2 = nil
|
392
383
|
end
|
393
|
-
if
|
394
|
-
r0 =
|
384
|
+
if r2
|
385
|
+
r0 = r2
|
395
386
|
else
|
396
|
-
if has_terminal?('
|
397
|
-
|
398
|
-
@index +=
|
387
|
+
if has_terminal?('TRUE', false, index)
|
388
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 4))
|
389
|
+
@index += 4
|
399
390
|
else
|
400
|
-
terminal_parse_failure('
|
401
|
-
|
391
|
+
terminal_parse_failure('TRUE')
|
392
|
+
r3 = nil
|
402
393
|
end
|
403
|
-
if
|
404
|
-
r0 =
|
394
|
+
if r3
|
395
|
+
r0 = r3
|
405
396
|
else
|
406
|
-
|
407
|
-
|
397
|
+
if has_terminal?('FALSE', false, index)
|
398
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 5))
|
399
|
+
@index += 5
|
400
|
+
else
|
401
|
+
terminal_parse_failure('FALSE')
|
402
|
+
r4 = nil
|
403
|
+
end
|
404
|
+
if r4
|
405
|
+
r0 = r4
|
406
|
+
else
|
407
|
+
@index = i0
|
408
|
+
r0 = nil
|
409
|
+
end
|
408
410
|
end
|
409
411
|
end
|
410
412
|
end
|
411
|
-
end
|
412
413
|
|
413
|
-
|
414
|
-
|
415
|
-
r0
|
416
|
-
end
|
414
|
+
node_cache[:boolean][start_index] = r0
|
417
415
|
|
418
|
-
|
419
|
-
def comparator
|
420
|
-
elements[1]
|
416
|
+
r0
|
421
417
|
end
|
422
418
|
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
419
|
+
module Comparison0
|
420
|
+
def comparator
|
421
|
+
elements[1]
|
422
|
+
end
|
427
423
|
|
428
|
-
|
429
|
-
|
430
|
-
|
424
|
+
def expression
|
425
|
+
elements[3]
|
426
|
+
end
|
431
427
|
end
|
432
428
|
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
start_index = index
|
437
|
-
if node_cache[:comparison].has_key?(index)
|
438
|
-
cached = node_cache[:comparison][index]
|
439
|
-
if cached
|
440
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
441
|
-
@index = cached.interval.end
|
429
|
+
module Comparison1
|
430
|
+
def expression
|
431
|
+
elements[0]
|
442
432
|
end
|
443
|
-
|
433
|
+
|
444
434
|
end
|
445
435
|
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
r5 = _nt_space
|
454
|
-
if r5
|
455
|
-
r4 = r5
|
456
|
-
else
|
457
|
-
r4 = instantiate_node(SyntaxNode,input, index...index)
|
436
|
+
def _nt_comparison
|
437
|
+
start_index = index
|
438
|
+
if node_cache[:comparison].has_key?(index)
|
439
|
+
cached = node_cache[:comparison][index]
|
440
|
+
if cached
|
441
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
442
|
+
@index = cached.interval.end
|
458
443
|
end
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
444
|
+
return cached
|
445
|
+
end
|
446
|
+
|
447
|
+
i0, s0 = index, []
|
448
|
+
r1 = _nt_expression
|
449
|
+
s0 << r1
|
450
|
+
if r1
|
451
|
+
s2, i2 = [], index
|
452
|
+
loop do
|
453
|
+
i3, s3 = index, []
|
454
|
+
r5 = _nt_space
|
455
|
+
if r5
|
456
|
+
r4 = r5
|
457
|
+
else
|
458
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
459
|
+
end
|
460
|
+
s3 << r4
|
461
|
+
if r4
|
462
|
+
r6 = _nt_comparator
|
463
|
+
s3 << r6
|
464
|
+
if r6
|
465
|
+
r8 = _nt_space
|
466
|
+
if r8
|
467
|
+
r7 = r8
|
468
|
+
else
|
469
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
470
|
+
end
|
471
|
+
s3 << r7
|
472
|
+
if r7
|
473
|
+
r9 = _nt_expression
|
474
|
+
s3 << r9
|
475
|
+
end
|
474
476
|
end
|
475
477
|
end
|
478
|
+
if s3.last
|
479
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
480
|
+
r3.extend(Comparison0)
|
481
|
+
else
|
482
|
+
@index = i3
|
483
|
+
r3 = nil
|
484
|
+
end
|
485
|
+
if r3
|
486
|
+
s2 << r3
|
487
|
+
else
|
488
|
+
break
|
489
|
+
end
|
476
490
|
end
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
else
|
487
|
-
break
|
488
|
-
end
|
491
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
492
|
+
s0 << r2
|
493
|
+
end
|
494
|
+
if s0.last
|
495
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
496
|
+
r0.extend(Comparison1)
|
497
|
+
else
|
498
|
+
@index = i0
|
499
|
+
r0 = nil
|
489
500
|
end
|
490
|
-
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
491
|
-
s0 << r2
|
492
|
-
end
|
493
|
-
if s0.last
|
494
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
495
|
-
r0.extend(Comparison1)
|
496
|
-
else
|
497
|
-
@index = i0
|
498
|
-
r0 = nil
|
499
|
-
end
|
500
501
|
|
501
|
-
|
502
|
+
node_cache[:comparison][start_index] = r0
|
502
503
|
|
503
|
-
|
504
|
-
|
504
|
+
r0
|
505
|
+
end
|
505
506
|
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
507
|
+
def _nt_comparator
|
508
|
+
start_index = index
|
509
|
+
if node_cache[:comparator].has_key?(index)
|
510
|
+
cached = node_cache[:comparator][index]
|
511
|
+
if cached
|
512
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
513
|
+
@index = cached.interval.end
|
514
|
+
end
|
515
|
+
return cached
|
513
516
|
end
|
514
|
-
return cached
|
515
|
-
end
|
516
517
|
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
else
|
522
|
-
terminal_parse_failure('=')
|
523
|
-
r1 = nil
|
524
|
-
end
|
525
|
-
if r1
|
526
|
-
r0 = r1
|
527
|
-
else
|
528
|
-
if has_terminal?('<>', false, index)
|
529
|
-
r2 = instantiate_node(NotEqual,input, index...(index + 2))
|
530
|
-
@index += 2
|
518
|
+
i0 = index
|
519
|
+
if has_terminal?('=', false, index)
|
520
|
+
r1 = instantiate_node(Equal,input, index...(index + 1))
|
521
|
+
@index += 1
|
531
522
|
else
|
532
|
-
terminal_parse_failure('
|
533
|
-
|
523
|
+
terminal_parse_failure('=')
|
524
|
+
r1 = nil
|
534
525
|
end
|
535
|
-
if
|
536
|
-
r0 =
|
526
|
+
if r1
|
527
|
+
r0 = r1
|
537
528
|
else
|
538
|
-
if has_terminal?('
|
539
|
-
|
529
|
+
if has_terminal?('<>', false, index)
|
530
|
+
r2 = instantiate_node(NotEqual,input, index...(index + 2))
|
540
531
|
@index += 2
|
541
532
|
else
|
542
|
-
terminal_parse_failure('
|
543
|
-
|
533
|
+
terminal_parse_failure('<>')
|
534
|
+
r2 = nil
|
544
535
|
end
|
545
|
-
if
|
546
|
-
r0 =
|
536
|
+
if r2
|
537
|
+
r0 = r2
|
547
538
|
else
|
548
|
-
if has_terminal?('
|
549
|
-
|
539
|
+
if has_terminal?('>=', false, index)
|
540
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
550
541
|
@index += 2
|
551
542
|
else
|
552
|
-
terminal_parse_failure('
|
553
|
-
|
543
|
+
terminal_parse_failure('>=')
|
544
|
+
r3 = nil
|
554
545
|
end
|
555
|
-
if
|
556
|
-
r0 =
|
546
|
+
if r3
|
547
|
+
r0 = r3
|
557
548
|
else
|
558
|
-
if has_terminal?('
|
559
|
-
|
560
|
-
@index +=
|
549
|
+
if has_terminal?('<=', false, index)
|
550
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
551
|
+
@index += 2
|
561
552
|
else
|
562
|
-
terminal_parse_failure('
|
563
|
-
|
553
|
+
terminal_parse_failure('<=')
|
554
|
+
r4 = nil
|
564
555
|
end
|
565
|
-
if
|
566
|
-
r0 =
|
556
|
+
if r4
|
557
|
+
r0 = r4
|
567
558
|
else
|
568
|
-
if has_terminal?('
|
569
|
-
|
559
|
+
if has_terminal?('>', false, index)
|
560
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
570
561
|
@index += 1
|
571
562
|
else
|
572
|
-
terminal_parse_failure('
|
573
|
-
|
563
|
+
terminal_parse_failure('>')
|
564
|
+
r5 = nil
|
574
565
|
end
|
575
|
-
if
|
576
|
-
r0 =
|
566
|
+
if r5
|
567
|
+
r0 = r5
|
577
568
|
else
|
578
|
-
|
579
|
-
|
569
|
+
if has_terminal?('<', false, index)
|
570
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
571
|
+
@index += 1
|
572
|
+
else
|
573
|
+
terminal_parse_failure('<')
|
574
|
+
r6 = nil
|
575
|
+
end
|
576
|
+
if r6
|
577
|
+
r0 = r6
|
578
|
+
else
|
579
|
+
@index = i0
|
580
|
+
r0 = nil
|
581
|
+
end
|
580
582
|
end
|
581
583
|
end
|
582
584
|
end
|
583
585
|
end
|
584
586
|
end
|
585
|
-
end
|
586
|
-
|
587
|
-
node_cache[:comparator][start_index] = r0
|
588
587
|
|
589
|
-
|
590
|
-
end
|
588
|
+
node_cache[:comparator][start_index] = r0
|
591
589
|
|
592
|
-
|
593
|
-
def additive_operator
|
594
|
-
elements[1]
|
590
|
+
r0
|
595
591
|
end
|
596
592
|
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
593
|
+
module Expression0
|
594
|
+
def additive_operator
|
595
|
+
elements[1]
|
596
|
+
end
|
601
597
|
|
602
|
-
|
603
|
-
|
604
|
-
|
598
|
+
def multiplicative
|
599
|
+
elements[3]
|
600
|
+
end
|
605
601
|
end
|
606
602
|
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
start_index = index
|
611
|
-
if node_cache[:expression].has_key?(index)
|
612
|
-
cached = node_cache[:expression][index]
|
613
|
-
if cached
|
614
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
615
|
-
@index = cached.interval.end
|
603
|
+
module Expression1
|
604
|
+
def multiplicative
|
605
|
+
elements[0]
|
616
606
|
end
|
617
|
-
|
607
|
+
|
618
608
|
end
|
619
609
|
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
r5 = _nt_space
|
628
|
-
if r5
|
629
|
-
r4 = r5
|
630
|
-
else
|
631
|
-
r4 = instantiate_node(SyntaxNode,input, index...index)
|
610
|
+
def _nt_expression
|
611
|
+
start_index = index
|
612
|
+
if node_cache[:expression].has_key?(index)
|
613
|
+
cached = node_cache[:expression][index]
|
614
|
+
if cached
|
615
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
616
|
+
@index = cached.interval.end
|
632
617
|
end
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
618
|
+
return cached
|
619
|
+
end
|
620
|
+
|
621
|
+
i0, s0 = index, []
|
622
|
+
r1 = _nt_multiplicative
|
623
|
+
s0 << r1
|
624
|
+
if r1
|
625
|
+
s2, i2 = [], index
|
626
|
+
loop do
|
627
|
+
i3, s3 = index, []
|
628
|
+
r5 = _nt_space
|
629
|
+
if r5
|
630
|
+
r4 = r5
|
631
|
+
else
|
632
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
633
|
+
end
|
634
|
+
s3 << r4
|
635
|
+
if r4
|
636
|
+
r6 = _nt_additive_operator
|
637
|
+
s3 << r6
|
638
|
+
if r6
|
639
|
+
r8 = _nt_space
|
640
|
+
if r8
|
641
|
+
r7 = r8
|
642
|
+
else
|
643
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
644
|
+
end
|
645
|
+
s3 << r7
|
646
|
+
if r7
|
647
|
+
r9 = _nt_multiplicative
|
648
|
+
s3 << r9
|
649
|
+
end
|
648
650
|
end
|
649
651
|
end
|
652
|
+
if s3.last
|
653
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
654
|
+
r3.extend(Expression0)
|
655
|
+
else
|
656
|
+
@index = i3
|
657
|
+
r3 = nil
|
658
|
+
end
|
659
|
+
if r3
|
660
|
+
s2 << r3
|
661
|
+
else
|
662
|
+
break
|
663
|
+
end
|
650
664
|
end
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
else
|
661
|
-
break
|
662
|
-
end
|
665
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
666
|
+
s0 << r2
|
667
|
+
end
|
668
|
+
if s0.last
|
669
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
670
|
+
r0.extend(Expression1)
|
671
|
+
else
|
672
|
+
@index = i0
|
673
|
+
r0 = nil
|
663
674
|
end
|
664
|
-
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
665
|
-
s0 << r2
|
666
|
-
end
|
667
|
-
if s0.last
|
668
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
669
|
-
r0.extend(Expression1)
|
670
|
-
else
|
671
|
-
@index = i0
|
672
|
-
r0 = nil
|
673
|
-
end
|
674
675
|
|
675
|
-
|
676
|
+
node_cache[:expression][start_index] = r0
|
676
677
|
|
677
|
-
|
678
|
-
|
678
|
+
r0
|
679
|
+
end
|
679
680
|
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
681
|
+
def _nt_additive_operator
|
682
|
+
start_index = index
|
683
|
+
if node_cache[:additive_operator].has_key?(index)
|
684
|
+
cached = node_cache[:additive_operator][index]
|
685
|
+
if cached
|
686
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
687
|
+
@index = cached.interval.end
|
688
|
+
end
|
689
|
+
return cached
|
687
690
|
end
|
688
|
-
return cached
|
689
|
-
end
|
690
691
|
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
@index += 1
|
695
|
-
else
|
696
|
-
terminal_parse_failure('+')
|
697
|
-
r1 = nil
|
698
|
-
end
|
699
|
-
if r1
|
700
|
-
r0 = r1
|
701
|
-
else
|
702
|
-
if has_terminal?('-', false, index)
|
703
|
-
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
692
|
+
i0 = index
|
693
|
+
if has_terminal?('+', false, index)
|
694
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
704
695
|
@index += 1
|
705
696
|
else
|
706
|
-
terminal_parse_failure('
|
707
|
-
|
697
|
+
terminal_parse_failure('+')
|
698
|
+
r1 = nil
|
708
699
|
end
|
709
|
-
if
|
710
|
-
r0 =
|
700
|
+
if r1
|
701
|
+
r0 = r1
|
711
702
|
else
|
712
|
-
|
713
|
-
|
703
|
+
if has_terminal?('-', false, index)
|
704
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
705
|
+
@index += 1
|
706
|
+
else
|
707
|
+
terminal_parse_failure('-')
|
708
|
+
r2 = nil
|
709
|
+
end
|
710
|
+
if r2
|
711
|
+
r0 = r2
|
712
|
+
else
|
713
|
+
@index = i0
|
714
|
+
r0 = nil
|
715
|
+
end
|
714
716
|
end
|
715
|
-
end
|
716
|
-
|
717
|
-
node_cache[:additive_operator][start_index] = r0
|
718
717
|
|
719
|
-
|
720
|
-
end
|
718
|
+
node_cache[:additive_operator][start_index] = r0
|
721
719
|
|
722
|
-
|
723
|
-
def multiplicative_operator
|
724
|
-
elements[1]
|
720
|
+
r0
|
725
721
|
end
|
726
722
|
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
723
|
+
module Multiplicative0
|
724
|
+
def multiplicative_operator
|
725
|
+
elements[1]
|
726
|
+
end
|
731
727
|
|
732
|
-
|
733
|
-
|
734
|
-
|
728
|
+
def value
|
729
|
+
elements[3]
|
730
|
+
end
|
735
731
|
end
|
736
732
|
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
start_index = index
|
741
|
-
if node_cache[:multiplicative].has_key?(index)
|
742
|
-
cached = node_cache[:multiplicative][index]
|
743
|
-
if cached
|
744
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
745
|
-
@index = cached.interval.end
|
733
|
+
module Multiplicative1
|
734
|
+
def value
|
735
|
+
elements[0]
|
746
736
|
end
|
747
|
-
|
737
|
+
|
748
738
|
end
|
749
739
|
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
r5 = _nt_space
|
758
|
-
if r5
|
759
|
-
r4 = r5
|
760
|
-
else
|
761
|
-
r4 = instantiate_node(SyntaxNode,input, index...index)
|
740
|
+
def _nt_multiplicative
|
741
|
+
start_index = index
|
742
|
+
if node_cache[:multiplicative].has_key?(index)
|
743
|
+
cached = node_cache[:multiplicative][index]
|
744
|
+
if cached
|
745
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
746
|
+
@index = cached.interval.end
|
762
747
|
end
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
748
|
+
return cached
|
749
|
+
end
|
750
|
+
|
751
|
+
i0, s0 = index, []
|
752
|
+
r1 = _nt_value
|
753
|
+
s0 << r1
|
754
|
+
if r1
|
755
|
+
s2, i2 = [], index
|
756
|
+
loop do
|
757
|
+
i3, s3 = index, []
|
758
|
+
r5 = _nt_space
|
759
|
+
if r5
|
760
|
+
r4 = r5
|
761
|
+
else
|
762
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
763
|
+
end
|
764
|
+
s3 << r4
|
765
|
+
if r4
|
766
|
+
r6 = _nt_multiplicative_operator
|
767
|
+
s3 << r6
|
768
|
+
if r6
|
769
|
+
r8 = _nt_space
|
770
|
+
if r8
|
771
|
+
r7 = r8
|
772
|
+
else
|
773
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
774
|
+
end
|
775
|
+
s3 << r7
|
776
|
+
if r7
|
777
|
+
r9 = _nt_value
|
778
|
+
s3 << r9
|
779
|
+
end
|
778
780
|
end
|
779
781
|
end
|
782
|
+
if s3.last
|
783
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
784
|
+
r3.extend(Multiplicative0)
|
785
|
+
else
|
786
|
+
@index = i3
|
787
|
+
r3 = nil
|
788
|
+
end
|
789
|
+
if r3
|
790
|
+
s2 << r3
|
791
|
+
else
|
792
|
+
break
|
793
|
+
end
|
780
794
|
end
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
else
|
791
|
-
break
|
792
|
-
end
|
795
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
796
|
+
s0 << r2
|
797
|
+
end
|
798
|
+
if s0.last
|
799
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
800
|
+
r0.extend(Multiplicative1)
|
801
|
+
else
|
802
|
+
@index = i0
|
803
|
+
r0 = nil
|
793
804
|
end
|
794
|
-
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
795
|
-
s0 << r2
|
796
|
-
end
|
797
|
-
if s0.last
|
798
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
799
|
-
r0.extend(Multiplicative1)
|
800
|
-
else
|
801
|
-
@index = i0
|
802
|
-
r0 = nil
|
803
|
-
end
|
804
805
|
|
805
|
-
|
806
|
+
node_cache[:multiplicative][start_index] = r0
|
806
807
|
|
807
|
-
|
808
|
-
|
808
|
+
r0
|
809
|
+
end
|
809
810
|
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
811
|
+
def _nt_multiplicative_operator
|
812
|
+
start_index = index
|
813
|
+
if node_cache[:multiplicative_operator].has_key?(index)
|
814
|
+
cached = node_cache[:multiplicative_operator][index]
|
815
|
+
if cached
|
816
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
817
|
+
@index = cached.interval.end
|
818
|
+
end
|
819
|
+
return cached
|
817
820
|
end
|
818
|
-
return cached
|
819
|
-
end
|
820
821
|
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
@index += 1
|
825
|
-
else
|
826
|
-
terminal_parse_failure('^')
|
827
|
-
r1 = nil
|
828
|
-
end
|
829
|
-
if r1
|
830
|
-
r0 = r1
|
831
|
-
else
|
832
|
-
if has_terminal?('*', false, index)
|
833
|
-
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
822
|
+
i0 = index
|
823
|
+
if has_terminal?('^', false, index)
|
824
|
+
r1 = instantiate_node(Pow,input, index...(index + 1))
|
834
825
|
@index += 1
|
835
826
|
else
|
836
|
-
terminal_parse_failure('
|
837
|
-
|
827
|
+
terminal_parse_failure('^')
|
828
|
+
r1 = nil
|
838
829
|
end
|
839
|
-
if
|
840
|
-
r0 =
|
830
|
+
if r1
|
831
|
+
r0 = r1
|
841
832
|
else
|
842
|
-
if has_terminal?('
|
843
|
-
|
833
|
+
if has_terminal?('*', false, index)
|
834
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
844
835
|
@index += 1
|
845
836
|
else
|
846
|
-
terminal_parse_failure('
|
847
|
-
|
837
|
+
terminal_parse_failure('*')
|
838
|
+
r2 = nil
|
848
839
|
end
|
849
|
-
if
|
850
|
-
r0 =
|
840
|
+
if r2
|
841
|
+
r0 = r2
|
851
842
|
else
|
852
|
-
|
853
|
-
|
843
|
+
if has_terminal?('/', false, index)
|
844
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
845
|
+
@index += 1
|
846
|
+
else
|
847
|
+
terminal_parse_failure('/')
|
848
|
+
r3 = nil
|
849
|
+
end
|
850
|
+
if r3
|
851
|
+
r0 = r3
|
852
|
+
else
|
853
|
+
@index = i0
|
854
|
+
r0 = nil
|
855
|
+
end
|
854
856
|
end
|
855
857
|
end
|
856
|
-
end
|
857
858
|
|
858
|
-
|
859
|
+
node_cache[:multiplicative_operator][start_index] = r0
|
859
860
|
|
860
|
-
|
861
|
-
end
|
862
|
-
|
863
|
-
module Value0
|
864
|
-
def expression
|
865
|
-
elements[2]
|
861
|
+
r0
|
866
862
|
end
|
867
863
|
|
868
|
-
|
864
|
+
module Value0
|
865
|
+
def expression
|
866
|
+
elements[2]
|
867
|
+
end
|
869
868
|
|
870
|
-
module Value1
|
871
|
-
def value
|
872
|
-
elements[1]
|
873
869
|
end
|
874
|
-
end
|
875
870
|
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
cached = node_cache[:value][index]
|
880
|
-
if cached
|
881
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
882
|
-
@index = cached.interval.end
|
871
|
+
module Value1
|
872
|
+
def value
|
873
|
+
elements[1]
|
883
874
|
end
|
884
|
-
return cached
|
885
875
|
end
|
886
876
|
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
877
|
+
def _nt_value
|
878
|
+
start_index = index
|
879
|
+
if node_cache[:value].has_key?(index)
|
880
|
+
cached = node_cache[:value][index]
|
881
|
+
if cached
|
882
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
883
|
+
@index = cached.interval.end
|
884
|
+
end
|
885
|
+
return cached
|
886
|
+
end
|
887
|
+
|
888
|
+
i0 = index
|
889
|
+
r1 = _nt_function
|
890
|
+
if r1
|
891
|
+
r0 = r1
|
896
892
|
else
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
if r3
|
902
|
-
r5 = _nt_space
|
903
|
-
if r5
|
904
|
-
r4 = r5
|
893
|
+
i2, s2 = index, []
|
894
|
+
if has_terminal?('(', false, index)
|
895
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
896
|
+
@index += 1
|
905
897
|
else
|
906
|
-
|
898
|
+
terminal_parse_failure('(')
|
899
|
+
r3 = nil
|
907
900
|
end
|
908
|
-
s2 <<
|
909
|
-
if
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
s2 <<
|
920
|
-
if
|
921
|
-
|
922
|
-
|
923
|
-
|
901
|
+
s2 << r3
|
902
|
+
if r3
|
903
|
+
r5 = _nt_space
|
904
|
+
if r5
|
905
|
+
r4 = r5
|
906
|
+
else
|
907
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
908
|
+
end
|
909
|
+
s2 << r4
|
910
|
+
if r4
|
911
|
+
r6 = _nt_expression
|
912
|
+
s2 << r6
|
913
|
+
if r6
|
914
|
+
r8 = _nt_space
|
915
|
+
if r8
|
916
|
+
r7 = r8
|
924
917
|
else
|
925
|
-
|
926
|
-
|
918
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
919
|
+
end
|
920
|
+
s2 << r7
|
921
|
+
if r7
|
922
|
+
if has_terminal?(')', false, index)
|
923
|
+
r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
924
|
+
@index += 1
|
925
|
+
else
|
926
|
+
terminal_parse_failure(')')
|
927
|
+
r9 = nil
|
928
|
+
end
|
929
|
+
s2 << r9
|
927
930
|
end
|
928
|
-
s2 << r9
|
929
931
|
end
|
930
932
|
end
|
931
933
|
end
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
r2.extend(Value0)
|
936
|
-
else
|
937
|
-
@index = i2
|
938
|
-
r2 = nil
|
939
|
-
end
|
940
|
-
if r2
|
941
|
-
r0 = r2
|
942
|
-
else
|
943
|
-
r10 = _nt_range
|
944
|
-
if r10
|
945
|
-
r0 = r10
|
934
|
+
if s2.last
|
935
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
936
|
+
r2.extend(Value0)
|
946
937
|
else
|
947
|
-
|
948
|
-
|
949
|
-
|
938
|
+
@index = i2
|
939
|
+
r2 = nil
|
940
|
+
end
|
941
|
+
if r2
|
942
|
+
r0 = r2
|
943
|
+
else
|
944
|
+
r10 = _nt_range
|
945
|
+
if r10
|
946
|
+
r0 = r10
|
950
947
|
else
|
951
|
-
|
952
|
-
if
|
953
|
-
r0 =
|
948
|
+
r11 = _nt_number
|
949
|
+
if r11
|
950
|
+
r0 = r11
|
954
951
|
else
|
955
|
-
|
956
|
-
if
|
957
|
-
r0 =
|
952
|
+
r12 = _nt_boolean
|
953
|
+
if r12
|
954
|
+
r0 = r12
|
958
955
|
else
|
959
|
-
|
960
|
-
if
|
961
|
-
r0 =
|
956
|
+
r13 = _nt_identifier
|
957
|
+
if r13
|
958
|
+
r0 = r13
|
962
959
|
else
|
963
|
-
|
964
|
-
if
|
965
|
-
|
966
|
-
@index += 1
|
967
|
-
else
|
968
|
-
terminal_parse_failure('-')
|
969
|
-
r16 = nil
|
970
|
-
end
|
971
|
-
s15 << r16
|
972
|
-
if r16
|
973
|
-
r17 = _nt_value
|
974
|
-
s15 << r17
|
975
|
-
end
|
976
|
-
if s15.last
|
977
|
-
r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
|
978
|
-
r15.extend(Value1)
|
979
|
-
else
|
980
|
-
@index = i15
|
981
|
-
r15 = nil
|
982
|
-
end
|
983
|
-
if r15
|
984
|
-
r0 = r15
|
960
|
+
r14 = _nt_string
|
961
|
+
if r14
|
962
|
+
r0 = r14
|
985
963
|
else
|
986
|
-
|
987
|
-
|
964
|
+
i15, s15 = index, []
|
965
|
+
if has_terminal?('-', false, index)
|
966
|
+
r16 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
967
|
+
@index += 1
|
968
|
+
else
|
969
|
+
terminal_parse_failure('-')
|
970
|
+
r16 = nil
|
971
|
+
end
|
972
|
+
s15 << r16
|
973
|
+
if r16
|
974
|
+
r17 = _nt_value
|
975
|
+
s15 << r17
|
976
|
+
end
|
977
|
+
if s15.last
|
978
|
+
r15 = instantiate_node(SyntaxNode,input, i15...index, s15)
|
979
|
+
r15.extend(Value1)
|
980
|
+
else
|
981
|
+
@index = i15
|
982
|
+
r15 = nil
|
983
|
+
end
|
984
|
+
if r15
|
985
|
+
r0 = r15
|
986
|
+
else
|
987
|
+
@index = i0
|
988
|
+
r0 = nil
|
989
|
+
end
|
988
990
|
end
|
989
991
|
end
|
990
992
|
end
|
@@ -992,883 +994,883 @@ module Soroban
|
|
992
994
|
end
|
993
995
|
end
|
994
996
|
end
|
995
|
-
end
|
996
997
|
|
997
|
-
|
998
|
+
node_cache[:value][start_index] = r0
|
998
999
|
|
999
|
-
|
1000
|
-
|
1000
|
+
r0
|
1001
|
+
end
|
1001
1002
|
|
1002
|
-
|
1003
|
-
|
1003
|
+
module Function0
|
1004
|
+
end
|
1004
1005
|
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1006
|
+
def _nt_function
|
1007
|
+
start_index = index
|
1008
|
+
if node_cache[:function].has_key?(index)
|
1009
|
+
cached = node_cache[:function][index]
|
1010
|
+
if cached
|
1011
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1012
|
+
@index = cached.interval.end
|
1013
|
+
end
|
1014
|
+
return cached
|
1012
1015
|
end
|
1013
|
-
return cached
|
1014
|
-
end
|
1015
1016
|
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1017
|
+
i0, s0 = index, []
|
1018
|
+
s1, i1 = [], index
|
1019
|
+
loop do
|
1020
|
+
if has_terminal?('\G[a-zA-Z]', true, index)
|
1021
|
+
r2 = true
|
1022
|
+
@index += 1
|
1023
|
+
else
|
1024
|
+
r2 = nil
|
1025
|
+
end
|
1026
|
+
if r2
|
1027
|
+
s1 << r2
|
1028
|
+
else
|
1029
|
+
break
|
1030
|
+
end
|
1024
1031
|
end
|
1025
|
-
if
|
1026
|
-
|
1032
|
+
if s1.empty?
|
1033
|
+
@index = i1
|
1034
|
+
r1 = nil
|
1027
1035
|
else
|
1028
|
-
|
1036
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1029
1037
|
end
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1036
|
-
end
|
1037
|
-
s0 << r1
|
1038
|
-
if r1
|
1039
|
-
if has_terminal?('(', false, index)
|
1040
|
-
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1041
|
-
@index += 1
|
1042
|
-
else
|
1043
|
-
terminal_parse_failure('(')
|
1044
|
-
r3 = nil
|
1045
|
-
end
|
1046
|
-
s0 << r3
|
1047
|
-
if r3
|
1048
|
-
r5 = _nt_space
|
1049
|
-
if r5
|
1050
|
-
r4 = r5
|
1038
|
+
s0 << r1
|
1039
|
+
if r1
|
1040
|
+
if has_terminal?('(', false, index)
|
1041
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1042
|
+
@index += 1
|
1051
1043
|
else
|
1052
|
-
|
1044
|
+
terminal_parse_failure('(')
|
1045
|
+
r3 = nil
|
1053
1046
|
end
|
1054
|
-
s0 <<
|
1055
|
-
if
|
1056
|
-
|
1057
|
-
if
|
1058
|
-
|
1047
|
+
s0 << r3
|
1048
|
+
if r3
|
1049
|
+
r5 = _nt_space
|
1050
|
+
if r5
|
1051
|
+
r4 = r5
|
1059
1052
|
else
|
1060
|
-
|
1053
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
1061
1054
|
end
|
1062
|
-
s0 <<
|
1063
|
-
if
|
1064
|
-
|
1065
|
-
if
|
1066
|
-
|
1055
|
+
s0 << r4
|
1056
|
+
if r4
|
1057
|
+
r7 = _nt_arguments
|
1058
|
+
if r7
|
1059
|
+
r6 = r7
|
1067
1060
|
else
|
1068
|
-
|
1061
|
+
r6 = instantiate_node(SyntaxNode,input, index...index)
|
1069
1062
|
end
|
1070
|
-
s0 <<
|
1071
|
-
if
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1063
|
+
s0 << r6
|
1064
|
+
if r6
|
1065
|
+
r9 = _nt_space
|
1066
|
+
if r9
|
1067
|
+
r8 = r9
|
1075
1068
|
else
|
1076
|
-
|
1077
|
-
|
1069
|
+
r8 = instantiate_node(SyntaxNode,input, index...index)
|
1070
|
+
end
|
1071
|
+
s0 << r8
|
1072
|
+
if r8
|
1073
|
+
if has_terminal?(')', false, index)
|
1074
|
+
r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1075
|
+
@index += 1
|
1076
|
+
else
|
1077
|
+
terminal_parse_failure(')')
|
1078
|
+
r10 = nil
|
1079
|
+
end
|
1080
|
+
s0 << r10
|
1078
1081
|
end
|
1079
|
-
s0 << r10
|
1080
1082
|
end
|
1081
1083
|
end
|
1082
1084
|
end
|
1083
1085
|
end
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
end
|
1092
|
-
|
1093
|
-
node_cache[:function][start_index] = r0
|
1086
|
+
if s0.last
|
1087
|
+
r0 = instantiate_node(Function,input, i0...index, s0)
|
1088
|
+
r0.extend(Function0)
|
1089
|
+
else
|
1090
|
+
@index = i0
|
1091
|
+
r0 = nil
|
1092
|
+
end
|
1094
1093
|
|
1095
|
-
|
1096
|
-
end
|
1094
|
+
node_cache[:function][start_index] = r0
|
1097
1095
|
|
1098
|
-
|
1099
|
-
def logical
|
1100
|
-
elements[3]
|
1096
|
+
r0
|
1101
1097
|
end
|
1102
|
-
end
|
1103
1098
|
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1099
|
+
module Arguments0
|
1100
|
+
def logical
|
1101
|
+
elements[3]
|
1102
|
+
end
|
1107
1103
|
end
|
1108
1104
|
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
start_index = index
|
1113
|
-
if node_cache[:arguments].has_key?(index)
|
1114
|
-
cached = node_cache[:arguments][index]
|
1115
|
-
if cached
|
1116
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1117
|
-
@index = cached.interval.end
|
1105
|
+
module Arguments1
|
1106
|
+
def logical
|
1107
|
+
elements[0]
|
1118
1108
|
end
|
1119
|
-
|
1109
|
+
|
1120
1110
|
end
|
1121
1111
|
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
r5 = _nt_space
|
1130
|
-
if r5
|
1131
|
-
r4 = r5
|
1132
|
-
else
|
1133
|
-
r4 = instantiate_node(SyntaxNode,input, index...index)
|
1112
|
+
def _nt_arguments
|
1113
|
+
start_index = index
|
1114
|
+
if node_cache[:arguments].has_key?(index)
|
1115
|
+
cached = node_cache[:arguments][index]
|
1116
|
+
if cached
|
1117
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1118
|
+
@index = cached.interval.end
|
1134
1119
|
end
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1120
|
+
return cached
|
1121
|
+
end
|
1122
|
+
|
1123
|
+
i0, s0 = index, []
|
1124
|
+
r1 = _nt_logical
|
1125
|
+
s0 << r1
|
1126
|
+
if r1
|
1127
|
+
s2, i2 = [], index
|
1128
|
+
loop do
|
1129
|
+
i3, s3 = index, []
|
1130
|
+
r5 = _nt_space
|
1131
|
+
if r5
|
1132
|
+
r4 = r5
|
1140
1133
|
else
|
1141
|
-
|
1142
|
-
r6 = nil
|
1134
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
1143
1135
|
end
|
1144
|
-
s3 <<
|
1145
|
-
if
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1136
|
+
s3 << r4
|
1137
|
+
if r4
|
1138
|
+
if has_terminal?(',', false, index)
|
1139
|
+
r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1140
|
+
@index += 1
|
1149
1141
|
else
|
1150
|
-
|
1142
|
+
terminal_parse_failure(',')
|
1143
|
+
r6 = nil
|
1151
1144
|
end
|
1152
|
-
s3 <<
|
1153
|
-
if
|
1154
|
-
|
1155
|
-
|
1145
|
+
s3 << r6
|
1146
|
+
if r6
|
1147
|
+
r8 = _nt_space
|
1148
|
+
if r8
|
1149
|
+
r7 = r8
|
1150
|
+
else
|
1151
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
1152
|
+
end
|
1153
|
+
s3 << r7
|
1154
|
+
if r7
|
1155
|
+
r9 = _nt_logical
|
1156
|
+
s3 << r9
|
1157
|
+
end
|
1156
1158
|
end
|
1157
1159
|
end
|
1160
|
+
if s3.last
|
1161
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1162
|
+
r3.extend(Arguments0)
|
1163
|
+
else
|
1164
|
+
@index = i3
|
1165
|
+
r3 = nil
|
1166
|
+
end
|
1167
|
+
if r3
|
1168
|
+
s2 << r3
|
1169
|
+
else
|
1170
|
+
break
|
1171
|
+
end
|
1158
1172
|
end
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
else
|
1169
|
-
break
|
1170
|
-
end
|
1173
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1174
|
+
s0 << r2
|
1175
|
+
end
|
1176
|
+
if s0.last
|
1177
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1178
|
+
r0.extend(Arguments1)
|
1179
|
+
else
|
1180
|
+
@index = i0
|
1181
|
+
r0 = nil
|
1171
1182
|
end
|
1172
|
-
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1173
|
-
s0 << r2
|
1174
|
-
end
|
1175
|
-
if s0.last
|
1176
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1177
|
-
r0.extend(Arguments1)
|
1178
|
-
else
|
1179
|
-
@index = i0
|
1180
|
-
r0 = nil
|
1181
|
-
end
|
1182
|
-
|
1183
|
-
node_cache[:arguments][start_index] = r0
|
1184
1183
|
|
1185
|
-
|
1186
|
-
end
|
1184
|
+
node_cache[:arguments][start_index] = r0
|
1187
1185
|
|
1188
|
-
|
1189
|
-
def float
|
1190
|
-
elements[1]
|
1186
|
+
r0
|
1191
1187
|
end
|
1192
|
-
end
|
1193
1188
|
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1189
|
+
module Number0
|
1190
|
+
def float
|
1191
|
+
elements[1]
|
1192
|
+
end
|
1197
1193
|
end
|
1198
|
-
end
|
1199
1194
|
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
cached = node_cache[:number][index]
|
1204
|
-
if cached
|
1205
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1206
|
-
@index = cached.interval.end
|
1195
|
+
module Number1
|
1196
|
+
def integer
|
1197
|
+
elements[1]
|
1207
1198
|
end
|
1208
|
-
return cached
|
1209
1199
|
end
|
1210
1200
|
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
r0 = r2
|
1219
|
-
else
|
1220
|
-
i3, s3 = index, []
|
1221
|
-
if has_terminal?('-', false, index)
|
1222
|
-
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1223
|
-
@index += 1
|
1224
|
-
else
|
1225
|
-
terminal_parse_failure('-')
|
1226
|
-
r4 = nil
|
1227
|
-
end
|
1228
|
-
s3 << r4
|
1229
|
-
if r4
|
1230
|
-
r5 = _nt_float
|
1231
|
-
s3 << r5
|
1201
|
+
def _nt_number
|
1202
|
+
start_index = index
|
1203
|
+
if node_cache[:number].has_key?(index)
|
1204
|
+
cached = node_cache[:number][index]
|
1205
|
+
if cached
|
1206
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1207
|
+
@index = cached.interval.end
|
1232
1208
|
end
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1209
|
+
return cached
|
1210
|
+
end
|
1211
|
+
|
1212
|
+
i0 = index
|
1213
|
+
r1 = _nt_float
|
1214
|
+
if r1
|
1215
|
+
r0 = r1
|
1216
|
+
else
|
1217
|
+
r2 = _nt_integer
|
1218
|
+
if r2
|
1219
|
+
r0 = r2
|
1242
1220
|
else
|
1243
|
-
|
1221
|
+
i3, s3 = index, []
|
1244
1222
|
if has_terminal?('-', false, index)
|
1245
|
-
|
1223
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1246
1224
|
@index += 1
|
1247
1225
|
else
|
1248
1226
|
terminal_parse_failure('-')
|
1249
|
-
|
1227
|
+
r4 = nil
|
1250
1228
|
end
|
1251
|
-
|
1252
|
-
if
|
1253
|
-
|
1254
|
-
|
1229
|
+
s3 << r4
|
1230
|
+
if r4
|
1231
|
+
r5 = _nt_float
|
1232
|
+
s3 << r5
|
1255
1233
|
end
|
1256
|
-
if
|
1257
|
-
|
1258
|
-
|
1234
|
+
if s3.last
|
1235
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1236
|
+
r3.extend(Number0)
|
1259
1237
|
else
|
1260
|
-
@index =
|
1261
|
-
|
1238
|
+
@index = i3
|
1239
|
+
r3 = nil
|
1262
1240
|
end
|
1263
|
-
if
|
1264
|
-
r0 =
|
1241
|
+
if r3
|
1242
|
+
r0 = r3
|
1265
1243
|
else
|
1266
|
-
|
1267
|
-
|
1244
|
+
i6, s6 = index, []
|
1245
|
+
if has_terminal?('-', false, index)
|
1246
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1247
|
+
@index += 1
|
1248
|
+
else
|
1249
|
+
terminal_parse_failure('-')
|
1250
|
+
r7 = nil
|
1251
|
+
end
|
1252
|
+
s6 << r7
|
1253
|
+
if r7
|
1254
|
+
r8 = _nt_integer
|
1255
|
+
s6 << r8
|
1256
|
+
end
|
1257
|
+
if s6.last
|
1258
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
1259
|
+
r6.extend(Number1)
|
1260
|
+
else
|
1261
|
+
@index = i6
|
1262
|
+
r6 = nil
|
1263
|
+
end
|
1264
|
+
if r6
|
1265
|
+
r0 = r6
|
1266
|
+
else
|
1267
|
+
@index = i0
|
1268
|
+
r0 = nil
|
1269
|
+
end
|
1268
1270
|
end
|
1269
1271
|
end
|
1270
1272
|
end
|
1271
|
-
end
|
1272
|
-
|
1273
|
-
node_cache[:number][start_index] = r0
|
1274
1273
|
|
1275
|
-
|
1276
|
-
end
|
1274
|
+
node_cache[:number][start_index] = r0
|
1277
1275
|
|
1278
|
-
|
1279
|
-
|
1276
|
+
r0
|
1277
|
+
end
|
1280
1278
|
|
1281
|
-
|
1282
|
-
start_index = index
|
1283
|
-
if node_cache[:float].has_key?(index)
|
1284
|
-
cached = node_cache[:float][index]
|
1285
|
-
if cached
|
1286
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1287
|
-
@index = cached.interval.end
|
1288
|
-
end
|
1289
|
-
return cached
|
1279
|
+
module Float0
|
1290
1280
|
end
|
1291
1281
|
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
if r2
|
1302
|
-
s1 << r2
|
1303
|
-
else
|
1304
|
-
break
|
1282
|
+
def _nt_float
|
1283
|
+
start_index = index
|
1284
|
+
if node_cache[:float].has_key?(index)
|
1285
|
+
cached = node_cache[:float][index]
|
1286
|
+
if cached
|
1287
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1288
|
+
@index = cached.interval.end
|
1289
|
+
end
|
1290
|
+
return cached
|
1305
1291
|
end
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1292
|
+
|
1293
|
+
i0, s0 = index, []
|
1294
|
+
s1, i1 = [], index
|
1295
|
+
loop do
|
1296
|
+
if has_terminal?('\G[0-9]', true, index)
|
1297
|
+
r2 = true
|
1298
|
+
@index += 1
|
1299
|
+
else
|
1300
|
+
r2 = nil
|
1301
|
+
end
|
1302
|
+
if r2
|
1303
|
+
s1 << r2
|
1304
|
+
else
|
1305
|
+
break
|
1306
|
+
end
|
1316
1307
|
end
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1308
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1309
|
+
s0 << r1
|
1310
|
+
if r1
|
1311
|
+
if has_terminal?('.', false, index)
|
1312
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1313
|
+
@index += 1
|
1314
|
+
else
|
1315
|
+
terminal_parse_failure('.')
|
1316
|
+
r3 = nil
|
1317
|
+
end
|
1318
|
+
s0 << r3
|
1319
|
+
if r3
|
1320
|
+
s4, i4 = [], index
|
1321
|
+
loop do
|
1322
|
+
if has_terminal?('\G[0-9]', true, index)
|
1323
|
+
r5 = true
|
1324
|
+
@index += 1
|
1325
|
+
else
|
1326
|
+
r5 = nil
|
1327
|
+
end
|
1328
|
+
if r5
|
1329
|
+
s4 << r5
|
1330
|
+
else
|
1331
|
+
break
|
1332
|
+
end
|
1326
1333
|
end
|
1327
|
-
if
|
1328
|
-
|
1334
|
+
if s4.empty?
|
1335
|
+
@index = i4
|
1336
|
+
r4 = nil
|
1329
1337
|
else
|
1330
|
-
|
1338
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
1331
1339
|
end
|
1340
|
+
s0 << r4
|
1332
1341
|
end
|
1333
|
-
if s4.empty?
|
1334
|
-
@index = i4
|
1335
|
-
r4 = nil
|
1336
|
-
else
|
1337
|
-
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
1338
|
-
end
|
1339
|
-
s0 << r4
|
1340
|
-
end
|
1341
|
-
end
|
1342
|
-
if s0.last
|
1343
|
-
r0 = instantiate_node(FloatValue,input, i0...index, s0)
|
1344
|
-
r0.extend(Float0)
|
1345
|
-
else
|
1346
|
-
@index = i0
|
1347
|
-
r0 = nil
|
1348
|
-
end
|
1349
|
-
|
1350
|
-
node_cache[:float][start_index] = r0
|
1351
|
-
|
1352
|
-
r0
|
1353
|
-
end
|
1354
|
-
|
1355
|
-
def _nt_integer
|
1356
|
-
start_index = index
|
1357
|
-
if node_cache[:integer].has_key?(index)
|
1358
|
-
cached = node_cache[:integer][index]
|
1359
|
-
if cached
|
1360
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1361
|
-
@index = cached.interval.end
|
1362
1342
|
end
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
s0, i0 = [], index
|
1367
|
-
loop do
|
1368
|
-
if has_terminal?('\G[0-9]', true, index)
|
1369
|
-
r1 = true
|
1370
|
-
@index += 1
|
1343
|
+
if s0.last
|
1344
|
+
r0 = instantiate_node(FloatValue,input, i0...index, s0)
|
1345
|
+
r0.extend(Float0)
|
1371
1346
|
else
|
1372
|
-
|
1373
|
-
|
1374
|
-
if r1
|
1375
|
-
s0 << r1
|
1376
|
-
else
|
1377
|
-
break
|
1347
|
+
@index = i0
|
1348
|
+
r0 = nil
|
1378
1349
|
end
|
1379
|
-
end
|
1380
|
-
if s0.empty?
|
1381
|
-
@index = i0
|
1382
|
-
r0 = nil
|
1383
|
-
else
|
1384
|
-
r0 = instantiate_node(IntegerValue,input, i0...index, s0)
|
1385
|
-
end
|
1386
1350
|
|
1387
|
-
|
1388
|
-
|
1389
|
-
r0
|
1390
|
-
end
|
1351
|
+
node_cache[:float][start_index] = r0
|
1391
1352
|
|
1392
|
-
|
1393
|
-
|
1353
|
+
r0
|
1354
|
+
end
|
1394
1355
|
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1356
|
+
def _nt_integer
|
1357
|
+
start_index = index
|
1358
|
+
if node_cache[:integer].has_key?(index)
|
1359
|
+
cached = node_cache[:integer][index]
|
1360
|
+
if cached
|
1361
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1362
|
+
@index = cached.interval.end
|
1363
|
+
end
|
1364
|
+
return cached
|
1402
1365
|
end
|
1403
|
-
return cached
|
1404
|
-
end
|
1405
1366
|
|
1406
|
-
|
1407
|
-
if has_terminal?('\G[a-zA-Z]', true, index)
|
1408
|
-
r1 = true
|
1409
|
-
@index += 1
|
1410
|
-
else
|
1411
|
-
r1 = nil
|
1412
|
-
end
|
1413
|
-
s0 << r1
|
1414
|
-
if r1
|
1415
|
-
s2, i2 = [], index
|
1367
|
+
s0, i0 = [], index
|
1416
1368
|
loop do
|
1417
|
-
if has_terminal?('\G[
|
1418
|
-
|
1369
|
+
if has_terminal?('\G[0-9]', true, index)
|
1370
|
+
r1 = true
|
1419
1371
|
@index += 1
|
1420
1372
|
else
|
1421
|
-
|
1373
|
+
r1 = nil
|
1422
1374
|
end
|
1423
|
-
if
|
1424
|
-
|
1375
|
+
if r1
|
1376
|
+
s0 << r1
|
1425
1377
|
else
|
1426
1378
|
break
|
1427
1379
|
end
|
1428
1380
|
end
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
else
|
1436
|
-
@index = i0
|
1437
|
-
r0 = nil
|
1438
|
-
end
|
1439
|
-
|
1440
|
-
node_cache[:identifier][start_index] = r0
|
1441
|
-
|
1442
|
-
r0
|
1443
|
-
end
|
1381
|
+
if s0.empty?
|
1382
|
+
@index = i0
|
1383
|
+
r0 = nil
|
1384
|
+
else
|
1385
|
+
r0 = instantiate_node(IntegerValue,input, i0...index, s0)
|
1386
|
+
end
|
1444
1387
|
|
1445
|
-
|
1446
|
-
end
|
1388
|
+
node_cache[:integer][start_index] = r0
|
1447
1389
|
|
1448
|
-
|
1449
|
-
|
1390
|
+
r0
|
1391
|
+
end
|
1450
1392
|
|
1451
|
-
|
1452
|
-
start_index = index
|
1453
|
-
if node_cache[:label].has_key?(index)
|
1454
|
-
cached = node_cache[:label][index]
|
1455
|
-
if cached
|
1456
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1457
|
-
@index = cached.interval.end
|
1458
|
-
end
|
1459
|
-
return cached
|
1393
|
+
module Identifier0
|
1460
1394
|
end
|
1461
1395
|
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
end
|
1472
|
-
if r3
|
1473
|
-
s2 << r3
|
1474
|
-
else
|
1475
|
-
break
|
1396
|
+
def _nt_identifier
|
1397
|
+
start_index = index
|
1398
|
+
if node_cache[:identifier].has_key?(index)
|
1399
|
+
cached = node_cache[:identifier][index]
|
1400
|
+
if cached
|
1401
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1402
|
+
@index = cached.interval.end
|
1403
|
+
end
|
1404
|
+
return cached
|
1476
1405
|
end
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
else
|
1482
|
-
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1483
|
-
end
|
1484
|
-
s1 << r2
|
1485
|
-
if r2
|
1486
|
-
if has_terminal?('\G[1-9]', true, index)
|
1487
|
-
r4 = true
|
1406
|
+
|
1407
|
+
i0, s0 = index, []
|
1408
|
+
if has_terminal?('\G[a-zA-Z]', true, index)
|
1409
|
+
r1 = true
|
1488
1410
|
@index += 1
|
1489
1411
|
else
|
1490
|
-
|
1412
|
+
r1 = nil
|
1491
1413
|
end
|
1492
|
-
|
1493
|
-
if
|
1494
|
-
|
1414
|
+
s0 << r1
|
1415
|
+
if r1
|
1416
|
+
s2, i2 = [], index
|
1495
1417
|
loop do
|
1496
|
-
if has_terminal?('\G[
|
1497
|
-
|
1418
|
+
if has_terminal?('\G[a-zA-Z0-9]', true, index)
|
1419
|
+
r3 = true
|
1498
1420
|
@index += 1
|
1499
1421
|
else
|
1500
|
-
|
1422
|
+
r3 = nil
|
1501
1423
|
end
|
1502
|
-
if
|
1503
|
-
|
1424
|
+
if r3
|
1425
|
+
s2 << r3
|
1504
1426
|
else
|
1505
1427
|
break
|
1506
1428
|
end
|
1507
1429
|
end
|
1508
|
-
|
1509
|
-
|
1430
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1431
|
+
s0 << r2
|
1510
1432
|
end
|
1433
|
+
if s0.last
|
1434
|
+
r0 = instantiate_node(Identifier,input, i0...index, s0)
|
1435
|
+
r0.extend(Identifier0)
|
1436
|
+
else
|
1437
|
+
@index = i0
|
1438
|
+
r0 = nil
|
1439
|
+
end
|
1440
|
+
|
1441
|
+
node_cache[:identifier][start_index] = r0
|
1442
|
+
|
1443
|
+
r0
|
1511
1444
|
end
|
1512
|
-
|
1513
|
-
|
1514
|
-
r1.extend(Label0)
|
1515
|
-
else
|
1516
|
-
@index = i1
|
1517
|
-
r1 = nil
|
1445
|
+
|
1446
|
+
module Label0
|
1518
1447
|
end
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1448
|
+
|
1449
|
+
module Label1
|
1450
|
+
end
|
1451
|
+
|
1452
|
+
def _nt_label
|
1453
|
+
start_index = index
|
1454
|
+
if node_cache[:label].has_key?(index)
|
1455
|
+
cached = node_cache[:label][index]
|
1456
|
+
if cached
|
1457
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1458
|
+
@index = cached.interval.end
|
1459
|
+
end
|
1460
|
+
return cached
|
1529
1461
|
end
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
if r10
|
1541
|
-
s9 << r10
|
1542
|
-
else
|
1543
|
-
break
|
1544
|
-
end
|
1462
|
+
|
1463
|
+
i0 = index
|
1464
|
+
i1, s1 = index, []
|
1465
|
+
s2, i2 = [], index
|
1466
|
+
loop do
|
1467
|
+
if has_terminal?('\G[A-Za-z]', true, index)
|
1468
|
+
r3 = true
|
1469
|
+
@index += 1
|
1470
|
+
else
|
1471
|
+
r3 = nil
|
1545
1472
|
end
|
1546
|
-
if
|
1547
|
-
|
1548
|
-
r9 = nil
|
1473
|
+
if r3
|
1474
|
+
s2 << r3
|
1549
1475
|
else
|
1550
|
-
|
1476
|
+
break
|
1551
1477
|
end
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1478
|
+
end
|
1479
|
+
if s2.empty?
|
1480
|
+
@index = i2
|
1481
|
+
r2 = nil
|
1482
|
+
else
|
1483
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1484
|
+
end
|
1485
|
+
s1 << r2
|
1486
|
+
if r2
|
1487
|
+
if has_terminal?('\G[1-9]', true, index)
|
1488
|
+
r4 = true
|
1489
|
+
@index += 1
|
1490
|
+
else
|
1491
|
+
r4 = nil
|
1492
|
+
end
|
1493
|
+
s1 << r4
|
1494
|
+
if r4
|
1495
|
+
s5, i5 = [], index
|
1496
|
+
loop do
|
1497
|
+
if has_terminal?('\G[0-9]', true, index)
|
1498
|
+
r6 = true
|
1565
1499
|
@index += 1
|
1566
1500
|
else
|
1567
|
-
|
1501
|
+
r6 = nil
|
1568
1502
|
end
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
if has_terminal?('\G[0-9]', true, index)
|
1574
|
-
r14 = true
|
1575
|
-
@index += 1
|
1576
|
-
else
|
1577
|
-
r14 = nil
|
1578
|
-
end
|
1579
|
-
if r14
|
1580
|
-
s13 << r14
|
1581
|
-
else
|
1582
|
-
break
|
1583
|
-
end
|
1584
|
-
end
|
1585
|
-
r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
|
1586
|
-
s7 << r13
|
1503
|
+
if r6
|
1504
|
+
s5 << r6
|
1505
|
+
else
|
1506
|
+
break
|
1587
1507
|
end
|
1588
1508
|
end
|
1509
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
1510
|
+
s1 << r5
|
1589
1511
|
end
|
1590
1512
|
end
|
1591
|
-
if
|
1592
|
-
|
1593
|
-
|
1513
|
+
if s1.last
|
1514
|
+
r1 = instantiate_node(Label,input, i1...index, s1)
|
1515
|
+
r1.extend(Label0)
|
1594
1516
|
else
|
1595
|
-
@index =
|
1596
|
-
|
1517
|
+
@index = i1
|
1518
|
+
r1 = nil
|
1597
1519
|
end
|
1598
|
-
if
|
1599
|
-
r0 =
|
1520
|
+
if r1
|
1521
|
+
r0 = r1
|
1600
1522
|
else
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
node_cache[:label][start_index] = r0
|
1607
|
-
|
1608
|
-
r0
|
1609
|
-
end
|
1610
|
-
|
1611
|
-
module String0
|
1612
|
-
end
|
1613
|
-
|
1614
|
-
module String1
|
1615
|
-
end
|
1616
|
-
|
1617
|
-
module String2
|
1618
|
-
end
|
1619
|
-
|
1620
|
-
def _nt_string
|
1621
|
-
start_index = index
|
1622
|
-
if node_cache[:string].has_key?(index)
|
1623
|
-
cached = node_cache[:string][index]
|
1624
|
-
if cached
|
1625
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1626
|
-
@index = cached.interval.end
|
1627
|
-
end
|
1628
|
-
return cached
|
1629
|
-
end
|
1630
|
-
|
1631
|
-
i0 = index
|
1632
|
-
i1, s1 = index, []
|
1633
|
-
if has_terminal?('"', false, index)
|
1634
|
-
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1635
|
-
@index += 1
|
1636
|
-
else
|
1637
|
-
terminal_parse_failure('"')
|
1638
|
-
r2 = nil
|
1639
|
-
end
|
1640
|
-
s1 << r2
|
1641
|
-
if r2
|
1642
|
-
s3, i3 = [], index
|
1643
|
-
loop do
|
1644
|
-
i4 = index
|
1645
|
-
if has_terminal?('\"', false, index)
|
1646
|
-
r5 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1647
|
-
@index += 2
|
1523
|
+
i7, s7 = index, []
|
1524
|
+
if has_terminal?('$', false, index)
|
1525
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1526
|
+
@index += 1
|
1648
1527
|
else
|
1649
|
-
terminal_parse_failure('
|
1650
|
-
|
1528
|
+
terminal_parse_failure('$')
|
1529
|
+
r8 = nil
|
1651
1530
|
end
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1659
|
-
@index += 1
|
1660
|
-
else
|
1661
|
-
terminal_parse_failure('"')
|
1662
|
-
r8 = nil
|
1663
|
-
end
|
1664
|
-
if r8
|
1665
|
-
r7 = nil
|
1666
|
-
else
|
1667
|
-
@index = i7
|
1668
|
-
r7 = instantiate_node(SyntaxNode,input, index...index)
|
1669
|
-
end
|
1670
|
-
s6 << r7
|
1671
|
-
if r7
|
1672
|
-
if index < input_length
|
1673
|
-
r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1531
|
+
s7 << r8
|
1532
|
+
if r8
|
1533
|
+
s9, i9 = [], index
|
1534
|
+
loop do
|
1535
|
+
if has_terminal?('\G[A-Za-z]', true, index)
|
1536
|
+
r10 = true
|
1674
1537
|
@index += 1
|
1675
1538
|
else
|
1676
|
-
|
1677
|
-
|
1539
|
+
r10 = nil
|
1540
|
+
end
|
1541
|
+
if r10
|
1542
|
+
s9 << r10
|
1543
|
+
else
|
1544
|
+
break
|
1678
1545
|
end
|
1679
|
-
s6 << r9
|
1680
1546
|
end
|
1681
|
-
if
|
1682
|
-
|
1683
|
-
|
1547
|
+
if s9.empty?
|
1548
|
+
@index = i9
|
1549
|
+
r9 = nil
|
1684
1550
|
else
|
1685
|
-
|
1686
|
-
r6 = nil
|
1551
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
1687
1552
|
end
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1553
|
+
s7 << r9
|
1554
|
+
if r9
|
1555
|
+
if has_terminal?('$', false, index)
|
1556
|
+
r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1557
|
+
@index += 1
|
1558
|
+
else
|
1559
|
+
terminal_parse_failure('$')
|
1560
|
+
r11 = nil
|
1561
|
+
end
|
1562
|
+
s7 << r11
|
1563
|
+
if r11
|
1564
|
+
if has_terminal?('\G[1-9]', true, index)
|
1565
|
+
r12 = true
|
1566
|
+
@index += 1
|
1567
|
+
else
|
1568
|
+
r12 = nil
|
1569
|
+
end
|
1570
|
+
s7 << r12
|
1571
|
+
if r12
|
1572
|
+
s13, i13 = [], index
|
1573
|
+
loop do
|
1574
|
+
if has_terminal?('\G[0-9]', true, index)
|
1575
|
+
r14 = true
|
1576
|
+
@index += 1
|
1577
|
+
else
|
1578
|
+
r14 = nil
|
1579
|
+
end
|
1580
|
+
if r14
|
1581
|
+
s13 << r14
|
1582
|
+
else
|
1583
|
+
break
|
1584
|
+
end
|
1585
|
+
end
|
1586
|
+
r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
|
1587
|
+
s7 << r13
|
1588
|
+
end
|
1589
|
+
end
|
1693
1590
|
end
|
1694
1591
|
end
|
1695
|
-
if
|
1696
|
-
|
1592
|
+
if s7.last
|
1593
|
+
r7 = instantiate_node(Label,input, i7...index, s7)
|
1594
|
+
r7.extend(Label1)
|
1697
1595
|
else
|
1698
|
-
|
1596
|
+
@index = i7
|
1597
|
+
r7 = nil
|
1699
1598
|
end
|
1700
|
-
|
1701
|
-
|
1702
|
-
s1 << r3
|
1703
|
-
if r3
|
1704
|
-
if has_terminal?('"', false, index)
|
1705
|
-
r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1706
|
-
@index += 1
|
1599
|
+
if r7
|
1600
|
+
r0 = r7
|
1707
1601
|
else
|
1708
|
-
|
1709
|
-
|
1602
|
+
@index = i0
|
1603
|
+
r0 = nil
|
1710
1604
|
end
|
1711
|
-
s1 << r10
|
1712
1605
|
end
|
1606
|
+
|
1607
|
+
node_cache[:label][start_index] = r0
|
1608
|
+
|
1609
|
+
r0
|
1713
1610
|
end
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1611
|
+
|
1612
|
+
module String0
|
1613
|
+
end
|
1614
|
+
|
1615
|
+
module String1
|
1616
|
+
end
|
1617
|
+
|
1618
|
+
module String2
|
1720
1619
|
end
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1620
|
+
|
1621
|
+
def _nt_string
|
1622
|
+
start_index = index
|
1623
|
+
if node_cache[:string].has_key?(index)
|
1624
|
+
cached = node_cache[:string][index]
|
1625
|
+
if cached
|
1626
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1627
|
+
@index = cached.interval.end
|
1628
|
+
end
|
1629
|
+
return cached
|
1630
|
+
end
|
1631
|
+
|
1632
|
+
i0 = index
|
1633
|
+
i1, s1 = index, []
|
1634
|
+
if has_terminal?('"', false, index)
|
1635
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1727
1636
|
@index += 1
|
1728
1637
|
else
|
1729
|
-
terminal_parse_failure("'
|
1730
|
-
|
1638
|
+
terminal_parse_failure('"')
|
1639
|
+
r2 = nil
|
1731
1640
|
end
|
1732
|
-
|
1733
|
-
if
|
1734
|
-
|
1641
|
+
s1 << r2
|
1642
|
+
if r2
|
1643
|
+
s3, i3 = [], index
|
1735
1644
|
loop do
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1645
|
+
i4 = index
|
1646
|
+
if has_terminal?('\"', false, index)
|
1647
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 2))
|
1648
|
+
@index += 2
|
1649
|
+
else
|
1650
|
+
terminal_parse_failure('\"')
|
1651
|
+
r5 = nil
|
1652
|
+
end
|
1653
|
+
if r5
|
1654
|
+
r4 = r5
|
1739
1655
|
else
|
1740
|
-
|
1656
|
+
i6, s6 = index, []
|
1657
|
+
i7 = index
|
1658
|
+
if has_terminal?('"', false, index)
|
1659
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1660
|
+
@index += 1
|
1661
|
+
else
|
1662
|
+
terminal_parse_failure('"')
|
1663
|
+
r8 = nil
|
1664
|
+
end
|
1665
|
+
if r8
|
1666
|
+
r7 = nil
|
1667
|
+
else
|
1668
|
+
@index = i7
|
1669
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
1670
|
+
end
|
1671
|
+
s6 << r7
|
1672
|
+
if r7
|
1673
|
+
if index < input_length
|
1674
|
+
r9 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1675
|
+
@index += 1
|
1676
|
+
else
|
1677
|
+
terminal_parse_failure("any character")
|
1678
|
+
r9 = nil
|
1679
|
+
end
|
1680
|
+
s6 << r9
|
1681
|
+
end
|
1682
|
+
if s6.last
|
1683
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
1684
|
+
r6.extend(String0)
|
1685
|
+
else
|
1686
|
+
@index = i6
|
1687
|
+
r6 = nil
|
1688
|
+
end
|
1689
|
+
if r6
|
1690
|
+
r4 = r6
|
1691
|
+
else
|
1692
|
+
@index = i4
|
1693
|
+
r4 = nil
|
1694
|
+
end
|
1741
1695
|
end
|
1742
|
-
if
|
1743
|
-
|
1696
|
+
if r4
|
1697
|
+
s3 << r4
|
1744
1698
|
else
|
1745
1699
|
break
|
1746
1700
|
end
|
1747
1701
|
end
|
1748
|
-
|
1749
|
-
|
1750
|
-
if
|
1751
|
-
if has_terminal?("'
|
1752
|
-
|
1702
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1703
|
+
s1 << r3
|
1704
|
+
if r3
|
1705
|
+
if has_terminal?('"', false, index)
|
1706
|
+
r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1753
1707
|
@index += 1
|
1754
1708
|
else
|
1755
|
-
terminal_parse_failure("'
|
1756
|
-
|
1709
|
+
terminal_parse_failure('"')
|
1710
|
+
r10 = nil
|
1757
1711
|
end
|
1758
|
-
|
1712
|
+
s1 << r10
|
1759
1713
|
end
|
1760
1714
|
end
|
1761
|
-
if
|
1762
|
-
|
1763
|
-
|
1715
|
+
if s1.last
|
1716
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1717
|
+
r1.extend(String1)
|
1764
1718
|
else
|
1765
|
-
@index =
|
1766
|
-
|
1719
|
+
@index = i1
|
1720
|
+
r1 = nil
|
1767
1721
|
end
|
1768
|
-
if
|
1769
|
-
r0 =
|
1722
|
+
if r1
|
1723
|
+
r0 = r1
|
1770
1724
|
else
|
1771
|
-
|
1772
|
-
|
1725
|
+
i11, s11 = index, []
|
1726
|
+
if has_terminal?("'", false, index)
|
1727
|
+
r12 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1728
|
+
@index += 1
|
1729
|
+
else
|
1730
|
+
terminal_parse_failure("'")
|
1731
|
+
r12 = nil
|
1732
|
+
end
|
1733
|
+
s11 << r12
|
1734
|
+
if r12
|
1735
|
+
s13, i13 = [], index
|
1736
|
+
loop do
|
1737
|
+
if has_terminal?('\G[^\']', true, index)
|
1738
|
+
r14 = true
|
1739
|
+
@index += 1
|
1740
|
+
else
|
1741
|
+
r14 = nil
|
1742
|
+
end
|
1743
|
+
if r14
|
1744
|
+
s13 << r14
|
1745
|
+
else
|
1746
|
+
break
|
1747
|
+
end
|
1748
|
+
end
|
1749
|
+
r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
|
1750
|
+
s11 << r13
|
1751
|
+
if r13
|
1752
|
+
if has_terminal?("'", false, index)
|
1753
|
+
r15 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1754
|
+
@index += 1
|
1755
|
+
else
|
1756
|
+
terminal_parse_failure("'")
|
1757
|
+
r15 = nil
|
1758
|
+
end
|
1759
|
+
s11 << r15
|
1760
|
+
end
|
1761
|
+
end
|
1762
|
+
if s11.last
|
1763
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
1764
|
+
r11.extend(String2)
|
1765
|
+
else
|
1766
|
+
@index = i11
|
1767
|
+
r11 = nil
|
1768
|
+
end
|
1769
|
+
if r11
|
1770
|
+
r0 = r11
|
1771
|
+
else
|
1772
|
+
@index = i0
|
1773
|
+
r0 = nil
|
1774
|
+
end
|
1773
1775
|
end
|
1774
|
-
end
|
1775
1776
|
|
1776
|
-
|
1777
|
+
node_cache[:string][start_index] = r0
|
1777
1778
|
|
1778
|
-
|
1779
|
-
end
|
1780
|
-
|
1781
|
-
module Range0
|
1782
|
-
def label1
|
1783
|
-
elements[0]
|
1779
|
+
r0
|
1784
1780
|
end
|
1785
1781
|
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1782
|
+
module Range0
|
1783
|
+
def label1
|
1784
|
+
elements[0]
|
1785
|
+
end
|
1790
1786
|
|
1791
|
-
|
1792
|
-
|
1793
|
-
if node_cache[:range].has_key?(index)
|
1794
|
-
cached = node_cache[:range][index]
|
1795
|
-
if cached
|
1796
|
-
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1797
|
-
@index = cached.interval.end
|
1787
|
+
def label2
|
1788
|
+
elements[2]
|
1798
1789
|
end
|
1799
|
-
return cached
|
1800
1790
|
end
|
1801
1791
|
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
r2 = nil
|
1792
|
+
def _nt_range
|
1793
|
+
start_index = index
|
1794
|
+
if node_cache[:range].has_key?(index)
|
1795
|
+
cached = node_cache[:range][index]
|
1796
|
+
if cached
|
1797
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1798
|
+
@index = cached.interval.end
|
1799
|
+
end
|
1800
|
+
return cached
|
1812
1801
|
end
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1802
|
+
|
1803
|
+
i0, s0 = index, []
|
1804
|
+
r1 = _nt_label
|
1805
|
+
s0 << r1
|
1806
|
+
if r1
|
1807
|
+
if has_terminal?(':', false, index)
|
1808
|
+
r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
1809
|
+
@index += 1
|
1810
|
+
else
|
1811
|
+
terminal_parse_failure(':')
|
1812
|
+
r2 = nil
|
1813
|
+
end
|
1814
|
+
s0 << r2
|
1815
|
+
if r2
|
1816
|
+
r3 = _nt_label
|
1817
|
+
s0 << r3
|
1818
|
+
end
|
1819
|
+
end
|
1820
|
+
if s0.last
|
1821
|
+
r0 = instantiate_node(Range,input, i0...index, s0)
|
1822
|
+
r0.extend(Range0)
|
1823
|
+
else
|
1824
|
+
@index = i0
|
1825
|
+
r0 = nil
|
1817
1826
|
end
|
1818
|
-
end
|
1819
|
-
if s0.last
|
1820
|
-
r0 = instantiate_node(Range,input, i0...index, s0)
|
1821
|
-
r0.extend(Range0)
|
1822
|
-
else
|
1823
|
-
@index = i0
|
1824
|
-
r0 = nil
|
1825
|
-
end
|
1826
1827
|
|
1827
|
-
|
1828
|
+
node_cache[:range][start_index] = r0
|
1828
1829
|
|
1829
|
-
|
1830
|
-
|
1830
|
+
r0
|
1831
|
+
end
|
1831
1832
|
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1833
|
+
def _nt_space
|
1834
|
+
start_index = index
|
1835
|
+
if node_cache[:space].has_key?(index)
|
1836
|
+
cached = node_cache[:space][index]
|
1837
|
+
if cached
|
1838
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1839
|
+
@index = cached.interval.end
|
1840
|
+
end
|
1841
|
+
return cached
|
1839
1842
|
end
|
1840
|
-
return cached
|
1841
|
-
end
|
1842
1843
|
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1844
|
+
s0, i0 = [], index
|
1845
|
+
loop do
|
1846
|
+
if has_terminal?('\G[\\s]', true, index)
|
1847
|
+
r1 = true
|
1848
|
+
@index += 1
|
1849
|
+
else
|
1850
|
+
r1 = nil
|
1851
|
+
end
|
1852
|
+
if r1
|
1853
|
+
s0 << r1
|
1854
|
+
else
|
1855
|
+
break
|
1856
|
+
end
|
1850
1857
|
end
|
1851
|
-
if
|
1852
|
-
|
1858
|
+
if s0.empty?
|
1859
|
+
@index = i0
|
1860
|
+
r0 = nil
|
1853
1861
|
else
|
1854
|
-
|
1862
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1855
1863
|
end
|
1856
|
-
end
|
1857
|
-
if s0.empty?
|
1858
|
-
@index = i0
|
1859
|
-
r0 = nil
|
1860
|
-
else
|
1861
|
-
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1862
|
-
end
|
1863
1864
|
|
1864
|
-
|
1865
|
+
node_cache[:space][start_index] = r0
|
1866
|
+
|
1867
|
+
r0
|
1868
|
+
end
|
1865
1869
|
|
1866
|
-
r0
|
1867
1870
|
end
|
1868
1871
|
|
1869
|
-
|
1872
|
+
class ExcelParser < Treetop::Runtime::CompiledParser
|
1873
|
+
include Excel
|
1874
|
+
end
|
1870
1875
|
|
1871
|
-
class SorobanParser < Treetop::Runtime::CompiledParser
|
1872
|
-
include Soroban
|
1873
1876
|
end
|
1874
|
-
|