surpass 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +2 -2
- data/Rakefile +14 -16
- data/debug-examples/formula-cell.bin +0 -0
- data/debug-examples/formula-cell.rb +14 -0
- data/debug-examples/formula-record.bin +0 -0
- data/debug-examples/formula-record.rb +15 -0
- data/lib/surpass/ExcelFormula.g +82 -84
- data/lib/surpass/ExcelFormula.tokens +29 -29
- data/lib/surpass/ExcelFormulaLexer.rb +1283 -842
- data/lib/surpass/ExcelFormulaParser.rb +1654 -491
- data/lib/surpass/biff_record.rb +2 -2
- data/lib/surpass/formula.rb +25 -0
- data/lib/surpass/row.rb +1 -1
- data/lib/surpass/utilities.rb +32 -0
- data/lib/surpass/workbook.rb +1 -1
- data/lib/surpass/worksheet.rb +4 -4
- data/lib/surpass.rb +12 -2
- data/surpass.gemspec +8 -9
- metadata +26 -25
- data/lib/surpass/excel_formula.rb +0 -23
- data/out.bin +0 -0
- data/tasks/ann.rake +0 -80
- data/tasks/bones.rake +0 -20
- data/tasks/gem.rake +0 -201
- data/tasks/git.rake +0 -40
- data/tasks/notes.rake +0 -27
- data/tasks/post_load.rake +0 -34
- data/tasks/rdoc.rake +0 -51
- data/tasks/rubyforge.rake +0 -55
- data/tasks/setup.rb +0 -292
- data/tasks/spec.rake +0 -54
- data/tasks/svn.rake +0 -47
- data/tasks/test.rake +0 -40
- data/tasks/zentest.rake +0 -36
@@ -1,922 +1,1363 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# ExcelFormula.g
|
4
|
+
#
|
5
|
+
# Generated using ANTLR version: 3.2.1-SNAPSHOT Dec 18, 2009 04:29:28
|
6
|
+
# Ruby runtime library version: 1.3.1
|
7
|
+
# Input grammar file: ExcelFormula.g
|
8
|
+
# Generated at: 2010-05-03 16:34:32
|
9
|
+
#
|
10
|
+
|
11
|
+
# ~~~> start load path setup
|
12
|
+
this_directory = File.expand_path( File.dirname( __FILE__ ) )
|
13
|
+
$:.unshift( this_directory ) unless $:.include?( this_directory )
|
14
|
+
|
15
|
+
antlr_load_failed = proc do
|
16
|
+
load_path = $LOAD_PATH.map { |dir| ' - ' << dir }.join( $/ )
|
17
|
+
raise LoadError, <<-END.strip!
|
18
|
+
|
19
|
+
Failed to load the ANTLR3 runtime library (version 1.3.1):
|
20
|
+
|
21
|
+
Ensure the library has been installed on your system and is available
|
22
|
+
on the load path. If rubygems is available on your system, this can
|
23
|
+
be done with the command:
|
24
|
+
|
25
|
+
gem install antlr3
|
26
|
+
|
27
|
+
Current load path:
|
28
|
+
#{ load_path }
|
29
|
+
|
30
|
+
END
|
31
|
+
end
|
32
|
+
|
33
|
+
defined?(ANTLR3) or begin
|
34
|
+
|
35
|
+
# 1: try to load the ruby antlr3 runtime library from the system path
|
36
|
+
require 'antlr3'
|
37
|
+
|
38
|
+
rescue LoadError
|
39
|
+
|
40
|
+
# 2: try to load rubygems if it isn't already loaded
|
41
|
+
defined?(Gem) or begin
|
42
|
+
require 'rubygems'
|
43
|
+
rescue LoadError
|
44
|
+
antlr_load_failed.call
|
45
|
+
end
|
46
|
+
|
47
|
+
# 3: try to activate the antlr3 gem
|
48
|
+
begin
|
49
|
+
Gem.activate( 'antlr3', '= 1.3.1' )
|
50
|
+
rescue Gem::LoadError
|
51
|
+
antlr_load_failed.call
|
52
|
+
end
|
53
|
+
|
54
|
+
require 'antlr3'
|
55
|
+
|
56
|
+
end
|
57
|
+
# <~~~ end load path setup
|
58
|
+
|
59
|
+
|
60
|
+
module ExcelFormula
|
61
|
+
# TokenData defines all of the token type integer values
|
62
|
+
# as constants, which will be included in all
|
63
|
+
# ANTLR-generated recognizers.
|
64
|
+
const_defined?(:TokenData) or TokenData = ANTLR3::TokenScheme.new
|
65
|
+
|
66
|
+
module TokenData
|
67
|
+
|
68
|
+
# define the token constants
|
69
|
+
define_tokens(:GE => 8, :LT => 7, :NUM_CONST => 21, :PERCENT => 16,
|
70
|
+
:REF2D => 22, :CONCAT => 10, :RP => 29, :LP => 26, :INT_CONST => 20,
|
71
|
+
:STR_CONST => 19, :POWER => 15, :SUB => 12, :FUNC_CHOOSE => 30,
|
72
|
+
:SEMICOLON => 27, :BANG => 24, :TRUE_CONST => 17, :EOF => -1,
|
73
|
+
:MUL => 13, :COLON => 23, :FALSE_CONST => 18, :NAME => 31,
|
74
|
+
:COMMA => 28, :GT => 6, :DIGIT => 33, :DIV => 14, :EQ => 4,
|
75
|
+
:FUNC_IF => 25, :QUOTENAME => 32, :LE => 9, :ADD => 11,
|
76
|
+
:NE => 5)
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
class Lexer < ANTLR3::Lexer
|
82
|
+
@grammar_home = ExcelFormula
|
83
|
+
include TokenData
|
84
|
+
|
85
|
+
begin
|
86
|
+
generated_using( "ExcelFormula.g", "3.2.1-SNAPSHOT Dec 18, 2009 04:29:28", "1.3.1" )
|
87
|
+
rescue NoMethodError => error
|
88
|
+
error.name.to_sym == :generated_using or raise
|
89
|
+
end
|
90
|
+
|
91
|
+
RULE_NAMES = ["EQ", "LT", "GT", "NE", "LE", "GE", "ADD", "SUB", "MUL",
|
92
|
+
"DIV", "COLON", "SEMICOLON", "COMMA", "LP", "RP", "CONCAT",
|
93
|
+
"PERCENT", "POWER", "BANG", "DIGIT", "INT_CONST", "NUM_CONST",
|
94
|
+
"STR_CONST", "REF2D", "TRUE_CONST", "FALSE_CONST", "NAME",
|
95
|
+
"QUOTENAME", "FUNC_IF", "FUNC_CHOOSE"].freeze
|
96
|
+
RULE_METHODS = [:eq!, :lt!, :gt!, :ne!, :le!, :ge!, :add!, :sub!, :mul!,
|
97
|
+
:div!, :colon!, :semicolon!, :comma!, :lp!, :rp!, :concat!,
|
98
|
+
:percent!, :power!, :bang!, :digit!, :int_const!, :num_const!,
|
99
|
+
:str_const!, :ref_2_d!, :true_const!, :false_const!,
|
100
|
+
:name!, :quotename!, :func_if!, :func_choose!].freeze
|
101
|
+
|
102
|
+
|
103
|
+
def initialize(input=nil, options = {})
|
104
|
+
super(input, options)
|
88
105
|
|
89
|
-
alias :to_i :int_type
|
90
106
|
end
|
107
|
+
|
108
|
+
# - - - - - - - - - - - lexer rules - - - - - - - - - - - -
|
109
|
+
# lexer rule eq! (EQ)
|
110
|
+
# (in ExcelFormula.g)
|
111
|
+
def eq!
|
112
|
+
# -> uncomment the next line to manually enable rule tracing
|
113
|
+
# trace_in(__method__, 1)
|
114
|
+
|
115
|
+
type = EQ
|
116
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
117
|
+
|
118
|
+
|
119
|
+
# - - - - main rule block - - - -
|
120
|
+
# at line 329:5: '='
|
121
|
+
match(?=)
|
122
|
+
|
123
|
+
|
124
|
+
@state.type = type
|
125
|
+
@state.channel = channel
|
126
|
+
|
127
|
+
ensure
|
128
|
+
# -> uncomment the next line to manually enable rule tracing
|
129
|
+
# trace_out(__method__, 1)
|
91
130
|
|
131
|
+
end
|
92
132
|
|
93
|
-
|
133
|
+
# lexer rule lt! (LT)
|
134
|
+
# (in ExcelFormula.g)
|
135
|
+
def lt!
|
136
|
+
# -> uncomment the next line to manually enable rule tracing
|
137
|
+
# trace_in(__method__, 2)
|
94
138
|
|
95
|
-
|
96
|
-
|
97
|
-
attr_reader :column
|
98
|
-
attr_reader :index
|
139
|
+
type = LT
|
140
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
99
141
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
@column = 0
|
142
|
+
|
143
|
+
# - - - - main rule block - - - -
|
144
|
+
# at line 330:5: '<'
|
145
|
+
match(?<)
|
105
146
|
|
106
|
-
|
107
|
-
|
147
|
+
|
148
|
+
@state.type = type
|
149
|
+
@state.channel = channel
|
108
150
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
if @buffer.length < offset + 1
|
113
|
-
char = @input.read(offset + 1 - @buffer.length)
|
114
|
-
@buffer << char if not char.nil?
|
115
|
-
end
|
116
|
-
|
117
|
-
if offset < @buffer.length
|
118
|
-
@buffer[offset]
|
119
|
-
else
|
120
|
-
:EOF
|
121
|
-
end
|
122
|
-
end
|
151
|
+
ensure
|
152
|
+
# -> uncomment the next line to manually enable rule tracing
|
153
|
+
# trace_out(__method__, 2)
|
123
154
|
|
124
|
-
|
125
|
-
@state = { :index => @index, :line => @line, :column => @column }
|
126
|
-
return 0
|
127
|
-
end
|
155
|
+
end
|
128
156
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
157
|
+
# lexer rule gt! (GT)
|
158
|
+
# (in ExcelFormula.g)
|
159
|
+
def gt!
|
160
|
+
# -> uncomment the next line to manually enable rule tracing
|
161
|
+
# trace_in(__method__, 3)
|
134
162
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
163
|
+
type = GT
|
164
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
165
|
+
|
166
|
+
|
167
|
+
# - - - - main rule block - - - -
|
168
|
+
# at line 331:5: '>'
|
169
|
+
match(?>)
|
170
|
+
|
171
|
+
|
172
|
+
@state.type = type
|
173
|
+
@state.channel = channel
|
174
|
+
|
175
|
+
ensure
|
176
|
+
# -> uncomment the next line to manually enable rule tracing
|
177
|
+
# trace_out(__method__, 3)
|
144
178
|
|
145
|
-
def substring(start, stop)
|
146
|
-
@buffer.slice(start, stop - start + 1)
|
147
|
-
end
|
148
179
|
end
|
149
180
|
|
181
|
+
# lexer rule ne! (NE)
|
182
|
+
# (in ExcelFormula.g)
|
183
|
+
def ne!
|
184
|
+
# -> uncomment the next line to manually enable rule tracing
|
185
|
+
# trace_in(__method__, 4)
|
150
186
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
@input.consume() if !@failed
|
167
|
-
end
|
187
|
+
type = NE
|
188
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
189
|
+
|
190
|
+
|
191
|
+
# - - - - main rule block - - - -
|
192
|
+
# at line 332:5: '<>'
|
193
|
+
match("<>")
|
194
|
+
|
195
|
+
|
196
|
+
@state.type = type
|
197
|
+
@state.channel = channel
|
198
|
+
|
199
|
+
ensure
|
200
|
+
# -> uncomment the next line to manually enable rule tracing
|
201
|
+
# trace_out(__method__, 4)
|
168
202
|
|
169
|
-
if @failed && @backtracking <= 0
|
170
|
-
raise "Expected #{value.respond_to?(:chr) ? value.chr : value}"
|
171
|
-
end
|
172
203
|
end
|
173
204
|
|
174
|
-
|
175
|
-
|
205
|
+
# lexer rule le! (LE)
|
206
|
+
# (in ExcelFormula.g)
|
207
|
+
def le!
|
208
|
+
# -> uncomment the next line to manually enable rule tracing
|
209
|
+
# trace_in(__method__, 5)
|
210
|
+
|
211
|
+
type = LE
|
212
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
213
|
+
|
214
|
+
|
215
|
+
# - - - - main rule block - - - -
|
216
|
+
# at line 333:5: '<='
|
217
|
+
match("<=")
|
218
|
+
|
219
|
+
|
220
|
+
@state.type = type
|
221
|
+
@state.channel = channel
|
222
|
+
|
223
|
+
ensure
|
224
|
+
# -> uncomment the next line to manually enable rule tracing
|
225
|
+
# trace_out(__method__, 5)
|
226
|
+
|
227
|
+
end
|
228
|
+
|
229
|
+
# lexer rule ge! (GE)
|
230
|
+
# (in ExcelFormula.g)
|
231
|
+
def ge!
|
232
|
+
# -> uncomment the next line to manually enable rule tracing
|
233
|
+
# trace_in(__method__, 6)
|
234
|
+
|
235
|
+
type = GE
|
236
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
237
|
+
|
238
|
+
|
239
|
+
# - - - - main rule block - - - -
|
240
|
+
# at line 334:5: '>='
|
241
|
+
match(">=")
|
242
|
+
|
243
|
+
|
244
|
+
@state.type = type
|
245
|
+
@state.channel = channel
|
246
|
+
|
247
|
+
ensure
|
248
|
+
# -> uncomment the next line to manually enable rule tracing
|
249
|
+
# trace_out(__method__, 6)
|
176
250
|
|
177
|
-
if char != :EOF && (char >= from || char <= to)
|
178
|
-
@failed = false
|
179
|
-
match()
|
180
|
-
elsif @backtracking > 0
|
181
|
-
@failed = true
|
182
|
-
else
|
183
|
-
raise "Expected [#{from.chr}..#{to.chr}]"
|
184
|
-
end
|
185
251
|
end
|
186
252
|
|
187
|
-
|
253
|
+
# lexer rule add! (ADD)
|
254
|
+
# (in ExcelFormula.g)
|
255
|
+
def add!
|
256
|
+
# -> uncomment the next line to manually enable rule tracing
|
257
|
+
# trace_in(__method__, 7)
|
258
|
+
|
259
|
+
type = ADD
|
260
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
261
|
+
|
262
|
+
|
263
|
+
# - - - - main rule block - - - -
|
264
|
+
# at line 336:6: '+'
|
265
|
+
match(?+)
|
188
266
|
|
189
|
-
|
190
|
-
|
267
|
+
|
268
|
+
@state.type = type
|
269
|
+
@state.channel = channel
|
270
|
+
|
271
|
+
ensure
|
272
|
+
# -> uncomment the next line to manually enable rule tracing
|
273
|
+
# trace_out(__method__, 7)
|
191
274
|
|
192
275
|
end
|
193
276
|
|
194
|
-
|
277
|
+
# lexer rule sub! (SUB)
|
278
|
+
# (in ExcelFormula.g)
|
279
|
+
def sub!
|
280
|
+
# -> uncomment the next line to manually enable rule tracing
|
281
|
+
# trace_in(__method__, 8)
|
282
|
+
|
283
|
+
type = SUB
|
284
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
285
|
+
|
286
|
+
|
287
|
+
# - - - - main rule block - - - -
|
288
|
+
# at line 337:6: '-'
|
289
|
+
match(?-)
|
290
|
+
|
291
|
+
|
292
|
+
@state.type = type
|
293
|
+
@state.channel = channel
|
294
|
+
|
295
|
+
ensure
|
296
|
+
# -> uncomment the next line to manually enable rule tracing
|
297
|
+
# trace_out(__method__, 8)
|
195
298
|
|
196
|
-
@type = :LT
|
197
|
-
@type_int = LT
|
198
|
-
# 333:5: '<'
|
199
|
-
match(?<)
|
200
299
|
end
|
201
300
|
|
202
|
-
|
301
|
+
# lexer rule mul! (MUL)
|
302
|
+
# (in ExcelFormula.g)
|
303
|
+
def mul!
|
304
|
+
# -> uncomment the next line to manually enable rule tracing
|
305
|
+
# trace_in(__method__, 9)
|
306
|
+
|
307
|
+
type = MUL
|
308
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
309
|
+
|
310
|
+
|
311
|
+
# - - - - main rule block - - - -
|
312
|
+
# at line 338:6: '*'
|
313
|
+
match(?*)
|
314
|
+
|
315
|
+
|
316
|
+
@state.type = type
|
317
|
+
@state.channel = channel
|
318
|
+
|
319
|
+
ensure
|
320
|
+
# -> uncomment the next line to manually enable rule tracing
|
321
|
+
# trace_out(__method__, 9)
|
203
322
|
|
204
|
-
@type = :GT
|
205
|
-
@type_int = GT
|
206
|
-
# 334:5: '>'
|
207
|
-
match(?>)
|
208
323
|
end
|
209
324
|
|
210
|
-
|
325
|
+
# lexer rule div! (DIV)
|
326
|
+
# (in ExcelFormula.g)
|
327
|
+
def div!
|
328
|
+
# -> uncomment the next line to manually enable rule tracing
|
329
|
+
# trace_in(__method__, 10)
|
330
|
+
|
331
|
+
type = DIV
|
332
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
333
|
+
|
334
|
+
|
335
|
+
# - - - - main rule block - - - -
|
336
|
+
# at line 339:6: '/'
|
337
|
+
match(?/)
|
211
338
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
339
|
+
|
340
|
+
@state.type = type
|
341
|
+
@state.channel = channel
|
342
|
+
|
343
|
+
ensure
|
344
|
+
# -> uncomment the next line to manually enable rule tracing
|
345
|
+
# trace_out(__method__, 10)
|
346
|
+
|
347
|
+
end
|
348
|
+
|
349
|
+
# lexer rule colon! (COLON)
|
350
|
+
# (in ExcelFormula.g)
|
351
|
+
def colon!
|
352
|
+
# -> uncomment the next line to manually enable rule tracing
|
353
|
+
# trace_in(__method__, 11)
|
354
|
+
|
355
|
+
type = COLON
|
356
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
357
|
+
|
358
|
+
|
359
|
+
# - - - - main rule block - - - -
|
360
|
+
# at line 341:8: ':'
|
361
|
+
match(?:)
|
362
|
+
|
363
|
+
|
364
|
+
@state.type = type
|
365
|
+
@state.channel = channel
|
366
|
+
|
367
|
+
ensure
|
368
|
+
# -> uncomment the next line to manually enable rule tracing
|
369
|
+
# trace_out(__method__, 11)
|
216
370
|
|
217
371
|
end
|
218
372
|
|
219
|
-
|
373
|
+
# lexer rule semicolon! (SEMICOLON)
|
374
|
+
# (in ExcelFormula.g)
|
375
|
+
def semicolon!
|
376
|
+
# -> uncomment the next line to manually enable rule tracing
|
377
|
+
# trace_in(__method__, 12)
|
378
|
+
|
379
|
+
type = SEMICOLON
|
380
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
381
|
+
|
382
|
+
|
383
|
+
# - - - - main rule block - - - -
|
384
|
+
# at line 342:12: ';'
|
385
|
+
match(?;)
|
386
|
+
|
387
|
+
|
388
|
+
@state.type = type
|
389
|
+
@state.channel = channel
|
220
390
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
match("<=")
|
391
|
+
ensure
|
392
|
+
# -> uncomment the next line to manually enable rule tracing
|
393
|
+
# trace_out(__method__, 12)
|
225
394
|
|
226
395
|
end
|
227
396
|
|
228
|
-
|
397
|
+
# lexer rule comma! (COMMA)
|
398
|
+
# (in ExcelFormula.g)
|
399
|
+
def comma!
|
400
|
+
# -> uncomment the next line to manually enable rule tracing
|
401
|
+
# trace_in(__method__, 13)
|
402
|
+
|
403
|
+
type = COMMA
|
404
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
405
|
+
|
406
|
+
|
407
|
+
# - - - - main rule block - - - -
|
408
|
+
# at line 343:8: ','
|
409
|
+
match(?,)
|
410
|
+
|
411
|
+
|
412
|
+
@state.type = type
|
413
|
+
@state.channel = channel
|
229
414
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
match(">=")
|
415
|
+
ensure
|
416
|
+
# -> uncomment the next line to manually enable rule tracing
|
417
|
+
# trace_out(__method__, 13)
|
234
418
|
|
235
419
|
end
|
236
420
|
|
237
|
-
|
421
|
+
# lexer rule lp! (LP)
|
422
|
+
# (in ExcelFormula.g)
|
423
|
+
def lp!
|
424
|
+
# -> uncomment the next line to manually enable rule tracing
|
425
|
+
# trace_in(__method__, 14)
|
426
|
+
|
427
|
+
type = LP
|
428
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
429
|
+
|
430
|
+
|
431
|
+
# - - - - main rule block - - - -
|
432
|
+
# at line 345:5: '('
|
433
|
+
match(?()
|
434
|
+
|
435
|
+
|
436
|
+
@state.type = type
|
437
|
+
@state.channel = channel
|
438
|
+
|
439
|
+
ensure
|
440
|
+
# -> uncomment the next line to manually enable rule tracing
|
441
|
+
# trace_out(__method__, 14)
|
442
|
+
|
443
|
+
end
|
444
|
+
|
445
|
+
# lexer rule rp! (RP)
|
446
|
+
# (in ExcelFormula.g)
|
447
|
+
def rp!
|
448
|
+
# -> uncomment the next line to manually enable rule tracing
|
449
|
+
# trace_in(__method__, 15)
|
450
|
+
|
451
|
+
type = RP
|
452
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
453
|
+
|
454
|
+
|
455
|
+
# - - - - main rule block - - - -
|
456
|
+
# at line 346:5: ')'
|
457
|
+
match(?))
|
458
|
+
|
459
|
+
|
460
|
+
@state.type = type
|
461
|
+
@state.channel = channel
|
462
|
+
|
463
|
+
ensure
|
464
|
+
# -> uncomment the next line to manually enable rule tracing
|
465
|
+
# trace_out(__method__, 15)
|
466
|
+
|
467
|
+
end
|
468
|
+
|
469
|
+
# lexer rule concat! (CONCAT)
|
470
|
+
# (in ExcelFormula.g)
|
471
|
+
def concat!
|
472
|
+
# -> uncomment the next line to manually enable rule tracing
|
473
|
+
# trace_in(__method__, 16)
|
474
|
+
|
475
|
+
type = CONCAT
|
476
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
477
|
+
|
478
|
+
|
479
|
+
# - - - - main rule block - - - -
|
480
|
+
# at line 347:9: '&'
|
481
|
+
match(?&)
|
482
|
+
|
483
|
+
|
484
|
+
@state.type = type
|
485
|
+
@state.channel = channel
|
486
|
+
|
487
|
+
ensure
|
488
|
+
# -> uncomment the next line to manually enable rule tracing
|
489
|
+
# trace_out(__method__, 16)
|
490
|
+
|
491
|
+
end
|
492
|
+
|
493
|
+
# lexer rule percent! (PERCENT)
|
494
|
+
# (in ExcelFormula.g)
|
495
|
+
def percent!
|
496
|
+
# -> uncomment the next line to manually enable rule tracing
|
497
|
+
# trace_in(__method__, 17)
|
498
|
+
|
499
|
+
type = PERCENT
|
500
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
501
|
+
|
502
|
+
|
503
|
+
# - - - - main rule block - - - -
|
504
|
+
# at line 348:10: '%'
|
505
|
+
match(?%)
|
506
|
+
|
507
|
+
|
508
|
+
@state.type = type
|
509
|
+
@state.channel = channel
|
510
|
+
|
511
|
+
ensure
|
512
|
+
# -> uncomment the next line to manually enable rule tracing
|
513
|
+
# trace_out(__method__, 17)
|
514
|
+
|
515
|
+
end
|
516
|
+
|
517
|
+
# lexer rule power! (POWER)
|
518
|
+
# (in ExcelFormula.g)
|
519
|
+
def power!
|
520
|
+
# -> uncomment the next line to manually enable rule tracing
|
521
|
+
# trace_in(__method__, 18)
|
522
|
+
|
523
|
+
type = POWER
|
524
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
525
|
+
|
526
|
+
|
527
|
+
# - - - - main rule block - - - -
|
528
|
+
# at line 349:8: '^'
|
529
|
+
match(?^)
|
530
|
+
|
531
|
+
|
532
|
+
@state.type = type
|
533
|
+
@state.channel = channel
|
534
|
+
|
535
|
+
ensure
|
536
|
+
# -> uncomment the next line to manually enable rule tracing
|
537
|
+
# trace_out(__method__, 18)
|
538
|
+
|
539
|
+
end
|
540
|
+
|
541
|
+
# lexer rule bang! (BANG)
|
542
|
+
# (in ExcelFormula.g)
|
543
|
+
def bang!
|
544
|
+
# -> uncomment the next line to manually enable rule tracing
|
545
|
+
# trace_in(__method__, 19)
|
546
|
+
|
547
|
+
type = BANG
|
548
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
549
|
+
|
550
|
+
|
551
|
+
# - - - - main rule block - - - -
|
552
|
+
# at line 350:7: '!'
|
553
|
+
match(?!)
|
554
|
+
|
555
|
+
|
556
|
+
@state.type = type
|
557
|
+
@state.channel = channel
|
558
|
+
|
559
|
+
ensure
|
560
|
+
# -> uncomment the next line to manually enable rule tracing
|
561
|
+
# trace_out(__method__, 19)
|
562
|
+
|
563
|
+
end
|
564
|
+
|
565
|
+
# lexer rule digit! (DIGIT)
|
566
|
+
# (in ExcelFormula.g)
|
567
|
+
def digit!
|
568
|
+
# -> uncomment the next line to manually enable rule tracing
|
569
|
+
# trace_in(__method__, 20)
|
570
|
+
|
571
|
+
|
572
|
+
# - - - - main rule block - - - -
|
573
|
+
# at line 352:17: '0' .. '9'
|
574
|
+
match_range(?0, ?9)
|
575
|
+
|
576
|
+
ensure
|
577
|
+
# -> uncomment the next line to manually enable rule tracing
|
578
|
+
# trace_out(__method__, 20)
|
579
|
+
|
580
|
+
end
|
581
|
+
|
582
|
+
# lexer rule int_const! (INT_CONST)
|
583
|
+
# (in ExcelFormula.g)
|
584
|
+
def int_const!
|
585
|
+
# -> uncomment the next line to manually enable rule tracing
|
586
|
+
# trace_in(__method__, 21)
|
587
|
+
|
588
|
+
type = INT_CONST
|
589
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
590
|
+
|
591
|
+
|
592
|
+
# - - - - main rule block - - - -
|
593
|
+
# at line 354:12: ( DIGIT )+
|
594
|
+
# at file 354:12: ( DIGIT )+
|
595
|
+
match_count_1 = 0
|
596
|
+
loop do
|
597
|
+
alt_1 = 2
|
598
|
+
look_1_0 = @input.peek(1)
|
599
|
+
|
600
|
+
if (look_1_0.between?(?0, ?9))
|
601
|
+
alt_1 = 1
|
602
|
+
|
603
|
+
end
|
604
|
+
case alt_1
|
605
|
+
when 1
|
606
|
+
# at line 354:12: DIGIT
|
607
|
+
digit!
|
608
|
+
|
609
|
+
else
|
610
|
+
match_count_1 > 0 and break
|
611
|
+
eee = EarlyExit(1)
|
612
|
+
|
613
|
+
|
614
|
+
raise eee
|
615
|
+
end
|
616
|
+
match_count_1 += 1
|
617
|
+
end
|
618
|
+
|
619
|
+
|
620
|
+
|
621
|
+
@state.type = type
|
622
|
+
@state.channel = channel
|
623
|
+
|
624
|
+
ensure
|
625
|
+
# -> uncomment the next line to manually enable rule tracing
|
626
|
+
# trace_out(__method__, 21)
|
238
627
|
|
239
|
-
@type = :ADD
|
240
|
-
@type_int = ADD
|
241
|
-
# 339:6: '+'
|
242
|
-
match(?+)
|
243
628
|
end
|
244
629
|
|
245
|
-
|
630
|
+
# lexer rule num_const! (NUM_CONST)
|
631
|
+
# (in ExcelFormula.g)
|
632
|
+
def num_const!
|
633
|
+
# -> uncomment the next line to manually enable rule tracing
|
634
|
+
# trace_in(__method__, 22)
|
635
|
+
|
636
|
+
type = NUM_CONST
|
637
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
638
|
+
|
639
|
+
|
640
|
+
# - - - - main rule block - - - -
|
641
|
+
# at line 355:12: ( DIGIT )* '.' ( DIGIT )+ ( ( 'E' | 'e' ) ( '+' | '-' )? ( DIGIT )+ )?
|
642
|
+
# at line 355:12: ( DIGIT )*
|
643
|
+
loop do # decision 2
|
644
|
+
alt_2 = 2
|
645
|
+
look_2_0 = @input.peek(1)
|
646
|
+
|
647
|
+
if (look_2_0.between?(?0, ?9))
|
648
|
+
alt_2 = 1
|
649
|
+
|
650
|
+
end
|
651
|
+
case alt_2
|
652
|
+
when 1
|
653
|
+
# at line 355:12: DIGIT
|
654
|
+
digit!
|
655
|
+
|
656
|
+
else
|
657
|
+
break # out of loop for decision 2
|
658
|
+
end
|
659
|
+
end # loop for decision 2
|
660
|
+
match(?.)
|
661
|
+
# at file 355:23: ( DIGIT )+
|
662
|
+
match_count_3 = 0
|
663
|
+
loop do
|
664
|
+
alt_3 = 2
|
665
|
+
look_3_0 = @input.peek(1)
|
666
|
+
|
667
|
+
if (look_3_0.between?(?0, ?9))
|
668
|
+
alt_3 = 1
|
669
|
+
|
670
|
+
end
|
671
|
+
case alt_3
|
672
|
+
when 1
|
673
|
+
# at line 355:23: DIGIT
|
674
|
+
digit!
|
675
|
+
|
676
|
+
else
|
677
|
+
match_count_3 > 0 and break
|
678
|
+
eee = EarlyExit(3)
|
679
|
+
|
680
|
+
|
681
|
+
raise eee
|
682
|
+
end
|
683
|
+
match_count_3 += 1
|
684
|
+
end
|
685
|
+
|
686
|
+
# at line 355:30: ( ( 'E' | 'e' ) ( '+' | '-' )? ( DIGIT )+ )?
|
687
|
+
alt_6 = 2
|
688
|
+
look_6_0 = @input.peek(1)
|
689
|
+
|
690
|
+
if (look_6_0 == ?E || look_6_0 == ?e)
|
691
|
+
alt_6 = 1
|
692
|
+
end
|
693
|
+
case alt_6
|
694
|
+
when 1
|
695
|
+
# at line 355:31: ( 'E' | 'e' ) ( '+' | '-' )? ( DIGIT )+
|
696
|
+
if @input.peek(1) == ?E || @input.peek(1) == ?e
|
697
|
+
@input.consume
|
698
|
+
else
|
699
|
+
mse = MismatchedSet(nil)
|
700
|
+
recover(mse)
|
701
|
+
raise mse
|
702
|
+
end
|
703
|
+
|
704
|
+
|
705
|
+
# at line 355:41: ( '+' | '-' )?
|
706
|
+
alt_4 = 2
|
707
|
+
look_4_0 = @input.peek(1)
|
708
|
+
|
709
|
+
if (look_4_0 == ?+ || look_4_0 == ?-)
|
710
|
+
alt_4 = 1
|
711
|
+
end
|
712
|
+
case alt_4
|
713
|
+
when 1
|
714
|
+
# at line
|
715
|
+
if @input.peek(1) == ?+ || @input.peek(1) == ?-
|
716
|
+
@input.consume
|
717
|
+
else
|
718
|
+
mse = MismatchedSet(nil)
|
719
|
+
recover(mse)
|
720
|
+
raise mse
|
721
|
+
end
|
722
|
+
|
723
|
+
|
724
|
+
|
725
|
+
end
|
726
|
+
# at file 355:52: ( DIGIT )+
|
727
|
+
match_count_5 = 0
|
728
|
+
loop do
|
729
|
+
alt_5 = 2
|
730
|
+
look_5_0 = @input.peek(1)
|
731
|
+
|
732
|
+
if (look_5_0.between?(?0, ?9))
|
733
|
+
alt_5 = 1
|
734
|
+
|
735
|
+
end
|
736
|
+
case alt_5
|
737
|
+
when 1
|
738
|
+
# at line 355:52: DIGIT
|
739
|
+
digit!
|
740
|
+
|
741
|
+
else
|
742
|
+
match_count_5 > 0 and break
|
743
|
+
eee = EarlyExit(5)
|
744
|
+
|
745
|
+
|
746
|
+
raise eee
|
747
|
+
end
|
748
|
+
match_count_5 += 1
|
749
|
+
end
|
750
|
+
|
751
|
+
|
752
|
+
end
|
753
|
+
|
754
|
+
|
755
|
+
@state.type = type
|
756
|
+
@state.channel = channel
|
757
|
+
|
758
|
+
ensure
|
759
|
+
# -> uncomment the next line to manually enable rule tracing
|
760
|
+
# trace_out(__method__, 22)
|
246
761
|
|
247
|
-
@type = :SUB
|
248
|
-
@type_int = SUB
|
249
|
-
# 340:6: '-'
|
250
|
-
match(?-)
|
251
762
|
end
|
252
763
|
|
253
|
-
|
764
|
+
# lexer rule str_const! (STR_CONST)
|
765
|
+
# (in ExcelFormula.g)
|
766
|
+
def str_const!
|
767
|
+
# -> uncomment the next line to manually enable rule tracing
|
768
|
+
# trace_in(__method__, 23)
|
769
|
+
|
770
|
+
type = STR_CONST
|
771
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
772
|
+
|
773
|
+
|
774
|
+
# - - - - main rule block - - - -
|
775
|
+
# at line 356:12: '\"' (~ '\"' )+ '\"'
|
776
|
+
match(?")
|
777
|
+
# at file 356:16: (~ '\"' )+
|
778
|
+
match_count_7 = 0
|
779
|
+
loop do
|
780
|
+
alt_7 = 2
|
781
|
+
look_7_0 = @input.peek(1)
|
782
|
+
|
783
|
+
if (look_7_0.between?(0x0000, ?!) || look_7_0.between?(?#, 0xFFFF))
|
784
|
+
alt_7 = 1
|
785
|
+
|
786
|
+
end
|
787
|
+
case alt_7
|
788
|
+
when 1
|
789
|
+
# at line 356:17: ~ '\"'
|
790
|
+
if @input.peek(1).between?(0x0000, ?!) || @input.peek(1).between?(?#, 0x00FF)
|
791
|
+
@input.consume
|
792
|
+
else
|
793
|
+
mse = MismatchedSet(nil)
|
794
|
+
recover(mse)
|
795
|
+
raise mse
|
796
|
+
end
|
797
|
+
|
798
|
+
|
799
|
+
|
800
|
+
else
|
801
|
+
match_count_7 > 0 and break
|
802
|
+
eee = EarlyExit(7)
|
803
|
+
|
804
|
+
|
805
|
+
raise eee
|
806
|
+
end
|
807
|
+
match_count_7 += 1
|
808
|
+
end
|
809
|
+
|
810
|
+
match(?")
|
811
|
+
|
812
|
+
|
813
|
+
@state.type = type
|
814
|
+
@state.channel = channel
|
815
|
+
|
816
|
+
ensure
|
817
|
+
# -> uncomment the next line to manually enable rule tracing
|
818
|
+
# trace_out(__method__, 23)
|
254
819
|
|
255
|
-
@type = :MUL
|
256
|
-
@type_int = MUL
|
257
|
-
# 341:6: '*'
|
258
|
-
match(?*)
|
259
820
|
end
|
260
821
|
|
261
|
-
|
822
|
+
# lexer rule ref_2_d! (REF2D)
|
823
|
+
# (in ExcelFormula.g)
|
824
|
+
def ref_2_d!
|
825
|
+
# -> uncomment the next line to manually enable rule tracing
|
826
|
+
# trace_in(__method__, 24)
|
827
|
+
|
828
|
+
type = REF2D
|
829
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
830
|
+
|
831
|
+
|
832
|
+
# - - - - main rule block - - - -
|
833
|
+
# at line 357:8: ( '$' )? ( 'A' .. 'I' )? ( 'A' .. 'Z' ) ( '$' )? ( DIGIT )+
|
834
|
+
# at line 357:8: ( '$' )?
|
835
|
+
alt_8 = 2
|
836
|
+
look_8_0 = @input.peek(1)
|
837
|
+
|
838
|
+
if (look_8_0 == ?$)
|
839
|
+
alt_8 = 1
|
840
|
+
end
|
841
|
+
case alt_8
|
842
|
+
when 1
|
843
|
+
# at line 357:8: '$'
|
844
|
+
match(?$)
|
845
|
+
|
846
|
+
end
|
847
|
+
# at line 357:13: ( 'A' .. 'I' )?
|
848
|
+
alt_9 = 2
|
849
|
+
look_9_0 = @input.peek(1)
|
850
|
+
|
851
|
+
if (look_9_0.between?(?A, ?I))
|
852
|
+
look_9_1 = @input.peek(2)
|
853
|
+
|
854
|
+
if (look_9_1.between?(?A, ?Z))
|
855
|
+
alt_9 = 1
|
856
|
+
end
|
857
|
+
end
|
858
|
+
case alt_9
|
859
|
+
when 1
|
860
|
+
# at line 357:14: 'A' .. 'I'
|
861
|
+
match_range(?A, ?I)
|
862
|
+
|
863
|
+
end
|
864
|
+
# at line 357:25: ( 'A' .. 'Z' )
|
865
|
+
# at line 357:26: 'A' .. 'Z'
|
866
|
+
match_range(?A, ?Z)
|
867
|
+
|
868
|
+
# at line 357:36: ( '$' )?
|
869
|
+
alt_10 = 2
|
870
|
+
look_10_0 = @input.peek(1)
|
871
|
+
|
872
|
+
if (look_10_0 == ?$)
|
873
|
+
alt_10 = 1
|
874
|
+
end
|
875
|
+
case alt_10
|
876
|
+
when 1
|
877
|
+
# at line 357:36: '$'
|
878
|
+
match(?$)
|
879
|
+
|
880
|
+
end
|
881
|
+
# at file 357:41: ( DIGIT )+
|
882
|
+
match_count_11 = 0
|
883
|
+
loop do
|
884
|
+
alt_11 = 2
|
885
|
+
look_11_0 = @input.peek(1)
|
886
|
+
|
887
|
+
if (look_11_0.between?(?0, ?9))
|
888
|
+
alt_11 = 1
|
889
|
+
|
890
|
+
end
|
891
|
+
case alt_11
|
892
|
+
when 1
|
893
|
+
# at line 357:41: DIGIT
|
894
|
+
digit!
|
895
|
+
|
896
|
+
else
|
897
|
+
match_count_11 > 0 and break
|
898
|
+
eee = EarlyExit(11)
|
899
|
+
|
900
|
+
|
901
|
+
raise eee
|
902
|
+
end
|
903
|
+
match_count_11 += 1
|
904
|
+
end
|
905
|
+
|
906
|
+
|
907
|
+
|
908
|
+
@state.type = type
|
909
|
+
@state.channel = channel
|
910
|
+
|
911
|
+
ensure
|
912
|
+
# -> uncomment the next line to manually enable rule tracing
|
913
|
+
# trace_out(__method__, 24)
|
262
914
|
|
263
|
-
@type = :DIV
|
264
|
-
@type_int = DIV
|
265
|
-
# 342:6: '/'
|
266
|
-
match(?/)
|
267
915
|
end
|
268
916
|
|
269
|
-
|
917
|
+
# lexer rule true_const! (TRUE_CONST)
|
918
|
+
# (in ExcelFormula.g)
|
919
|
+
def true_const!
|
920
|
+
# -> uncomment the next line to manually enable rule tracing
|
921
|
+
# trace_in(__method__, 25)
|
922
|
+
|
923
|
+
type = TRUE_CONST
|
924
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
925
|
+
|
926
|
+
|
927
|
+
# - - - - main rule block - - - -
|
928
|
+
# at line 358:13: ( 'T' | 't' ) ( 'R' | 'r' ) ( 'U' | 'u' ) ( 'E' | 'e' )
|
929
|
+
if @input.peek(1) == ?T || @input.peek(1) == ?t
|
930
|
+
@input.consume
|
931
|
+
else
|
932
|
+
mse = MismatchedSet(nil)
|
933
|
+
recover(mse)
|
934
|
+
raise mse
|
935
|
+
end
|
936
|
+
|
937
|
+
|
938
|
+
if @input.peek(1) == ?R || @input.peek(1) == ?r
|
939
|
+
@input.consume
|
940
|
+
else
|
941
|
+
mse = MismatchedSet(nil)
|
942
|
+
recover(mse)
|
943
|
+
raise mse
|
944
|
+
end
|
945
|
+
|
946
|
+
|
947
|
+
if @input.peek(1) == ?U || @input.peek(1) == ?u
|
948
|
+
@input.consume
|
949
|
+
else
|
950
|
+
mse = MismatchedSet(nil)
|
951
|
+
recover(mse)
|
952
|
+
raise mse
|
953
|
+
end
|
954
|
+
|
955
|
+
|
956
|
+
if @input.peek(1) == ?E || @input.peek(1) == ?e
|
957
|
+
@input.consume
|
958
|
+
else
|
959
|
+
mse = MismatchedSet(nil)
|
960
|
+
recover(mse)
|
961
|
+
raise mse
|
962
|
+
end
|
963
|
+
|
964
|
+
|
965
|
+
|
966
|
+
|
967
|
+
@state.type = type
|
968
|
+
@state.channel = channel
|
969
|
+
|
970
|
+
ensure
|
971
|
+
# -> uncomment the next line to manually enable rule tracing
|
972
|
+
# trace_out(__method__, 25)
|
270
973
|
|
271
|
-
@type = :COLON
|
272
|
-
@type_int = COLON
|
273
|
-
# 344:8: ':'
|
274
|
-
match(?:)
|
275
974
|
end
|
276
975
|
|
277
|
-
|
976
|
+
# lexer rule false_const! (FALSE_CONST)
|
977
|
+
# (in ExcelFormula.g)
|
978
|
+
def false_const!
|
979
|
+
# -> uncomment the next line to manually enable rule tracing
|
980
|
+
# trace_in(__method__, 26)
|
981
|
+
|
982
|
+
type = FALSE_CONST
|
983
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
984
|
+
|
985
|
+
|
986
|
+
# - - - - main rule block - - - -
|
987
|
+
# at line 359:14: ( 'F' | 'f' ) ( 'A' | 'a' ) ( 'L' | 'l' ) ( 'S' | 's' ) ( 'E' | 'e' )
|
988
|
+
if @input.peek(1) == ?F || @input.peek(1) == ?f
|
989
|
+
@input.consume
|
990
|
+
else
|
991
|
+
mse = MismatchedSet(nil)
|
992
|
+
recover(mse)
|
993
|
+
raise mse
|
994
|
+
end
|
995
|
+
|
996
|
+
|
997
|
+
if @input.peek(1) == ?A || @input.peek(1) == ?a
|
998
|
+
@input.consume
|
999
|
+
else
|
1000
|
+
mse = MismatchedSet(nil)
|
1001
|
+
recover(mse)
|
1002
|
+
raise mse
|
1003
|
+
end
|
1004
|
+
|
1005
|
+
|
1006
|
+
if @input.peek(1) == ?L || @input.peek(1) == ?l
|
1007
|
+
@input.consume
|
1008
|
+
else
|
1009
|
+
mse = MismatchedSet(nil)
|
1010
|
+
recover(mse)
|
1011
|
+
raise mse
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
|
1015
|
+
if @input.peek(1) == ?S || @input.peek(1) == ?s
|
1016
|
+
@input.consume
|
1017
|
+
else
|
1018
|
+
mse = MismatchedSet(nil)
|
1019
|
+
recover(mse)
|
1020
|
+
raise mse
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
|
1024
|
+
if @input.peek(1) == ?E || @input.peek(1) == ?e
|
1025
|
+
@input.consume
|
1026
|
+
else
|
1027
|
+
mse = MismatchedSet(nil)
|
1028
|
+
recover(mse)
|
1029
|
+
raise mse
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
|
1033
|
+
|
1034
|
+
|
1035
|
+
@state.type = type
|
1036
|
+
@state.channel = channel
|
1037
|
+
|
1038
|
+
ensure
|
1039
|
+
# -> uncomment the next line to manually enable rule tracing
|
1040
|
+
# trace_out(__method__, 26)
|
278
1041
|
|
279
|
-
@type = :SEMICOLON
|
280
|
-
@type_int = SEMICOLON
|
281
|
-
# 345:12: ';'
|
282
|
-
match(?;)
|
283
1042
|
end
|
284
1043
|
|
285
|
-
|
1044
|
+
# lexer rule name! (NAME)
|
1045
|
+
# (in ExcelFormula.g)
|
1046
|
+
def name!
|
1047
|
+
# -> uncomment the next line to manually enable rule tracing
|
1048
|
+
# trace_in(__method__, 27)
|
1049
|
+
|
1050
|
+
type = NAME
|
1051
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
1052
|
+
|
1053
|
+
|
1054
|
+
# - - - - main rule block - - - -
|
1055
|
+
# at line 360:7: '\\w[\\.\\w]*'
|
1056
|
+
match("w[.w]*")
|
1057
|
+
|
1058
|
+
|
1059
|
+
@state.type = type
|
1060
|
+
@state.channel = channel
|
1061
|
+
|
1062
|
+
ensure
|
1063
|
+
# -> uncomment the next line to manually enable rule tracing
|
1064
|
+
# trace_out(__method__, 27)
|
286
1065
|
|
287
|
-
@type = :COMMA
|
288
|
-
@type_int = COMMA
|
289
|
-
# 346:8: ','
|
290
|
-
match(?,)
|
291
1066
|
end
|
292
1067
|
|
293
|
-
|
1068
|
+
# lexer rule quotename! (QUOTENAME)
|
1069
|
+
# (in ExcelFormula.g)
|
1070
|
+
def quotename!
|
1071
|
+
# -> uncomment the next line to manually enable rule tracing
|
1072
|
+
# trace_in(__method__, 28)
|
1073
|
+
|
1074
|
+
type = QUOTENAME
|
1075
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
1076
|
+
|
1077
|
+
|
1078
|
+
# - - - - main rule block - - - -
|
1079
|
+
# at line 361:12: '\\'(?:[^\\']|\\'\\')*\\''
|
1080
|
+
match("'(?:[^']|'')*'")
|
1081
|
+
|
1082
|
+
|
1083
|
+
@state.type = type
|
1084
|
+
@state.channel = channel
|
1085
|
+
|
1086
|
+
ensure
|
1087
|
+
# -> uncomment the next line to manually enable rule tracing
|
1088
|
+
# trace_out(__method__, 28)
|
294
1089
|
|
295
|
-
@type = :LP
|
296
|
-
@type_int = LP
|
297
|
-
# 348:5: '('
|
298
|
-
match(?()
|
299
1090
|
end
|
300
1091
|
|
301
|
-
|
1092
|
+
# lexer rule func_if! (FUNC_IF)
|
1093
|
+
# (in ExcelFormula.g)
|
1094
|
+
def func_if!
|
1095
|
+
# -> uncomment the next line to manually enable rule tracing
|
1096
|
+
# trace_in(__method__, 29)
|
1097
|
+
|
1098
|
+
type = FUNC_IF
|
1099
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
1100
|
+
|
1101
|
+
|
1102
|
+
# - - - - main rule block - - - -
|
1103
|
+
# at line 362:10: 'IF'
|
1104
|
+
match("IF")
|
1105
|
+
|
1106
|
+
|
1107
|
+
@state.type = type
|
1108
|
+
@state.channel = channel
|
1109
|
+
|
1110
|
+
ensure
|
1111
|
+
# -> uncomment the next line to manually enable rule tracing
|
1112
|
+
# trace_out(__method__, 29)
|
302
1113
|
|
303
|
-
@type = :RP
|
304
|
-
@type_int = RP
|
305
|
-
# 349:5: ')'
|
306
|
-
match(?))
|
307
1114
|
end
|
308
1115
|
|
309
|
-
|
1116
|
+
# lexer rule func_choose! (FUNC_CHOOSE)
|
1117
|
+
# (in ExcelFormula.g)
|
1118
|
+
def func_choose!
|
1119
|
+
# -> uncomment the next line to manually enable rule tracing
|
1120
|
+
# trace_in(__method__, 30)
|
1121
|
+
|
1122
|
+
type = FUNC_CHOOSE
|
1123
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
1124
|
+
|
1125
|
+
|
1126
|
+
# - - - - main rule block - - - -
|
1127
|
+
# at line 363:14: 'CHOOSE'
|
1128
|
+
match("CHOOSE")
|
1129
|
+
|
1130
|
+
|
1131
|
+
@state.type = type
|
1132
|
+
@state.channel = channel
|
1133
|
+
|
1134
|
+
ensure
|
1135
|
+
# -> uncomment the next line to manually enable rule tracing
|
1136
|
+
# trace_out(__method__, 30)
|
310
1137
|
|
311
|
-
@type = :CONCAT
|
312
|
-
@type_int = CONCAT
|
313
|
-
# 350:9: '&'
|
314
|
-
match(?&)
|
315
1138
|
end
|
316
1139
|
|
317
|
-
|
1140
|
+
# main rule used to study the input at the current position,
|
1141
|
+
# and choose the proper lexer rule to call in order to
|
1142
|
+
# fetch the next token
|
1143
|
+
#
|
1144
|
+
# usually, you don't make direct calls to this method,
|
1145
|
+
# but instead use the next_token method, which will
|
1146
|
+
# build and emit the actual next token
|
1147
|
+
def token!
|
1148
|
+
# at line 1:8: ( EQ | LT | GT | NE | LE | GE | ADD | SUB | MUL | DIV | COLON | SEMICOLON | COMMA | LP | RP | CONCAT | PERCENT | POWER | BANG | INT_CONST | NUM_CONST | STR_CONST | REF2D | TRUE_CONST | FALSE_CONST | NAME | QUOTENAME | FUNC_IF | FUNC_CHOOSE )
|
1149
|
+
alt_12 = 29
|
1150
|
+
alt_12 = @dfa12.predict(@input)
|
1151
|
+
case alt_12
|
1152
|
+
when 1
|
1153
|
+
# at line 1:10: EQ
|
1154
|
+
eq!
|
1155
|
+
|
1156
|
+
when 2
|
1157
|
+
# at line 1:13: LT
|
1158
|
+
lt!
|
1159
|
+
|
1160
|
+
when 3
|
1161
|
+
# at line 1:16: GT
|
1162
|
+
gt!
|
1163
|
+
|
1164
|
+
when 4
|
1165
|
+
# at line 1:19: NE
|
1166
|
+
ne!
|
1167
|
+
|
1168
|
+
when 5
|
1169
|
+
# at line 1:22: LE
|
1170
|
+
le!
|
1171
|
+
|
1172
|
+
when 6
|
1173
|
+
# at line 1:25: GE
|
1174
|
+
ge!
|
1175
|
+
|
1176
|
+
when 7
|
1177
|
+
# at line 1:28: ADD
|
1178
|
+
add!
|
1179
|
+
|
1180
|
+
when 8
|
1181
|
+
# at line 1:32: SUB
|
1182
|
+
sub!
|
1183
|
+
|
1184
|
+
when 9
|
1185
|
+
# at line 1:36: MUL
|
1186
|
+
mul!
|
1187
|
+
|
1188
|
+
when 10
|
1189
|
+
# at line 1:40: DIV
|
1190
|
+
div!
|
1191
|
+
|
1192
|
+
when 11
|
1193
|
+
# at line 1:44: COLON
|
1194
|
+
colon!
|
1195
|
+
|
1196
|
+
when 12
|
1197
|
+
# at line 1:50: SEMICOLON
|
1198
|
+
semicolon!
|
1199
|
+
|
1200
|
+
when 13
|
1201
|
+
# at line 1:60: COMMA
|
1202
|
+
comma!
|
1203
|
+
|
1204
|
+
when 14
|
1205
|
+
# at line 1:66: LP
|
1206
|
+
lp!
|
1207
|
+
|
1208
|
+
when 15
|
1209
|
+
# at line 1:69: RP
|
1210
|
+
rp!
|
1211
|
+
|
1212
|
+
when 16
|
1213
|
+
# at line 1:72: CONCAT
|
1214
|
+
concat!
|
1215
|
+
|
1216
|
+
when 17
|
1217
|
+
# at line 1:79: PERCENT
|
1218
|
+
percent!
|
1219
|
+
|
1220
|
+
when 18
|
1221
|
+
# at line 1:87: POWER
|
1222
|
+
power!
|
1223
|
+
|
1224
|
+
when 19
|
1225
|
+
# at line 1:93: BANG
|
1226
|
+
bang!
|
1227
|
+
|
1228
|
+
when 20
|
1229
|
+
# at line 1:98: INT_CONST
|
1230
|
+
int_const!
|
1231
|
+
|
1232
|
+
when 21
|
1233
|
+
# at line 1:108: NUM_CONST
|
1234
|
+
num_const!
|
1235
|
+
|
1236
|
+
when 22
|
1237
|
+
# at line 1:118: STR_CONST
|
1238
|
+
str_const!
|
1239
|
+
|
1240
|
+
when 23
|
1241
|
+
# at line 1:128: REF2D
|
1242
|
+
ref_2_d!
|
1243
|
+
|
1244
|
+
when 24
|
1245
|
+
# at line 1:134: TRUE_CONST
|
1246
|
+
true_const!
|
1247
|
+
|
1248
|
+
when 25
|
1249
|
+
# at line 1:145: FALSE_CONST
|
1250
|
+
false_const!
|
1251
|
+
|
1252
|
+
when 26
|
1253
|
+
# at line 1:157: NAME
|
1254
|
+
name!
|
318
1255
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
1256
|
+
when 27
|
1257
|
+
# at line 1:162: QUOTENAME
|
1258
|
+
quotename!
|
1259
|
+
|
1260
|
+
when 28
|
1261
|
+
# at line 1:172: FUNC_IF
|
1262
|
+
func_if!
|
1263
|
+
|
1264
|
+
when 29
|
1265
|
+
# at line 1:180: FUNC_CHOOSE
|
1266
|
+
func_choose!
|
1267
|
+
|
1268
|
+
end
|
323
1269
|
end
|
324
1270
|
|
325
|
-
|
1271
|
+
|
1272
|
+
# - - - - - - - - - - DFA definitions - - - - - - - - - - -
|
1273
|
+
class DFA12 < ANTLR3::DFA
|
1274
|
+
EOT = unpack(2, -1, 1, 31, 1, 33, 13, -1, 1, 34, 18, -1, 1, 38, 3,
|
1275
|
+
-1)
|
1276
|
+
EOF = unpack(40, -1)
|
1277
|
+
MIN = unpack(1, 0, 1, -1, 2, 61, 13, -1, 1, 46, 3, -1, 2, 36, 1, -1,
|
1278
|
+
1, 36, 3, -1, 1, 36, 6, -1, 3, 36, 2, -1)
|
1279
|
+
MAX = unpack(1, 116, 1, -1, 1, 62, 1, 61, 13, -1, 1, 57, 3, -1, 1,
|
1280
|
+
97, 1, 114, 1, -1, 1, 90, 3, -1, 1, 90, 6, -1, 1, 108,
|
1281
|
+
1, 57, 1, 79, 2, -1)
|
1282
|
+
ACCEPT = unpack(1, -1, 1, 1, 2, -1, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11,
|
1283
|
+
1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1,
|
1284
|
+
19, 1, -1, 1, 21, 1, 22, 1, 23, 2, -1, 1, 24, 1, -1,
|
1285
|
+
1, 25, 1, 26, 1, 27, 1, -1, 1, 4, 1, 5, 1, 2, 1, 6,
|
1286
|
+
1, 3, 1, 20, 3, -1, 1, 28, 1, 29)
|
1287
|
+
SPECIAL = unpack(40, -1)
|
1288
|
+
TRANSITION = [
|
1289
|
+
unpack(1, 26, 32, -1, 1, 16, 1, 19, 1, -1, 1, 20, 1, 14, 1, 13,
|
1290
|
+
1, 27, 1, 11, 1, 12, 1, 6, 1, 4, 1, 10, 1, 5, 1, 18, 1, 7,
|
1291
|
+
10, 17, 1, 8, 1, 9, 1, 2, 1, 1, 1, 3, 2, -1, 2, 20, 1, 28,
|
1292
|
+
2, 20, 1, 21, 2, 20, 1, 24, 10, 20, 1, 22, 6, 20, 3, -1,
|
1293
|
+
1, 15, 7, -1, 1, 25, 13, -1, 1, 23),
|
1294
|
+
unpack(),
|
1295
|
+
unpack(1, 30, 1, 29),
|
1296
|
+
unpack(1, 32),
|
1297
|
+
unpack(),
|
1298
|
+
unpack(),
|
1299
|
+
unpack(),
|
1300
|
+
unpack(),
|
1301
|
+
unpack(),
|
1302
|
+
unpack(),
|
1303
|
+
unpack(),
|
1304
|
+
unpack(),
|
1305
|
+
unpack(),
|
1306
|
+
unpack(),
|
1307
|
+
unpack(),
|
1308
|
+
unpack(),
|
1309
|
+
unpack(),
|
1310
|
+
unpack(1, 18, 1, -1, 10, 17),
|
1311
|
+
unpack(),
|
1312
|
+
unpack(),
|
1313
|
+
unpack(),
|
1314
|
+
unpack(1, 20, 11, -1, 10, 20, 7, -1, 1, 35, 25, 20, 6, -1, 1, 25),
|
1315
|
+
unpack(1, 20, 11, -1, 10, 20, 24, -1, 1, 23, 31, -1, 1, 23),
|
1316
|
+
unpack(),
|
1317
|
+
unpack(1, 20, 11, -1, 10, 20, 7, -1, 5, 20, 1, 36, 20, 20),
|
1318
|
+
unpack(),
|
1319
|
+
unpack(),
|
1320
|
+
unpack(),
|
1321
|
+
unpack(1, 20, 11, -1, 10, 20, 7, -1, 7, 20, 1, 37, 18, 20),
|
1322
|
+
unpack(),
|
1323
|
+
unpack(),
|
1324
|
+
unpack(),
|
1325
|
+
unpack(),
|
1326
|
+
unpack(),
|
1327
|
+
unpack(),
|
1328
|
+
unpack(1, 20, 11, -1, 10, 20, 18, -1, 1, 25, 31, -1, 1, 25),
|
1329
|
+
unpack(1, 20, 11, -1, 10, 20),
|
1330
|
+
unpack(1, 20, 11, -1, 10, 20, 21, -1, 1, 39),
|
1331
|
+
unpack(),
|
1332
|
+
unpack()
|
1333
|
+
].freeze
|
1334
|
+
|
1335
|
+
( 0 ... MIN.length ).zip( MIN, MAX ) do | i, a, z |
|
1336
|
+
if a > 0 and z < 0
|
1337
|
+
MAX[ i ] %= 0x10000
|
1338
|
+
end
|
1339
|
+
end
|
1340
|
+
|
1341
|
+
@decision = 12
|
1342
|
+
|
1343
|
+
|
1344
|
+
def description
|
1345
|
+
<<-'__dfa_description__'.strip!
|
1346
|
+
1:1: Tokens : ( EQ | LT | GT | NE | LE | GE | ADD | SUB | MUL | DIV | COLON | SEMICOLON | COMMA | LP | RP | CONCAT | PERCENT | POWER | BANG | INT_CONST | NUM_CONST | STR_CONST | REF2D | TRUE_CONST | FALSE_CONST | NAME | QUOTENAME | FUNC_IF | FUNC_CHOOSE );
|
1347
|
+
__dfa_description__
|
1348
|
+
end
|
1349
|
+
end
|
1350
|
+
|
1351
|
+
|
1352
|
+
private
|
1353
|
+
|
1354
|
+
def initialize_dfas
|
1355
|
+
super rescue nil
|
1356
|
+
@dfa12 = DFA12.new(self, 12)
|
326
1357
|
|
327
|
-
@type = :POWER
|
328
|
-
@type_int = POWER
|
329
|
-
# 352:8: '^'
|
330
|
-
match(?^)
|
331
1358
|
end
|
1359
|
+
end # class Lexer < ANTLR3::Lexer
|
332
1360
|
|
333
|
-
|
1361
|
+
at_exit { Lexer.main(ARGV) } if __FILE__ == $0
|
1362
|
+
end
|
334
1363
|
|
335
|
-
@type = :BANG
|
336
|
-
@type_int = BANG
|
337
|
-
# 353:7: '!'
|
338
|
-
match(?!)
|
339
|
-
end
|
340
|
-
|
341
|
-
def match_DIGIT()
|
342
|
-
|
343
|
-
@type = :DIGIT
|
344
|
-
@type_int = DIGIT
|
345
|
-
# 355:8: '0' .. '9'
|
346
|
-
match_range(?0, ?9)
|
347
|
-
end
|
348
|
-
|
349
|
-
def match_INT_CONST()
|
350
|
-
|
351
|
-
@type = :INT_CONST
|
352
|
-
@type_int = INT_CONST
|
353
|
-
# 357:12: ( DIGIT )+
|
354
|
-
# 357:12: ( DIGIT )+
|
355
|
-
matchedOnce1 = false
|
356
|
-
while true
|
357
|
-
alt1 = 2
|
358
|
-
#
|
359
|
-
look_ahead1_0 = @input.look_ahead(1)
|
360
|
-
look_ahead1_0 = -1 if look_ahead1_0 == :EOF
|
361
|
-
if (look_ahead1_0 >= ?0 && look_ahead1_0 <= ?9)
|
362
|
-
alt1 = 1
|
363
|
-
end
|
364
|
-
case alt1
|
365
|
-
when 1
|
366
|
-
# 357:12: DIGIT
|
367
|
-
match_DIGIT()
|
368
|
-
else
|
369
|
-
break
|
370
|
-
end
|
371
|
-
matchedOnce1 = true
|
372
|
-
end
|
373
|
-
|
374
|
-
if !matchedOnce1
|
375
|
-
raise "Expected at least one match: 357:12: ( DIGIT )+"
|
376
|
-
end
|
377
|
-
end
|
378
|
-
|
379
|
-
def match_NUM_CONST()
|
380
|
-
|
381
|
-
@type = :NUM_CONST
|
382
|
-
@type_int = NUM_CONST
|
383
|
-
# 358:12: ( DIGIT )* '.' ( DIGIT )+ ( ( 'E' | 'e' ) ( '+' | '-' )? ( DIGIT )+ )?
|
384
|
-
# 358:12: ( DIGIT )*
|
385
|
-
while true
|
386
|
-
alt2 = 2
|
387
|
-
#
|
388
|
-
look_ahead2_0 = @input.look_ahead(1)
|
389
|
-
look_ahead2_0 = -1 if look_ahead2_0 == :EOF
|
390
|
-
if (look_ahead2_0 >= ?0 && look_ahead2_0 <= ?9)
|
391
|
-
alt2 = 1
|
392
|
-
end
|
393
|
-
case alt2
|
394
|
-
when 1
|
395
|
-
# 358:12: DIGIT
|
396
|
-
match_DIGIT()
|
397
|
-
else
|
398
|
-
break
|
399
|
-
end
|
400
|
-
end
|
401
|
-
match(?.)
|
402
|
-
# 358:23: ( DIGIT )+
|
403
|
-
matchedOnce3 = false
|
404
|
-
while true
|
405
|
-
alt3 = 2
|
406
|
-
#
|
407
|
-
look_ahead3_0 = @input.look_ahead(1)
|
408
|
-
look_ahead3_0 = -1 if look_ahead3_0 == :EOF
|
409
|
-
if (look_ahead3_0 >= ?0 && look_ahead3_0 <= ?9)
|
410
|
-
alt3 = 1
|
411
|
-
end
|
412
|
-
case alt3
|
413
|
-
when 1
|
414
|
-
# 358:23: DIGIT
|
415
|
-
match_DIGIT()
|
416
|
-
else
|
417
|
-
break
|
418
|
-
end
|
419
|
-
matchedOnce3 = true
|
420
|
-
end
|
421
|
-
|
422
|
-
if !matchedOnce3
|
423
|
-
raise "Expected at least one match: 358:23: ( DIGIT )+"
|
424
|
-
end
|
425
|
-
# 358:30: ( ( 'E' | 'e' ) ( '+' | '-' )? ( DIGIT )+ )?
|
426
|
-
alt6 = 2
|
427
|
-
#
|
428
|
-
look_ahead6_0 = @input.look_ahead(1)
|
429
|
-
|
430
|
-
look_ahead6_0 = -1 if look_ahead6_0 == :EOF
|
431
|
-
if look_ahead6_0 == ?E || look_ahead6_0 == ?e
|
432
|
-
alt6 = 1
|
433
|
-
end
|
434
|
-
case alt6
|
435
|
-
when 1
|
436
|
-
# 358:31: ( 'E' | 'e' ) ( '+' | '-' )? ( DIGIT )+
|
437
|
-
if @input.look_ahead(1) == ?E || @input.look_ahead(1) == ?e
|
438
|
-
match()
|
439
|
-
else
|
440
|
-
raise "Expected set"
|
441
|
-
end
|
442
|
-
# 358:41: ( '+' | '-' )?
|
443
|
-
alt4 = 2
|
444
|
-
#
|
445
|
-
look_ahead4_0 = @input.look_ahead(1)
|
446
|
-
|
447
|
-
look_ahead4_0 = -1 if look_ahead4_0 == :EOF
|
448
|
-
if look_ahead4_0 == ?+ || look_ahead4_0 == ?-
|
449
|
-
alt4 = 1
|
450
|
-
end
|
451
|
-
case alt4
|
452
|
-
when 1
|
453
|
-
#
|
454
|
-
if @input.look_ahead(1) == ?+ || @input.look_ahead(1) == ?-
|
455
|
-
match()
|
456
|
-
else
|
457
|
-
raise "Expected set"
|
458
|
-
end
|
459
|
-
end
|
460
|
-
# 358:52: ( DIGIT )+
|
461
|
-
matchedOnce5 = false
|
462
|
-
while true
|
463
|
-
alt5 = 2
|
464
|
-
#
|
465
|
-
look_ahead5_0 = @input.look_ahead(1)
|
466
|
-
look_ahead5_0 = -1 if look_ahead5_0 == :EOF
|
467
|
-
if (look_ahead5_0 >= ?0 && look_ahead5_0 <= ?9)
|
468
|
-
alt5 = 1
|
469
|
-
end
|
470
|
-
case alt5
|
471
|
-
when 1
|
472
|
-
# 358:52: DIGIT
|
473
|
-
match_DIGIT()
|
474
|
-
else
|
475
|
-
break
|
476
|
-
end
|
477
|
-
matchedOnce5 = true
|
478
|
-
end
|
479
|
-
|
480
|
-
if !matchedOnce5
|
481
|
-
raise "Expected at least one match: 358:52: ( DIGIT )+"
|
482
|
-
end
|
483
|
-
end
|
484
|
-
end
|
485
|
-
|
486
|
-
def match_STR_CONST()
|
487
|
-
|
488
|
-
@type = :STR_CONST
|
489
|
-
@type_int = STR_CONST
|
490
|
-
# 359:12: '\"' ~ '\"' '\"'
|
491
|
-
match(?")
|
492
|
-
if (@input.look_ahead(1) >= 0x0000 && @input.look_ahead(1) <= ?!) || (@input.look_ahead(1) >= ?# && @input.look_ahead(1) <= 0x00FF)
|
493
|
-
match()
|
494
|
-
else
|
495
|
-
raise "Expected set"
|
496
|
-
end
|
497
|
-
match(?")
|
498
|
-
end
|
499
|
-
|
500
|
-
def match_REF2D()
|
501
|
-
|
502
|
-
@type = :REF2D
|
503
|
-
@type_int = REF2D
|
504
|
-
# 360:8: ( '$' )? ( 'A' .. 'I' )? ( 'A' .. 'Z' ) ( '$' )? ( DIGIT )+
|
505
|
-
# 360:8: ( '$' )?
|
506
|
-
alt7 = 2
|
507
|
-
#
|
508
|
-
look_ahead7_0 = @input.look_ahead(1)
|
509
|
-
|
510
|
-
look_ahead7_0 = -1 if look_ahead7_0 == :EOF
|
511
|
-
if look_ahead7_0 == ?$
|
512
|
-
alt7 = 1
|
513
|
-
end
|
514
|
-
case alt7
|
515
|
-
when 1
|
516
|
-
# 360:8: '$'
|
517
|
-
match(?$)
|
518
|
-
end
|
519
|
-
# 360:13: ( 'A' .. 'I' )?
|
520
|
-
alt8 = 2
|
521
|
-
#
|
522
|
-
look_ahead8_0 = @input.look_ahead(1)
|
523
|
-
|
524
|
-
look_ahead8_0 = -1 if look_ahead8_0 == :EOF
|
525
|
-
if (look_ahead8_0 >= ?A && look_ahead8_0 <= ?I)
|
526
|
-
#
|
527
|
-
look_ahead8_1 = @input.look_ahead(2)
|
528
|
-
|
529
|
-
look_ahead8_1 = -1 if look_ahead8_1 == :EOF
|
530
|
-
if (look_ahead8_1 >= ?A && look_ahead8_1 <= ?Z)
|
531
|
-
alt8 = 1
|
532
|
-
end
|
533
|
-
end
|
534
|
-
case alt8
|
535
|
-
when 1
|
536
|
-
# 360:14: 'A' .. 'I'
|
537
|
-
match_range(?A, ?I)
|
538
|
-
end
|
539
|
-
# 360:26: 'A' .. 'Z'
|
540
|
-
match_range(?A, ?Z)
|
541
|
-
# 360:36: ( '$' )?
|
542
|
-
alt9 = 2
|
543
|
-
#
|
544
|
-
look_ahead9_0 = @input.look_ahead(1)
|
545
|
-
|
546
|
-
look_ahead9_0 = -1 if look_ahead9_0 == :EOF
|
547
|
-
if look_ahead9_0 == ?$
|
548
|
-
alt9 = 1
|
549
|
-
end
|
550
|
-
case alt9
|
551
|
-
when 1
|
552
|
-
# 360:36: '$'
|
553
|
-
match(?$)
|
554
|
-
end
|
555
|
-
# 360:41: ( DIGIT )+
|
556
|
-
matchedOnce10 = false
|
557
|
-
while true
|
558
|
-
alt10 = 2
|
559
|
-
#
|
560
|
-
look_ahead10_0 = @input.look_ahead(1)
|
561
|
-
look_ahead10_0 = -1 if look_ahead10_0 == :EOF
|
562
|
-
if (look_ahead10_0 >= ?0 && look_ahead10_0 <= ?9)
|
563
|
-
alt10 = 1
|
564
|
-
end
|
565
|
-
case alt10
|
566
|
-
when 1
|
567
|
-
# 360:41: DIGIT
|
568
|
-
match_DIGIT()
|
569
|
-
else
|
570
|
-
break
|
571
|
-
end
|
572
|
-
matchedOnce10 = true
|
573
|
-
end
|
574
|
-
|
575
|
-
if !matchedOnce10
|
576
|
-
raise "Expected at least one match: 360:41: ( DIGIT )+"
|
577
|
-
end
|
578
|
-
end
|
579
|
-
|
580
|
-
def match_TRUE_CONST()
|
581
|
-
|
582
|
-
@type = :TRUE_CONST
|
583
|
-
@type_int = TRUE_CONST
|
584
|
-
# 361:13: ( 'T' | 't' ) ( 'R' | 'r' ) ( 'U' | 'u' ) ( 'E' | 'e' )
|
585
|
-
if @input.look_ahead(1) == ?T || @input.look_ahead(1) == ?t
|
586
|
-
match()
|
587
|
-
else
|
588
|
-
raise "Expected set"
|
589
|
-
end
|
590
|
-
if @input.look_ahead(1) == ?R || @input.look_ahead(1) == ?r
|
591
|
-
match()
|
592
|
-
else
|
593
|
-
raise "Expected set"
|
594
|
-
end
|
595
|
-
if @input.look_ahead(1) == ?U || @input.look_ahead(1) == ?u
|
596
|
-
match()
|
597
|
-
else
|
598
|
-
raise "Expected set"
|
599
|
-
end
|
600
|
-
if @input.look_ahead(1) == ?E || @input.look_ahead(1) == ?e
|
601
|
-
match()
|
602
|
-
else
|
603
|
-
raise "Expected set"
|
604
|
-
end
|
605
|
-
end
|
606
|
-
|
607
|
-
def match_FALSE_CONST()
|
608
|
-
|
609
|
-
@type = :FALSE_CONST
|
610
|
-
@type_int = FALSE_CONST
|
611
|
-
# 362:14: ( 'F' | 'f' ) ( 'A' | 'a' ) ( 'L' | 'l' ) ( 'S' | 's' ) ( 'E' | 'e' )
|
612
|
-
if @input.look_ahead(1) == ?F || @input.look_ahead(1) == ?f
|
613
|
-
match()
|
614
|
-
else
|
615
|
-
raise "Expected set"
|
616
|
-
end
|
617
|
-
if @input.look_ahead(1) == ?A || @input.look_ahead(1) == ?a
|
618
|
-
match()
|
619
|
-
else
|
620
|
-
raise "Expected set"
|
621
|
-
end
|
622
|
-
if @input.look_ahead(1) == ?L || @input.look_ahead(1) == ?l
|
623
|
-
match()
|
624
|
-
else
|
625
|
-
raise "Expected set"
|
626
|
-
end
|
627
|
-
if @input.look_ahead(1) == ?S || @input.look_ahead(1) == ?s
|
628
|
-
match()
|
629
|
-
else
|
630
|
-
raise "Expected set"
|
631
|
-
end
|
632
|
-
if @input.look_ahead(1) == ?E || @input.look_ahead(1) == ?e
|
633
|
-
match()
|
634
|
-
else
|
635
|
-
raise "Expected set"
|
636
|
-
end
|
637
|
-
end
|
638
|
-
|
639
|
-
def match_NAME()
|
640
|
-
|
641
|
-
@type = :NAME
|
642
|
-
@type_int = NAME
|
643
|
-
# 363:7: '\\w[\\.\\w]*'
|
644
|
-
match("w[.w]*")
|
645
|
-
|
646
|
-
end
|
647
|
-
|
648
|
-
def match_QUOTENAME()
|
649
|
-
|
650
|
-
@type = :QUOTENAME
|
651
|
-
@type_int = QUOTENAME
|
652
|
-
# 364:12: '\\'(?:[^\\']|\\'\\')*\\''
|
653
|
-
match("'(?:[^']|'')*'")
|
654
|
-
|
655
|
-
end
|
656
|
-
|
657
|
-
def match_FUNC_IF()
|
658
|
-
|
659
|
-
@type = :FUNC_IF
|
660
|
-
@type_int = FUNC_IF
|
661
|
-
# 365:10: 'IF'
|
662
|
-
match("IF")
|
663
|
-
|
664
|
-
end
|
665
|
-
|
666
|
-
def match_FUNC_CHOOSE()
|
667
|
-
|
668
|
-
@type = :FUNC_CHOOSE
|
669
|
-
@type_int = FUNC_CHOOSE
|
670
|
-
# 366:14: 'CHOOSE'
|
671
|
-
match("CHOOSE")
|
672
|
-
|
673
|
-
end
|
674
|
-
|
675
|
-
def match_Tokens()
|
676
|
-
|
677
|
-
# 1:8: ( LT | GT | NE | LE | GE | ADD | SUB | MUL | DIV | COLON | SEMICOLON | COMMA | LP | RP | CONCAT | PERCENT | POWER | BANG | DIGIT | INT_CONST | NUM_CONST | STR_CONST | REF2D | TRUE_CONST | FALSE_CONST | NAME | QUOTENAME | FUNC_IF | FUNC_CHOOSE )
|
678
|
-
alt11 = 29
|
679
|
-
alt11 = DFA11.predict(self, @input)
|
680
|
-
case alt11
|
681
|
-
when 1
|
682
|
-
# 1:10: LT
|
683
|
-
match_LT()
|
684
|
-
when 2
|
685
|
-
# 1:13: GT
|
686
|
-
match_GT()
|
687
|
-
when 3
|
688
|
-
# 1:16: NE
|
689
|
-
match_NE()
|
690
|
-
when 4
|
691
|
-
# 1:19: LE
|
692
|
-
match_LE()
|
693
|
-
when 5
|
694
|
-
# 1:22: GE
|
695
|
-
match_GE()
|
696
|
-
when 6
|
697
|
-
# 1:25: ADD
|
698
|
-
match_ADD()
|
699
|
-
when 7
|
700
|
-
# 1:29: SUB
|
701
|
-
match_SUB()
|
702
|
-
when 8
|
703
|
-
# 1:33: MUL
|
704
|
-
match_MUL()
|
705
|
-
when 9
|
706
|
-
# 1:37: DIV
|
707
|
-
match_DIV()
|
708
|
-
when 10
|
709
|
-
# 1:41: COLON
|
710
|
-
match_COLON()
|
711
|
-
when 11
|
712
|
-
# 1:47: SEMICOLON
|
713
|
-
match_SEMICOLON()
|
714
|
-
when 12
|
715
|
-
# 1:57: COMMA
|
716
|
-
match_COMMA()
|
717
|
-
when 13
|
718
|
-
# 1:63: LP
|
719
|
-
match_LP()
|
720
|
-
when 14
|
721
|
-
# 1:66: RP
|
722
|
-
match_RP()
|
723
|
-
when 15
|
724
|
-
# 1:69: CONCAT
|
725
|
-
match_CONCAT()
|
726
|
-
when 16
|
727
|
-
# 1:76: PERCENT
|
728
|
-
match_PERCENT()
|
729
|
-
when 17
|
730
|
-
# 1:84: POWER
|
731
|
-
match_POWER()
|
732
|
-
when 18
|
733
|
-
# 1:90: BANG
|
734
|
-
match_BANG()
|
735
|
-
when 19
|
736
|
-
# 1:95: DIGIT
|
737
|
-
match_DIGIT()
|
738
|
-
when 20
|
739
|
-
# 1:101: INT_CONST
|
740
|
-
match_INT_CONST()
|
741
|
-
when 21
|
742
|
-
# 1:111: NUM_CONST
|
743
|
-
match_NUM_CONST()
|
744
|
-
when 22
|
745
|
-
# 1:121: STR_CONST
|
746
|
-
match_STR_CONST()
|
747
|
-
when 23
|
748
|
-
# 1:131: REF2D
|
749
|
-
match_REF2D()
|
750
|
-
when 24
|
751
|
-
# 1:137: TRUE_CONST
|
752
|
-
match_TRUE_CONST()
|
753
|
-
when 25
|
754
|
-
# 1:148: FALSE_CONST
|
755
|
-
match_FALSE_CONST()
|
756
|
-
when 26
|
757
|
-
# 1:160: NAME
|
758
|
-
match_NAME()
|
759
|
-
when 27
|
760
|
-
# 1:165: QUOTENAME
|
761
|
-
match_QUOTENAME()
|
762
|
-
when 28
|
763
|
-
# 1:175: FUNC_IF
|
764
|
-
match_FUNC_IF()
|
765
|
-
when 29
|
766
|
-
# 1:183: FUNC_CHOOSE
|
767
|
-
match_FUNC_CHOOSE()
|
768
|
-
end
|
769
|
-
|
770
|
-
end
|
771
|
-
|
772
|
-
|
773
|
-
class DFA
|
774
|
-
def initialize(eot, eof, min, max, accept, special, transition)
|
775
|
-
@eot = eot
|
776
|
-
@eof = eof
|
777
|
-
@min = min
|
778
|
-
@max = max
|
779
|
-
@accept = accept
|
780
|
-
@special = special
|
781
|
-
@transition = transition
|
782
|
-
end
|
783
|
-
|
784
|
-
def predict(parser, input)
|
785
|
-
mark = input.mark()
|
786
|
-
s = 0 # we always start at s0
|
787
|
-
begin
|
788
|
-
loop do
|
789
|
-
special_state = @special[s]
|
790
|
-
if special_state >= 0
|
791
|
-
s = parser.special_state_transition(special_state)
|
792
|
-
input.consume()
|
793
|
-
next
|
794
|
-
end
|
795
|
-
|
796
|
-
if @accept[s] >= 1
|
797
|
-
return @accept[s]
|
798
|
-
end
|
799
|
-
|
800
|
-
# look for a normal char transition
|
801
|
-
c = input.look_ahead(1).to_i
|
802
|
-
if c != :EOF && c >= @min[s] && c <= @max[s]
|
803
|
-
next_state = @transition[s][c - @min[s]] # move to next state
|
804
|
-
if next_state < 0
|
805
|
-
# was in range but not a normal transition
|
806
|
-
# must check EOT, which is like the else clause.
|
807
|
-
# eot[s]>=0 indicates that an EOT edge goes to another
|
808
|
-
# state.
|
809
|
-
if @eot[s] >= 0 # EOT Transition to accept state?
|
810
|
-
s = @eot[s]
|
811
|
-
input.consume()
|
812
|
-
next
|
813
|
-
end
|
814
|
-
raise "No viable alt"
|
815
|
-
end
|
816
|
-
s = next_state
|
817
|
-
input.consume()
|
818
|
-
next
|
819
|
-
end
|
820
|
-
if @eot[s] >= 0 # EOT Transition?
|
821
|
-
s = @eot[s]
|
822
|
-
input.consume()
|
823
|
-
next
|
824
|
-
end
|
825
|
-
if c == :EOF && @eof[s] >= 0 # EOF Transition to accept state?
|
826
|
-
return @accept[@eof[s]]
|
827
|
-
end
|
828
|
-
|
829
|
-
# not in range and not EOF/EOT, must be invalid symbol
|
830
|
-
raise "No viable alt"
|
831
|
-
end
|
832
|
-
ensure
|
833
|
-
input.rewind(mark)
|
834
|
-
end
|
835
|
-
end
|
836
|
-
end
|
837
|
-
|
838
|
-
DFA11 = DFA.new(
|
839
|
-
[-1,30,32,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,33,-1,-1,-1,-1,
|
840
|
-
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,38,-1,39,-1,-1,-1,-1],
|
841
|
-
[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
842
|
-
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],
|
843
|
-
[0,61,61,0,0,0,0,0,0,0,0,0,0,0,0,0,46,0,0,0,36,36,0,36,0,0,0,36,
|
844
|
-
0,0,0,0,0,0,46,36,36,36,0,0,0],
|
845
|
-
[116,62,61,0,0,0,0,0,0,0,0,0,0,0,0,0,57,0,0,0,97,114,0,90,0,0,0,
|
846
|
-
90,0,0,0,0,0,0,57,108,57,79,0,0,0],
|
847
|
-
[-1,-1,-1,6,7,8,9,10,11,12,13,14,15,16,17,18,-1,21,22,23,-1,-1,24,
|
848
|
-
-1,25,26,27,-1,3,4,1,5,2,19,-1,-1,-1,-1,20,28,29],
|
849
|
-
[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
850
|
-
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],
|
851
|
-
[
|
852
|
-
[25,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
853
|
-
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,15,18,-1,19,13,12,
|
854
|
-
26,10,11,5,3,9,4,17,6,16,16,16,16,16,16,16,16,16,16,7,8,
|
855
|
-
1,-1,2,-1,-1,19,19,27,19,19,20,19,19,23,19,19,19,19,19,
|
856
|
-
19,19,19,19,19,21,19,19,19,19,19,19,-1,-1,-1,14,-1,-1,-1,
|
857
|
-
-1,-1,-1,-1,24,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,22],
|
858
|
-
[29,28],
|
859
|
-
[31],
|
860
|
-
[],
|
861
|
-
[],
|
862
|
-
[],
|
863
|
-
[],
|
864
|
-
[],
|
865
|
-
[],
|
866
|
-
[],
|
867
|
-
[],
|
868
|
-
[],
|
869
|
-
[],
|
870
|
-
[],
|
871
|
-
[],
|
872
|
-
[],
|
873
|
-
[17,-1,34,34,34,34,34,34,34,34,34,34],
|
874
|
-
[],
|
875
|
-
[],
|
876
|
-
[],
|
877
|
-
[19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
|
878
|
-
19,19,-1,-1,-1,-1,-1,-1,-1,35,19,19,19,19,19,19,19,19,19,
|
879
|
-
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,-1,-1,-1,
|
880
|
-
-1,-1,-1,24],
|
881
|
-
[19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
|
882
|
-
19,19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
883
|
-
-1,-1,-1,-1,-1,-1,-1,22,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
884
|
-
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
885
|
-
-1,22],
|
886
|
-
[],
|
887
|
-
[19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
|
888
|
-
19,19,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,36,19,19,19,19,
|
889
|
-
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19],
|
890
|
-
[],
|
891
|
-
[],
|
892
|
-
[],
|
893
|
-
[19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
|
894
|
-
19,19,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,37,19,19,
|
895
|
-
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19],
|
896
|
-
[],
|
897
|
-
[],
|
898
|
-
[],
|
899
|
-
[],
|
900
|
-
[],
|
901
|
-
[],
|
902
|
-
[17,-1,34,34,34,34,34,34,34,34,34,34],
|
903
|
-
[19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
|
904
|
-
19,19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
905
|
-
-1,24,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
906
|
-
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,24],
|
907
|
-
[19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
|
908
|
-
19,19],
|
909
|
-
[19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,19,19,19,19,19,19,19,19,
|
910
|
-
19,19,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
911
|
-
-1,-1,-1,-1,40],
|
912
|
-
[],
|
913
|
-
[],
|
914
|
-
[]
|
915
|
-
])
|
916
|
-
|
917
|
-
def special_state_transition(s)
|
918
|
-
-1
|
919
|
-
end
|
920
|
-
|
921
|
-
public :special_state_transition
|
922
|
-
end
|