omghax-einstein 0.1.1 → 0.2.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.
- data/Benchmarks.txt +48 -0
- data/History.txt +9 -0
- data/Manifest.txt +14 -21
- data/README.txt +1 -8
- data/Rakefile +26 -13
- data/einstein.gemspec +24 -0
- data/lib/einstein.rb +10 -41
- data/lib/einstein/evaluator.rb +102 -0
- data/lib/einstein/expression.rb +37 -0
- data/lib/einstein/parser.racc +41 -0
- data/lib/einstein/parser.racc.rb +333 -0
- data/lib/einstein/parser.rex +42 -0
- data/lib/einstein/parser.rex.rb +101 -0
- data/lib/einstein/pretty_printer.rb +98 -0
- data/lib/einstein/processor.rb +12 -0
- data/lib/einstein/version.rb +3 -3
- data/tasks/benchmark.rake +28 -0
- data/test/helper.rb +2 -1
- data/test/test_einstein.rb +20 -0
- data/test/test_evaluator.rb +86 -0
- data/test/test_parser.rb +35 -30
- data/test/test_pretty_printer.rb +81 -0
- metadata +31 -31
- data/config/hoe.rb +0 -62
- data/config/requirements.rb +0 -17
- data/lib/einstein/generated_parser.rb +0 -337
- data/lib/einstein/nodes.rb +0 -155
- data/lib/einstein/parser.rb +0 -60
- data/lib/einstein/tokenizer.rb +0 -112
- data/lib/einstein/visitors.rb +0 -303
- data/lib/parser.y +0 -79
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -74
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/test/test_evaluate.rb +0 -127
- data/test/test_pretty_print.rb +0 -119
- data/test/test_tokenizer.rb +0 -68
- data/website/index.html +0 -120
- data/website/index.txt +0 -58
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.rhtml +0 -48
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
#
|
|
2
|
+
# DO NOT MODIFY!!!!
|
|
3
|
+
# This file is automatically generated by racc 1.4.5
|
|
4
|
+
# from racc grammer file "lib/einstein/parser.racc".
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
require 'racc/parser'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
require 'einstein/parser.rex.rb'
|
|
11
|
+
|
|
12
|
+
module Einstein
|
|
13
|
+
|
|
14
|
+
class Parser < Racc::Parser
|
|
15
|
+
|
|
16
|
+
##### racc 1.4.5 generates ###
|
|
17
|
+
|
|
18
|
+
racc_reduce_table = [
|
|
19
|
+
0, 0, :racc_error,
|
|
20
|
+
1, 19, :_reduce_none,
|
|
21
|
+
1, 21, :_reduce_2,
|
|
22
|
+
1, 21, :_reduce_3,
|
|
23
|
+
3, 22, :_reduce_4,
|
|
24
|
+
1, 22, :_reduce_none,
|
|
25
|
+
1, 23, :_reduce_none,
|
|
26
|
+
2, 23, :_reduce_7,
|
|
27
|
+
2, 23, :_reduce_8,
|
|
28
|
+
2, 23, :_reduce_9,
|
|
29
|
+
1, 24, :_reduce_none,
|
|
30
|
+
3, 24, :_reduce_11,
|
|
31
|
+
1, 25, :_reduce_none,
|
|
32
|
+
3, 25, :_reduce_13,
|
|
33
|
+
3, 25, :_reduce_14,
|
|
34
|
+
3, 25, :_reduce_15,
|
|
35
|
+
1, 26, :_reduce_none,
|
|
36
|
+
3, 26, :_reduce_17,
|
|
37
|
+
3, 26, :_reduce_18,
|
|
38
|
+
1, 27, :_reduce_none,
|
|
39
|
+
3, 27, :_reduce_20,
|
|
40
|
+
3, 27, :_reduce_21,
|
|
41
|
+
1, 28, :_reduce_none,
|
|
42
|
+
3, 28, :_reduce_23,
|
|
43
|
+
1, 20, :_reduce_none,
|
|
44
|
+
3, 20, :_reduce_25,
|
|
45
|
+
3, 20, :_reduce_26 ]
|
|
46
|
+
|
|
47
|
+
racc_reduce_n = 27
|
|
48
|
+
|
|
49
|
+
racc_shift_n = 46
|
|
50
|
+
|
|
51
|
+
racc_action_table = [
|
|
52
|
+
4, 6, 8, 17, 11, 12, 13, 4, 6, 8,
|
|
53
|
+
17, 11, 12, 13, 4, 6, 8, 17, 11, 12,
|
|
54
|
+
13, 4, 6, 8, 17, 11, 12, 13, 4, 6,
|
|
55
|
+
8, 43, 11, 12, 13, 4, 6, 8, 26, 11,
|
|
56
|
+
12, 13, 4, 6, 8, 39, 11, 12, 13, 4,
|
|
57
|
+
6, 8, 30, 11, 12, 13, 4, 6, 8, 26,
|
|
58
|
+
11, 12, 13, 4, 6, 8, 26, 11, 12, 13,
|
|
59
|
+
4, 6, 8, nil, 11, 12, 13, 4, 6, 8,
|
|
60
|
+
nil, 11, 12, 13, 4, 6, 8, nil, 11, 12,
|
|
61
|
+
13, 4, 6, 8, nil, 11, 12, 13, 4, 6,
|
|
62
|
+
8, nil, 11, 12, 13, 4, 6, 8, nil, 11,
|
|
63
|
+
12, 13, 20, 18, 19, 20, 18, 19, 20, 18,
|
|
64
|
+
19, 24, 25, 21, 22, 21, 22, 21, 22, 24,
|
|
65
|
+
25, 31, 32 ]
|
|
66
|
+
|
|
67
|
+
racc_action_check = [
|
|
68
|
+
0, 0, 0, 34, 0, 0, 0, 32, 32, 32,
|
|
69
|
+
35, 32, 32, 32, 31, 31, 31, 36, 31, 31,
|
|
70
|
+
31, 26, 26, 26, 3, 26, 26, 26, 8, 8,
|
|
71
|
+
8, 30, 8, 8, 8, 25, 25, 25, 10, 25,
|
|
72
|
+
25, 25, 24, 24, 24, 23, 24, 24, 24, 11,
|
|
73
|
+
11, 11, 14, 11, 11, 11, 12, 12, 12, 44,
|
|
74
|
+
12, 12, 12, 13, 13, 13, 45, 13, 13, 13,
|
|
75
|
+
20, 20, 20, nil, 20, 20, 20, 21, 21, 21,
|
|
76
|
+
nil, 21, 21, 21, 17, 17, 17, nil, 17, 17,
|
|
77
|
+
17, 18, 18, 18, nil, 18, 18, 18, 19, 19,
|
|
78
|
+
19, nil, 19, 19, 19, 22, 22, 22, nil, 22,
|
|
79
|
+
22, 22, 37, 37, 37, 5, 5, 5, 38, 38,
|
|
80
|
+
38, 9, 9, 40, 40, 7, 7, 41, 41, 42,
|
|
81
|
+
42, 15, 15 ]
|
|
82
|
+
|
|
83
|
+
racc_action_pointer = [
|
|
84
|
+
-2, nil, nil, 15, nil, 105, nil, 119, 26, 108,
|
|
85
|
+
23, 47, 54, 61, 52, 115, nil, 82, 89, 96,
|
|
86
|
+
68, 75, 103, 40, 40, 33, 19, nil, nil, nil,
|
|
87
|
+
31, 12, 5, nil, -6, 1, 8, 102, 108, nil,
|
|
88
|
+
117, 121, 116, nil, 44, 51 ]
|
|
89
|
+
|
|
90
|
+
racc_action_default = [
|
|
91
|
+
-27, -6, -10, -12, -2, -16, -3, -19, -27, -22,
|
|
92
|
+
-24, -27, -27, -27, -27, -1, -5, -27, -27, -27,
|
|
93
|
+
-27, -27, -27, -27, -27, -27, -27, -7, -8, -9,
|
|
94
|
+
-27, -27, -27, -11, -14, -15, -13, -17, -18, -4,
|
|
95
|
+
-20, -21, -23, 46, -25, -26 ]
|
|
96
|
+
|
|
97
|
+
racc_goto_table = [
|
|
98
|
+
14, 27, 28, 29, 34, 35, 36, 33, 23, 37,
|
|
99
|
+
38, 40, 41, 44, 45, 42 ]
|
|
100
|
+
|
|
101
|
+
racc_goto_check = [
|
|
102
|
+
1, 5, 5, 5, 6, 6, 6, 5, 1, 7,
|
|
103
|
+
7, 8, 8, 10, 10, 9 ]
|
|
104
|
+
|
|
105
|
+
racc_goto_pointer = [
|
|
106
|
+
nil, 0, nil, nil, nil, -10, -14, -12, -13, -11,
|
|
107
|
+
-18 ]
|
|
108
|
+
|
|
109
|
+
racc_goto_default = [
|
|
110
|
+
nil, nil, 15, 16, 1, 2, 3, 5, 7, 9,
|
|
111
|
+
10 ]
|
|
112
|
+
|
|
113
|
+
racc_token_table = {
|
|
114
|
+
false => 0,
|
|
115
|
+
Object.new => 1,
|
|
116
|
+
:IDENT => 2,
|
|
117
|
+
:NUMBER => 3,
|
|
118
|
+
"(" => 4,
|
|
119
|
+
")" => 5,
|
|
120
|
+
"+" => 6,
|
|
121
|
+
"-" => 7,
|
|
122
|
+
"~" => 8,
|
|
123
|
+
:MULT2 => 9,
|
|
124
|
+
"*" => 10,
|
|
125
|
+
"/" => 11,
|
|
126
|
+
"%" => 12,
|
|
127
|
+
:LSHIFT => 13,
|
|
128
|
+
:RSHIFT => 14,
|
|
129
|
+
"&" => 15,
|
|
130
|
+
"|" => 16,
|
|
131
|
+
"^" => 17 }
|
|
132
|
+
|
|
133
|
+
racc_use_result_var = true
|
|
134
|
+
|
|
135
|
+
racc_nt_base = 18
|
|
136
|
+
|
|
137
|
+
Racc_arg = [
|
|
138
|
+
racc_action_table,
|
|
139
|
+
racc_action_check,
|
|
140
|
+
racc_action_default,
|
|
141
|
+
racc_action_pointer,
|
|
142
|
+
racc_goto_table,
|
|
143
|
+
racc_goto_check,
|
|
144
|
+
racc_goto_default,
|
|
145
|
+
racc_goto_pointer,
|
|
146
|
+
racc_nt_base,
|
|
147
|
+
racc_reduce_table,
|
|
148
|
+
racc_token_table,
|
|
149
|
+
racc_shift_n,
|
|
150
|
+
racc_reduce_n,
|
|
151
|
+
racc_use_result_var ]
|
|
152
|
+
|
|
153
|
+
Racc_token_to_s_table = [
|
|
154
|
+
'$end',
|
|
155
|
+
'error',
|
|
156
|
+
'IDENT',
|
|
157
|
+
'NUMBER',
|
|
158
|
+
'"("',
|
|
159
|
+
'")"',
|
|
160
|
+
'"+"',
|
|
161
|
+
'"-"',
|
|
162
|
+
'"~"',
|
|
163
|
+
'MULT2',
|
|
164
|
+
'"*"',
|
|
165
|
+
'"/"',
|
|
166
|
+
'"%"',
|
|
167
|
+
'LSHIFT',
|
|
168
|
+
'RSHIFT',
|
|
169
|
+
'"&"',
|
|
170
|
+
'"|"',
|
|
171
|
+
'"^"',
|
|
172
|
+
'$start',
|
|
173
|
+
'exp',
|
|
174
|
+
'bitwise_or',
|
|
175
|
+
'literal',
|
|
176
|
+
'primary',
|
|
177
|
+
'unary',
|
|
178
|
+
'exponent',
|
|
179
|
+
'multiplicative',
|
|
180
|
+
'additive',
|
|
181
|
+
'shift',
|
|
182
|
+
'bitwise_and']
|
|
183
|
+
|
|
184
|
+
Racc_debug_parser = false
|
|
185
|
+
|
|
186
|
+
##### racc system variables end #####
|
|
187
|
+
|
|
188
|
+
# reduce 0 omitted
|
|
189
|
+
|
|
190
|
+
# reduce 1 omitted
|
|
191
|
+
|
|
192
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 5
|
|
193
|
+
def _reduce_2( val, _values, result )
|
|
194
|
+
result = [:resolve, val.first]
|
|
195
|
+
result
|
|
196
|
+
end
|
|
197
|
+
.,.,
|
|
198
|
+
|
|
199
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 6
|
|
200
|
+
def _reduce_3( val, _values, result )
|
|
201
|
+
result = [:lit, val.first]
|
|
202
|
+
result
|
|
203
|
+
end
|
|
204
|
+
.,.,
|
|
205
|
+
|
|
206
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 8
|
|
207
|
+
def _reduce_4( val, _values, result )
|
|
208
|
+
result = val[1]
|
|
209
|
+
result
|
|
210
|
+
end
|
|
211
|
+
.,.,
|
|
212
|
+
|
|
213
|
+
# reduce 5 omitted
|
|
214
|
+
|
|
215
|
+
# reduce 6 omitted
|
|
216
|
+
|
|
217
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 12
|
|
218
|
+
def _reduce_7( val, _values, result )
|
|
219
|
+
result = [:unary_plus, val[1]]
|
|
220
|
+
result
|
|
221
|
+
end
|
|
222
|
+
.,.,
|
|
223
|
+
|
|
224
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 13
|
|
225
|
+
def _reduce_8( val, _values, result )
|
|
226
|
+
result = [:unary_minus, val[1]]
|
|
227
|
+
result
|
|
228
|
+
end
|
|
229
|
+
.,.,
|
|
230
|
+
|
|
231
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 14
|
|
232
|
+
def _reduce_9( val, _values, result )
|
|
233
|
+
result = [:bitwise_not, val[1]]
|
|
234
|
+
result
|
|
235
|
+
end
|
|
236
|
+
.,.,
|
|
237
|
+
|
|
238
|
+
# reduce 10 omitted
|
|
239
|
+
|
|
240
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 17
|
|
241
|
+
def _reduce_11( val, _values, result )
|
|
242
|
+
result = [:exponent, val[0], val[2]]
|
|
243
|
+
result
|
|
244
|
+
end
|
|
245
|
+
.,.,
|
|
246
|
+
|
|
247
|
+
# reduce 12 omitted
|
|
248
|
+
|
|
249
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 20
|
|
250
|
+
def _reduce_13( val, _values, result )
|
|
251
|
+
result = [:multiply, val[0], val[2]]
|
|
252
|
+
result
|
|
253
|
+
end
|
|
254
|
+
.,.,
|
|
255
|
+
|
|
256
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 21
|
|
257
|
+
def _reduce_14( val, _values, result )
|
|
258
|
+
result = [:divide, val[0], val[2]]
|
|
259
|
+
result
|
|
260
|
+
end
|
|
261
|
+
.,.,
|
|
262
|
+
|
|
263
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 22
|
|
264
|
+
def _reduce_15( val, _values, result )
|
|
265
|
+
result = [:modulus, val[0], val[2]]
|
|
266
|
+
result
|
|
267
|
+
end
|
|
268
|
+
.,.,
|
|
269
|
+
|
|
270
|
+
# reduce 16 omitted
|
|
271
|
+
|
|
272
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 25
|
|
273
|
+
def _reduce_17( val, _values, result )
|
|
274
|
+
result = [:add, val[0], val[2]]
|
|
275
|
+
result
|
|
276
|
+
end
|
|
277
|
+
.,.,
|
|
278
|
+
|
|
279
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 26
|
|
280
|
+
def _reduce_18( val, _values, result )
|
|
281
|
+
result = [:subtract, val[0], val[2]]
|
|
282
|
+
result
|
|
283
|
+
end
|
|
284
|
+
.,.,
|
|
285
|
+
|
|
286
|
+
# reduce 19 omitted
|
|
287
|
+
|
|
288
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 29
|
|
289
|
+
def _reduce_20( val, _values, result )
|
|
290
|
+
result = [:lshift, val[0], val[2]]
|
|
291
|
+
result
|
|
292
|
+
end
|
|
293
|
+
.,.,
|
|
294
|
+
|
|
295
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 30
|
|
296
|
+
def _reduce_21( val, _values, result )
|
|
297
|
+
result = [:rshift, val[0], val[2]]
|
|
298
|
+
result
|
|
299
|
+
end
|
|
300
|
+
.,.,
|
|
301
|
+
|
|
302
|
+
# reduce 22 omitted
|
|
303
|
+
|
|
304
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 33
|
|
305
|
+
def _reduce_23( val, _values, result )
|
|
306
|
+
result = [:bitwise_and, val[0], val[2]]
|
|
307
|
+
result
|
|
308
|
+
end
|
|
309
|
+
.,.,
|
|
310
|
+
|
|
311
|
+
# reduce 24 omitted
|
|
312
|
+
|
|
313
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 36
|
|
314
|
+
def _reduce_25( val, _values, result )
|
|
315
|
+
result = [:bitwise_or, val[0], val[2]]
|
|
316
|
+
result
|
|
317
|
+
end
|
|
318
|
+
.,.,
|
|
319
|
+
|
|
320
|
+
module_eval <<'.,.,', 'lib/einstein/parser.racc', 37
|
|
321
|
+
def _reduce_26( val, _values, result )
|
|
322
|
+
result = [:bitwise_xor, val[0], val[2]]
|
|
323
|
+
result
|
|
324
|
+
end
|
|
325
|
+
.,.,
|
|
326
|
+
|
|
327
|
+
def _reduce_none( val, _values, result )
|
|
328
|
+
result
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
end # class Parser
|
|
332
|
+
|
|
333
|
+
end # module Einstein
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
class Einstein::Parser
|
|
2
|
+
|
|
3
|
+
macro
|
|
4
|
+
|
|
5
|
+
# whitespace
|
|
6
|
+
WS \s+
|
|
7
|
+
|
|
8
|
+
# numerics
|
|
9
|
+
BINARY 0[bB][01]+
|
|
10
|
+
HEXADECIMAL 0[xX][0-9a-fA-F]+
|
|
11
|
+
OCTAL 0[0-9]+
|
|
12
|
+
INTEGER [1-9][0-9]*
|
|
13
|
+
FLOAT [0-9]+\.[0-9]+([eE][\-\+][0-9]+)?
|
|
14
|
+
|
|
15
|
+
# tokens
|
|
16
|
+
EXPONENT \*{2}
|
|
17
|
+
LSHIFT <<
|
|
18
|
+
RSHIFT >>
|
|
19
|
+
|
|
20
|
+
# variables
|
|
21
|
+
IDENT [a-zA-Z_]+
|
|
22
|
+
|
|
23
|
+
rule
|
|
24
|
+
|
|
25
|
+
# whitespace (ignored)
|
|
26
|
+
{WS}
|
|
27
|
+
|
|
28
|
+
# literals
|
|
29
|
+
{BINARY} { [:NUMBER, text.to_i(2)] }
|
|
30
|
+
{HEXADECIMAL} { [:NUMBER, text.hex] }
|
|
31
|
+
{OCTAL} { [:NUMBER, text.oct] }
|
|
32
|
+
{FLOAT} { [:NUMBER, text.to_f] }
|
|
33
|
+
{INTEGER} { [:NUMBER, text.to_i] }
|
|
34
|
+
{IDENT} { [:IDENT, text] }
|
|
35
|
+
|
|
36
|
+
# tokens
|
|
37
|
+
{EXPONENT} { [:MULT2, text] }
|
|
38
|
+
{LSHIFT} { [:LSHIFT, text] }
|
|
39
|
+
{RSHIFT} { [:RSHIFT, text] }
|
|
40
|
+
|
|
41
|
+
# passthru
|
|
42
|
+
.|\n { [text, text] }
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#
|
|
2
|
+
# DO NOT MODIFY!!!!
|
|
3
|
+
# This file is automatically generated by rex 1.0.0
|
|
4
|
+
# from lexical definition file "lib/einstein/parser.rex".
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
require 'racc/parser'
|
|
8
|
+
module Einstein
|
|
9
|
+
class Parser < Racc::Parser
|
|
10
|
+
require 'strscan'
|
|
11
|
+
|
|
12
|
+
class ScanError < StandardError ; end
|
|
13
|
+
|
|
14
|
+
attr_reader :lineno
|
|
15
|
+
attr_reader :filename
|
|
16
|
+
|
|
17
|
+
def scan_setup ; end
|
|
18
|
+
|
|
19
|
+
def action &block
|
|
20
|
+
yield
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def scan_str( str )
|
|
24
|
+
scan_evaluate str
|
|
25
|
+
do_parse
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def load_file( filename )
|
|
29
|
+
@filename = filename
|
|
30
|
+
open(filename, "r") do |f|
|
|
31
|
+
scan_evaluate f.read
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def scan_file( filename )
|
|
36
|
+
load_file filename
|
|
37
|
+
do_parse
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def next_token
|
|
41
|
+
@rex_tokens.shift
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def scan_evaluate( str )
|
|
45
|
+
scan_setup
|
|
46
|
+
@rex_tokens = []
|
|
47
|
+
@lineno = 1
|
|
48
|
+
ss = StringScanner.new(str)
|
|
49
|
+
state = nil
|
|
50
|
+
until ss.eos?
|
|
51
|
+
text = ss.peek(1)
|
|
52
|
+
@lineno += 1 if text == "\n"
|
|
53
|
+
case state
|
|
54
|
+
when nil
|
|
55
|
+
case
|
|
56
|
+
when (text = ss.scan(/\s+/))
|
|
57
|
+
;
|
|
58
|
+
|
|
59
|
+
when (text = ss.scan(/0[bB][01]+/))
|
|
60
|
+
@rex_tokens.push action { [:NUMBER, text.to_i(2)] }
|
|
61
|
+
|
|
62
|
+
when (text = ss.scan(/0[xX][0-9a-fA-F]+/))
|
|
63
|
+
@rex_tokens.push action { [:NUMBER, text.hex] }
|
|
64
|
+
|
|
65
|
+
when (text = ss.scan(/0[0-9]+/))
|
|
66
|
+
@rex_tokens.push action { [:NUMBER, text.oct] }
|
|
67
|
+
|
|
68
|
+
when (text = ss.scan(/[0-9]+\.[0-9]+([eE][\-\+][0-9]+)?/))
|
|
69
|
+
@rex_tokens.push action { [:NUMBER, text.to_f] }
|
|
70
|
+
|
|
71
|
+
when (text = ss.scan(/[1-9][0-9]*/))
|
|
72
|
+
@rex_tokens.push action { [:NUMBER, text.to_i] }
|
|
73
|
+
|
|
74
|
+
when (text = ss.scan(/[a-zA-Z_]+/))
|
|
75
|
+
@rex_tokens.push action { [:IDENT, text] }
|
|
76
|
+
|
|
77
|
+
when (text = ss.scan(/\*{2}/))
|
|
78
|
+
@rex_tokens.push action { [:MULT2, text] }
|
|
79
|
+
|
|
80
|
+
when (text = ss.scan(/<</))
|
|
81
|
+
@rex_tokens.push action { [:LSHIFT, text] }
|
|
82
|
+
|
|
83
|
+
when (text = ss.scan(/>>/))
|
|
84
|
+
@rex_tokens.push action { [:RSHIFT, text] }
|
|
85
|
+
|
|
86
|
+
when (text = ss.scan(/.|\n/))
|
|
87
|
+
@rex_tokens.push action { [text, text] }
|
|
88
|
+
|
|
89
|
+
else
|
|
90
|
+
text = ss.string[ss.pos .. -1]
|
|
91
|
+
raise ScanError, "can not match: '" + text + "'"
|
|
92
|
+
end # if
|
|
93
|
+
|
|
94
|
+
else
|
|
95
|
+
raise ScanError, "undefined state: '" + state.to_s + "'"
|
|
96
|
+
end # case state
|
|
97
|
+
end # until ss
|
|
98
|
+
end # def scan_evaluate
|
|
99
|
+
|
|
100
|
+
end # class
|
|
101
|
+
end # module
|