plympton 1.1.0
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.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +15 -0
- data/LICENSE.txt +20 -0
- data/README.md +24 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/bin/func-auto.py +431 -0
- data/bin/func.py +435 -0
- data/bin/func.py.new +440 -0
- data/bin/idascript.py +21 -0
- data/lib/plympton.rb +26 -0
- data/lib/plympton/Solver.tokens +25 -0
- data/lib/plympton/SolverLexer.rb +704 -0
- data/lib/plympton/SolverParser.rb +550 -0
- data/lib/plympton/block.rb +19 -0
- data/lib/plympton/chunk.rb +20 -0
- data/lib/plympton/disassembly.rb +105 -0
- data/lib/plympton/function.rb +31 -0
- data/lib/plympton/matrix.rb +59 -0
- data/lib/plympton/object.rb +153 -0
- data/lib/plympton/solver.g +118 -0
- data/plympton.gemspec +95 -0
- data/spec/libFontParser.64.dylib.fz +152170 -0
- data/spec/libauto.dylib.fz +127001 -0
- data/spec/plympton_spec.rb +220 -0
- data/spec/rufus-test.32bit.trace.xml +53 -0
- data/spec/rufus-test.64bit.trace.xml +50 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/steady-state.64bit.trace.xml +12070 -0
- metadata +195 -0
data/bin/idascript.py
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# http://www.hexblog.com/?p=128
|
2
|
+
import os
|
3
|
+
import sys
|
4
|
+
|
5
|
+
class ToFileStdOut(object):
|
6
|
+
def __init__(self):
|
7
|
+
self.outfile = open(os.environ['PWD'] + "/" + 'idaout.txt', 'w')
|
8
|
+
|
9
|
+
def write(self, text):
|
10
|
+
self.outfile.write(text)
|
11
|
+
|
12
|
+
def flush(self):
|
13
|
+
self.outfile.flush()
|
14
|
+
|
15
|
+
def isatty(self):
|
16
|
+
return False
|
17
|
+
|
18
|
+
def __del__(self):
|
19
|
+
self.outfile.close()
|
20
|
+
|
21
|
+
sys.stdout = sys.stderr = ToFileStdOut()
|
data/lib/plympton.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'bigdecimal'
|
3
|
+
require 'bigdecimal/math'
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'narray'
|
6
|
+
|
7
|
+
Dir[File.dirname(__FILE__) + "/plympton/*.rb"].each do |file|
|
8
|
+
require "plympton/#{File.basename(file, File.extname(file))}"
|
9
|
+
end
|
10
|
+
|
11
|
+
# Add in the YAML parsing hooks
|
12
|
+
YAML.add_domain_type("fuzz.io,2011", "Object") do |type, val|
|
13
|
+
YAML.object_maker(Plympton::Object, val)
|
14
|
+
end
|
15
|
+
|
16
|
+
YAML.add_domain_type("fuzz.io,2011", "Function") do |type, val|
|
17
|
+
YAML.object_maker(Plympton::Function, val)
|
18
|
+
end
|
19
|
+
|
20
|
+
YAML.add_domain_type("fuzz.io,2011", "Chunk") do |type, val|
|
21
|
+
YAML.object_maker(Plympton::Chunk, val)
|
22
|
+
end
|
23
|
+
|
24
|
+
YAML.add_domain_type("fuzz.io,2011", "Block") do |type, val|
|
25
|
+
YAML.object_maker(Plympton::Block, val)
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
MOD=8
|
2
|
+
WHITESPACE=18
|
3
|
+
INT=12
|
4
|
+
FLOAT=13
|
5
|
+
MULT=6
|
6
|
+
MINUS=5
|
7
|
+
MODIFIER=17
|
8
|
+
LPAREN=10
|
9
|
+
T__19=19
|
10
|
+
RPAREN=11
|
11
|
+
EXP=9
|
12
|
+
PLUS=4
|
13
|
+
MODVAR=14
|
14
|
+
DIGIT=16
|
15
|
+
DIV=7
|
16
|
+
UNMODVAR=15
|
17
|
+
'ln'=19
|
18
|
+
'/'=7
|
19
|
+
'('=10
|
20
|
+
'*'=6
|
21
|
+
'-'=5
|
22
|
+
'+'=4
|
23
|
+
')'=11
|
24
|
+
'^'=9
|
25
|
+
'%'=8
|
@@ -0,0 +1,704 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# solver.g
|
4
|
+
# --
|
5
|
+
# Generated using ANTLR version: 3.2.1-SNAPSHOT Jul 31, 2010 19:34:52
|
6
|
+
# Ruby runtime library version: 1.8.11
|
7
|
+
# Input grammar file: solver.g
|
8
|
+
# Generated at: 2011-11-02 11:29:53
|
9
|
+
#
|
10
|
+
|
11
|
+
# ~~~> start load path setup
|
12
|
+
this_directory = File.expand_path( File.dirname( __FILE__ ) )
|
13
|
+
$LOAD_PATH.unshift( this_directory ) unless $LOAD_PATH.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.8.11):
|
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.8.11' )
|
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 Solver
|
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( :MOD => 8, :WHITESPACE => 18, :FLOAT => 13, :INT => 12,
|
70
|
+
:MULT => 6, :MINUS => 5, :EOF => -1, :MODIFIER => 17,
|
71
|
+
:LPAREN => 10, :T__19 => 19, :RPAREN => 11, :EXP => 9,
|
72
|
+
:PLUS => 4, :MODVAR => 14, :DIGIT => 16, :DIV => 7, :UNMODVAR => 15 )
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
class Lexer < ANTLR3::Lexer
|
78
|
+
@grammar_home = Solver
|
79
|
+
include TokenData
|
80
|
+
|
81
|
+
|
82
|
+
begin
|
83
|
+
generated_using( "solver.g", "3.2.1-SNAPSHOT Jul 31, 2010 19:34:52", "1.8.11" )
|
84
|
+
rescue NoMethodError => error
|
85
|
+
# ignore
|
86
|
+
end
|
87
|
+
|
88
|
+
RULE_NAMES = [ "PLUS", "MINUS", "MULT", "DIV", "MOD", "EXP", "LPAREN",
|
89
|
+
"RPAREN", "T__19", "INT", "FLOAT", "MODVAR", "UNMODVAR",
|
90
|
+
"WHITESPACE", "DIGIT", "MODIFIER" ].freeze
|
91
|
+
RULE_METHODS = [ :plus!, :minus!, :mult!, :div!, :mod!, :exp!, :lparen!,
|
92
|
+
:rparen!, :t__19!, :int!, :float!, :modvar!, :unmodvar!,
|
93
|
+
:whitespace!, :digit!, :modifier! ].freeze
|
94
|
+
|
95
|
+
|
96
|
+
def initialize( input=nil, options = {} )
|
97
|
+
super( input, options )
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
# - - - - - - begin action @lexer::members - - - - - -
|
102
|
+
# solver.g
|
103
|
+
|
104
|
+
|
105
|
+
# Recovery function handling errors
|
106
|
+
def recover( error = $! )
|
107
|
+
puts "Lexer Recovering: #{error}"
|
108
|
+
exit(1)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Reporting function handling errors
|
112
|
+
def report_error( error = $! )
|
113
|
+
puts "Lexer Reporting: #{error}"
|
114
|
+
exit(1)
|
115
|
+
end
|
116
|
+
|
117
|
+
# - - - - - - end action @lexer::members - - - - - - -
|
118
|
+
|
119
|
+
|
120
|
+
# - - - - - - - - - - - lexer rules - - - - - - - - - - - -
|
121
|
+
# lexer rule plus! (PLUS)
|
122
|
+
# (in solver.g)
|
123
|
+
def plus!
|
124
|
+
# -> uncomment the next line to manually enable rule tracing
|
125
|
+
# trace_in( __method__, 1 )
|
126
|
+
|
127
|
+
type = PLUS
|
128
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
129
|
+
|
130
|
+
|
131
|
+
# - - - - main rule block - - - -
|
132
|
+
# at line 21:8: '+'
|
133
|
+
match( 0x2b )
|
134
|
+
|
135
|
+
|
136
|
+
@state.type = type
|
137
|
+
@state.channel = channel
|
138
|
+
|
139
|
+
ensure
|
140
|
+
# -> uncomment the next line to manually enable rule tracing
|
141
|
+
# trace_out( __method__, 1 )
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
# lexer rule minus! (MINUS)
|
146
|
+
# (in solver.g)
|
147
|
+
def minus!
|
148
|
+
# -> uncomment the next line to manually enable rule tracing
|
149
|
+
# trace_in( __method__, 2 )
|
150
|
+
|
151
|
+
type = MINUS
|
152
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
153
|
+
|
154
|
+
|
155
|
+
# - - - - main rule block - - - -
|
156
|
+
# at line 22:9: '-'
|
157
|
+
match( 0x2d )
|
158
|
+
|
159
|
+
|
160
|
+
@state.type = type
|
161
|
+
@state.channel = channel
|
162
|
+
|
163
|
+
ensure
|
164
|
+
# -> uncomment the next line to manually enable rule tracing
|
165
|
+
# trace_out( __method__, 2 )
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
# lexer rule mult! (MULT)
|
170
|
+
# (in solver.g)
|
171
|
+
def mult!
|
172
|
+
# -> uncomment the next line to manually enable rule tracing
|
173
|
+
# trace_in( __method__, 3 )
|
174
|
+
|
175
|
+
type = MULT
|
176
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
177
|
+
|
178
|
+
|
179
|
+
# - - - - main rule block - - - -
|
180
|
+
# at line 23:8: '*'
|
181
|
+
match( 0x2a )
|
182
|
+
|
183
|
+
|
184
|
+
@state.type = type
|
185
|
+
@state.channel = channel
|
186
|
+
|
187
|
+
ensure
|
188
|
+
# -> uncomment the next line to manually enable rule tracing
|
189
|
+
# trace_out( __method__, 3 )
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
# lexer rule div! (DIV)
|
194
|
+
# (in solver.g)
|
195
|
+
def div!
|
196
|
+
# -> uncomment the next line to manually enable rule tracing
|
197
|
+
# trace_in( __method__, 4 )
|
198
|
+
|
199
|
+
type = DIV
|
200
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
201
|
+
|
202
|
+
|
203
|
+
# - - - - main rule block - - - -
|
204
|
+
# at line 24:7: '/'
|
205
|
+
match( 0x2f )
|
206
|
+
|
207
|
+
|
208
|
+
@state.type = type
|
209
|
+
@state.channel = channel
|
210
|
+
|
211
|
+
ensure
|
212
|
+
# -> uncomment the next line to manually enable rule tracing
|
213
|
+
# trace_out( __method__, 4 )
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
# lexer rule mod! (MOD)
|
218
|
+
# (in solver.g)
|
219
|
+
def mod!
|
220
|
+
# -> uncomment the next line to manually enable rule tracing
|
221
|
+
# trace_in( __method__, 5 )
|
222
|
+
|
223
|
+
type = MOD
|
224
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
225
|
+
|
226
|
+
|
227
|
+
# - - - - main rule block - - - -
|
228
|
+
# at line 25:7: '%'
|
229
|
+
match( 0x25 )
|
230
|
+
|
231
|
+
|
232
|
+
@state.type = type
|
233
|
+
@state.channel = channel
|
234
|
+
|
235
|
+
ensure
|
236
|
+
# -> uncomment the next line to manually enable rule tracing
|
237
|
+
# trace_out( __method__, 5 )
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
# lexer rule exp! (EXP)
|
242
|
+
# (in solver.g)
|
243
|
+
def exp!
|
244
|
+
# -> uncomment the next line to manually enable rule tracing
|
245
|
+
# trace_in( __method__, 6 )
|
246
|
+
|
247
|
+
type = EXP
|
248
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
249
|
+
|
250
|
+
|
251
|
+
# - - - - main rule block - - - -
|
252
|
+
# at line 26:7: '^'
|
253
|
+
match( 0x5e )
|
254
|
+
|
255
|
+
|
256
|
+
@state.type = type
|
257
|
+
@state.channel = channel
|
258
|
+
|
259
|
+
ensure
|
260
|
+
# -> uncomment the next line to manually enable rule tracing
|
261
|
+
# trace_out( __method__, 6 )
|
262
|
+
|
263
|
+
end
|
264
|
+
|
265
|
+
# lexer rule lparen! (LPAREN)
|
266
|
+
# (in solver.g)
|
267
|
+
def lparen!
|
268
|
+
# -> uncomment the next line to manually enable rule tracing
|
269
|
+
# trace_in( __method__, 7 )
|
270
|
+
|
271
|
+
type = LPAREN
|
272
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
273
|
+
|
274
|
+
|
275
|
+
# - - - - main rule block - - - -
|
276
|
+
# at line 27:10: '('
|
277
|
+
match( 0x28 )
|
278
|
+
|
279
|
+
|
280
|
+
@state.type = type
|
281
|
+
@state.channel = channel
|
282
|
+
|
283
|
+
ensure
|
284
|
+
# -> uncomment the next line to manually enable rule tracing
|
285
|
+
# trace_out( __method__, 7 )
|
286
|
+
|
287
|
+
end
|
288
|
+
|
289
|
+
# lexer rule rparen! (RPAREN)
|
290
|
+
# (in solver.g)
|
291
|
+
def rparen!
|
292
|
+
# -> uncomment the next line to manually enable rule tracing
|
293
|
+
# trace_in( __method__, 8 )
|
294
|
+
|
295
|
+
type = RPAREN
|
296
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
297
|
+
|
298
|
+
|
299
|
+
# - - - - main rule block - - - -
|
300
|
+
# at line 28:10: ')'
|
301
|
+
match( 0x29 )
|
302
|
+
|
303
|
+
|
304
|
+
@state.type = type
|
305
|
+
@state.channel = channel
|
306
|
+
|
307
|
+
ensure
|
308
|
+
# -> uncomment the next line to manually enable rule tracing
|
309
|
+
# trace_out( __method__, 8 )
|
310
|
+
|
311
|
+
end
|
312
|
+
|
313
|
+
# lexer rule t__19! (T__19)
|
314
|
+
# (in solver.g)
|
315
|
+
def t__19!
|
316
|
+
# -> uncomment the next line to manually enable rule tracing
|
317
|
+
# trace_in( __method__, 9 )
|
318
|
+
|
319
|
+
type = T__19
|
320
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
321
|
+
|
322
|
+
|
323
|
+
# - - - - main rule block - - - -
|
324
|
+
# at line 29:9: 'ln'
|
325
|
+
match( "ln" )
|
326
|
+
|
327
|
+
|
328
|
+
@state.type = type
|
329
|
+
@state.channel = channel
|
330
|
+
|
331
|
+
ensure
|
332
|
+
# -> uncomment the next line to manually enable rule tracing
|
333
|
+
# trace_out( __method__, 9 )
|
334
|
+
|
335
|
+
end
|
336
|
+
|
337
|
+
# lexer rule int! (INT)
|
338
|
+
# (in solver.g)
|
339
|
+
def int!
|
340
|
+
# -> uncomment the next line to manually enable rule tracing
|
341
|
+
# trace_in( __method__, 10 )
|
342
|
+
|
343
|
+
type = INT
|
344
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
345
|
+
|
346
|
+
|
347
|
+
# - - - - main rule block - - - -
|
348
|
+
# at line 107:11: ( DIGIT )+
|
349
|
+
# at file 107:11: ( DIGIT )+
|
350
|
+
match_count_1 = 0
|
351
|
+
while true
|
352
|
+
alt_1 = 2
|
353
|
+
look_1_0 = @input.peek( 1 )
|
354
|
+
|
355
|
+
if ( look_1_0.between?( 0x30, 0x39 ) )
|
356
|
+
alt_1 = 1
|
357
|
+
|
358
|
+
end
|
359
|
+
case alt_1
|
360
|
+
when 1
|
361
|
+
# at line 107:12: DIGIT
|
362
|
+
digit!
|
363
|
+
|
364
|
+
else
|
365
|
+
match_count_1 > 0 and break
|
366
|
+
eee = EarlyExit(1)
|
367
|
+
|
368
|
+
|
369
|
+
raise eee
|
370
|
+
end
|
371
|
+
match_count_1 += 1
|
372
|
+
end
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
@state.type = type
|
377
|
+
@state.channel = channel
|
378
|
+
|
379
|
+
ensure
|
380
|
+
# -> uncomment the next line to manually enable rule tracing
|
381
|
+
# trace_out( __method__, 10 )
|
382
|
+
|
383
|
+
end
|
384
|
+
|
385
|
+
# lexer rule float! (FLOAT)
|
386
|
+
# (in solver.g)
|
387
|
+
def float!
|
388
|
+
# -> uncomment the next line to manually enable rule tracing
|
389
|
+
# trace_in( __method__, 11 )
|
390
|
+
|
391
|
+
type = FLOAT
|
392
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
393
|
+
|
394
|
+
|
395
|
+
# - - - - main rule block - - - -
|
396
|
+
# at line 108:12: INT '.' INT
|
397
|
+
int!
|
398
|
+
match( 0x2e )
|
399
|
+
int!
|
400
|
+
|
401
|
+
|
402
|
+
@state.type = type
|
403
|
+
@state.channel = channel
|
404
|
+
|
405
|
+
ensure
|
406
|
+
# -> uncomment the next line to manually enable rule tracing
|
407
|
+
# trace_out( __method__, 11 )
|
408
|
+
|
409
|
+
end
|
410
|
+
|
411
|
+
# lexer rule modvar! (MODVAR)
|
412
|
+
# (in solver.g)
|
413
|
+
def modvar!
|
414
|
+
# -> uncomment the next line to manually enable rule tracing
|
415
|
+
# trace_in( __method__, 12 )
|
416
|
+
|
417
|
+
type = MODVAR
|
418
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
419
|
+
|
420
|
+
|
421
|
+
# - - - - main rule block - - - -
|
422
|
+
# at line 109:13: 'A' .. 'G' ( MODIFIER )
|
423
|
+
match_range( 0x41, 0x47 )
|
424
|
+
# at line 109:21: ( MODIFIER )
|
425
|
+
# at line 109:22: MODIFIER
|
426
|
+
modifier!
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
@state.type = type
|
431
|
+
@state.channel = channel
|
432
|
+
|
433
|
+
ensure
|
434
|
+
# -> uncomment the next line to manually enable rule tracing
|
435
|
+
# trace_out( __method__, 12 )
|
436
|
+
|
437
|
+
end
|
438
|
+
|
439
|
+
# lexer rule unmodvar! (UNMODVAR)
|
440
|
+
# (in solver.g)
|
441
|
+
def unmodvar!
|
442
|
+
# -> uncomment the next line to manually enable rule tracing
|
443
|
+
# trace_in( __method__, 13 )
|
444
|
+
|
445
|
+
type = UNMODVAR
|
446
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
447
|
+
|
448
|
+
|
449
|
+
# - - - - main rule block - - - -
|
450
|
+
# at line 110:14: ( 'R' | 'U' | 'V' )
|
451
|
+
if @input.peek(1) == 0x52 || @input.peek( 1 ).between?( 0x55, 0x56 )
|
452
|
+
@input.consume
|
453
|
+
else
|
454
|
+
mse = MismatchedSet( nil )
|
455
|
+
recover mse
|
456
|
+
raise mse
|
457
|
+
end
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
@state.type = type
|
463
|
+
@state.channel = channel
|
464
|
+
|
465
|
+
ensure
|
466
|
+
# -> uncomment the next line to manually enable rule tracing
|
467
|
+
# trace_out( __method__, 13 )
|
468
|
+
|
469
|
+
end
|
470
|
+
|
471
|
+
# lexer rule whitespace! (WHITESPACE)
|
472
|
+
# (in solver.g)
|
473
|
+
def whitespace!
|
474
|
+
# -> uncomment the next line to manually enable rule tracing
|
475
|
+
# trace_in( __method__, 14 )
|
476
|
+
|
477
|
+
type = WHITESPACE
|
478
|
+
channel = ANTLR3::DEFAULT_CHANNEL
|
479
|
+
|
480
|
+
|
481
|
+
# - - - - main rule block - - - -
|
482
|
+
# at line 111:14: ( '\\t' | ' ' | '\\r' | '\\n' | '\\u000C' )+
|
483
|
+
# at file 111:14: ( '\\t' | ' ' | '\\r' | '\\n' | '\\u000C' )+
|
484
|
+
match_count_2 = 0
|
485
|
+
while true
|
486
|
+
alt_2 = 2
|
487
|
+
look_2_0 = @input.peek( 1 )
|
488
|
+
|
489
|
+
if ( look_2_0.between?( 0x9, 0xa ) || look_2_0.between?( 0xc, 0xd ) || look_2_0 == 0x20 )
|
490
|
+
alt_2 = 1
|
491
|
+
|
492
|
+
end
|
493
|
+
case alt_2
|
494
|
+
when 1
|
495
|
+
# at line
|
496
|
+
if @input.peek( 1 ).between?( 0x9, 0xa ) || @input.peek( 1 ).between?( 0xc, 0xd ) || @input.peek(1) == 0x20
|
497
|
+
@input.consume
|
498
|
+
else
|
499
|
+
mse = MismatchedSet( nil )
|
500
|
+
recover mse
|
501
|
+
raise mse
|
502
|
+
end
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
else
|
507
|
+
match_count_2 > 0 and break
|
508
|
+
eee = EarlyExit(2)
|
509
|
+
|
510
|
+
|
511
|
+
raise eee
|
512
|
+
end
|
513
|
+
match_count_2 += 1
|
514
|
+
end
|
515
|
+
|
516
|
+
# --> action
|
517
|
+
channel = HIDDEN;
|
518
|
+
# <-- action
|
519
|
+
|
520
|
+
|
521
|
+
@state.type = type
|
522
|
+
@state.channel = channel
|
523
|
+
|
524
|
+
ensure
|
525
|
+
# -> uncomment the next line to manually enable rule tracing
|
526
|
+
# trace_out( __method__, 14 )
|
527
|
+
|
528
|
+
end
|
529
|
+
|
530
|
+
# lexer rule digit! (DIGIT)
|
531
|
+
# (in solver.g)
|
532
|
+
def digit!
|
533
|
+
# -> uncomment the next line to manually enable rule tracing
|
534
|
+
# trace_in( __method__, 15 )
|
535
|
+
|
536
|
+
|
537
|
+
# - - - - main rule block - - - -
|
538
|
+
# at line 117:18: '0' .. '9'
|
539
|
+
match_range( 0x30, 0x39 )
|
540
|
+
|
541
|
+
ensure
|
542
|
+
# -> uncomment the next line to manually enable rule tracing
|
543
|
+
# trace_out( __method__, 15 )
|
544
|
+
|
545
|
+
end
|
546
|
+
|
547
|
+
# lexer rule modifier! (MODIFIER)
|
548
|
+
# (in solver.g)
|
549
|
+
def modifier!
|
550
|
+
# -> uncomment the next line to manually enable rule tracing
|
551
|
+
# trace_in( __method__, 16 )
|
552
|
+
|
553
|
+
|
554
|
+
# - - - - main rule block - - - -
|
555
|
+
# at line
|
556
|
+
if @input.peek(1) == 0x61 || @input.peek(1) == 0x73
|
557
|
+
@input.consume
|
558
|
+
else
|
559
|
+
mse = MismatchedSet( nil )
|
560
|
+
recover mse
|
561
|
+
raise mse
|
562
|
+
end
|
563
|
+
|
564
|
+
|
565
|
+
|
566
|
+
ensure
|
567
|
+
# -> uncomment the next line to manually enable rule tracing
|
568
|
+
# trace_out( __method__, 16 )
|
569
|
+
|
570
|
+
end
|
571
|
+
|
572
|
+
# main rule used to study the input at the current position,
|
573
|
+
# and choose the proper lexer rule to call in order to
|
574
|
+
# fetch the next token
|
575
|
+
#
|
576
|
+
# usually, you don't make direct calls to this method,
|
577
|
+
# but instead use the next_token method, which will
|
578
|
+
# build and emit the actual next token
|
579
|
+
def token!
|
580
|
+
# at line 1:8: ( PLUS | MINUS | MULT | DIV | MOD | EXP | LPAREN | RPAREN | T__19 | INT | FLOAT | MODVAR | UNMODVAR | WHITESPACE )
|
581
|
+
alt_3 = 14
|
582
|
+
alt_3 = @dfa3.predict( @input )
|
583
|
+
case alt_3
|
584
|
+
when 1
|
585
|
+
# at line 1:10: PLUS
|
586
|
+
plus!
|
587
|
+
|
588
|
+
when 2
|
589
|
+
# at line 1:15: MINUS
|
590
|
+
minus!
|
591
|
+
|
592
|
+
when 3
|
593
|
+
# at line 1:21: MULT
|
594
|
+
mult!
|
595
|
+
|
596
|
+
when 4
|
597
|
+
# at line 1:26: DIV
|
598
|
+
div!
|
599
|
+
|
600
|
+
when 5
|
601
|
+
# at line 1:30: MOD
|
602
|
+
mod!
|
603
|
+
|
604
|
+
when 6
|
605
|
+
# at line 1:34: EXP
|
606
|
+
exp!
|
607
|
+
|
608
|
+
when 7
|
609
|
+
# at line 1:38: LPAREN
|
610
|
+
lparen!
|
611
|
+
|
612
|
+
when 8
|
613
|
+
# at line 1:45: RPAREN
|
614
|
+
rparen!
|
615
|
+
|
616
|
+
when 9
|
617
|
+
# at line 1:52: T__19
|
618
|
+
t__19!
|
619
|
+
|
620
|
+
when 10
|
621
|
+
# at line 1:58: INT
|
622
|
+
int!
|
623
|
+
|
624
|
+
when 11
|
625
|
+
# at line 1:62: FLOAT
|
626
|
+
float!
|
627
|
+
|
628
|
+
when 12
|
629
|
+
# at line 1:68: MODVAR
|
630
|
+
modvar!
|
631
|
+
|
632
|
+
when 13
|
633
|
+
# at line 1:75: UNMODVAR
|
634
|
+
unmodvar!
|
635
|
+
|
636
|
+
when 14
|
637
|
+
# at line 1:84: WHITESPACE
|
638
|
+
whitespace!
|
639
|
+
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
|
644
|
+
# - - - - - - - - - - DFA definitions - - - - - - - - - - -
|
645
|
+
class DFA3 < ANTLR3::DFA
|
646
|
+
EOT = unpack( 10, -1, 1, 14, 5, -1 )
|
647
|
+
EOF = unpack( 16, -1 )
|
648
|
+
MIN = unpack( 1, 9, 9, -1, 1, 46, 5, -1 )
|
649
|
+
MAX = unpack( 1, 108, 9, -1, 1, 57, 5, -1 )
|
650
|
+
ACCEPT = unpack( 1, -1, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7,
|
651
|
+
1, 8, 1, 9, 1, -1, 1, 12, 1, 13, 1, 14, 1, 10, 1,
|
652
|
+
11 )
|
653
|
+
SPECIAL = unpack( 16, -1 )
|
654
|
+
TRANSITION = [
|
655
|
+
unpack( 2, 13, 1, -1, 2, 13, 18, -1, 1, 13, 4, -1, 1, 5, 2, -1,
|
656
|
+
1, 7, 1, 8, 1, 3, 1, 1, 1, -1, 1, 2, 1, -1, 1, 4, 10, 10,
|
657
|
+
7, -1, 7, 11, 10, -1, 1, 12, 2, -1, 2, 12, 7, -1, 1, 6,
|
658
|
+
13, -1, 1, 9 ),
|
659
|
+
unpack( ),
|
660
|
+
unpack( ),
|
661
|
+
unpack( ),
|
662
|
+
unpack( ),
|
663
|
+
unpack( ),
|
664
|
+
unpack( ),
|
665
|
+
unpack( ),
|
666
|
+
unpack( ),
|
667
|
+
unpack( ),
|
668
|
+
unpack( 1, 15, 1, -1, 10, 10 ),
|
669
|
+
unpack( ),
|
670
|
+
unpack( ),
|
671
|
+
unpack( ),
|
672
|
+
unpack( ),
|
673
|
+
unpack( )
|
674
|
+
].freeze
|
675
|
+
|
676
|
+
( 0 ... MIN.length ).zip( MIN, MAX ) do | i, a, z |
|
677
|
+
if a > 0 and z < 0
|
678
|
+
MAX[ i ] %= 0x10000
|
679
|
+
end
|
680
|
+
end
|
681
|
+
|
682
|
+
@decision = 3
|
683
|
+
|
684
|
+
|
685
|
+
def description
|
686
|
+
<<-'__dfa_description__'.strip!
|
687
|
+
1:1: Tokens : ( PLUS | MINUS | MULT | DIV | MOD | EXP | LPAREN | RPAREN | T__19 | INT | FLOAT | MODVAR | UNMODVAR | WHITESPACE );
|
688
|
+
__dfa_description__
|
689
|
+
end
|
690
|
+
end
|
691
|
+
|
692
|
+
|
693
|
+
private
|
694
|
+
|
695
|
+
def initialize_dfas
|
696
|
+
super rescue nil
|
697
|
+
@dfa3 = DFA3.new( self, 3 )
|
698
|
+
|
699
|
+
end
|
700
|
+
end # class Lexer < ANTLR3::Lexer
|
701
|
+
|
702
|
+
at_exit { Lexer.main( ARGV ) } if __FILE__ == $0
|
703
|
+
end
|
704
|
+
|