tp_plus 0.0.73 → 0.0.74
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 +4 -4
- data/README.md +74 -65
- data/Rakefile +35 -21
- data/bin/tpp +73 -73
- data/lib/tp_plus/interpreter.rb +152 -129
- data/lib/tp_plus/namespace.rb +66 -66
- data/lib/tp_plus/nodes/abort_node.rb +9 -9
- data/lib/tp_plus/nodes/address_node.rb +22 -0
- data/lib/tp_plus/nodes/argument_node.rb +20 -19
- data/lib/tp_plus/nodes/assignment_node.rb +45 -45
- data/lib/tp_plus/nodes/call_node.rb +34 -34
- data/lib/tp_plus/nodes/case_condition_node.rb +26 -26
- data/lib/tp_plus/nodes/case_node.rb +33 -33
- data/lib/tp_plus/nodes/comment_node.rb +22 -22
- data/lib/tp_plus/nodes/conditional_node.rb +60 -54
- data/lib/tp_plus/nodes/definition_node.rb +22 -22
- data/lib/tp_plus/nodes/digit_node.rb +22 -21
- data/lib/tp_plus/nodes/empty_stmt_node.rb +9 -0
- data/lib/tp_plus/nodes/eval_node.rb +13 -13
- data/lib/tp_plus/nodes/expression_node.rb +68 -65
- data/lib/tp_plus/nodes/for_node.rb +20 -20
- data/lib/tp_plus/nodes/header_node.rb +27 -27
- data/lib/tp_plus/nodes/indirect_node.rb +51 -49
- data/lib/tp_plus/nodes/inline_conditional_node.rb +40 -40
- data/lib/tp_plus/nodes/io_method_node.rb +55 -55
- data/lib/tp_plus/nodes/io_node.rb +31 -30
- data/lib/tp_plus/nodes/jump_node.rb +23 -23
- data/lib/tp_plus/nodes/label_definition_node.rb +21 -21
- data/lib/tp_plus/nodes/motion_node.rb +62 -62
- data/lib/tp_plus/nodes/namespace_node.rb +16 -16
- data/lib/tp_plus/nodes/namespaced_var_node.rb +38 -38
- data/lib/tp_plus/nodes/numreg_node.rb +26 -25
- data/lib/tp_plus/nodes/offset_node.rb +27 -27
- data/lib/tp_plus/nodes/operator_node.rb +78 -72
- data/lib/tp_plus/nodes/paren_expression_node.rb +17 -0
- data/lib/tp_plus/nodes/pause_node.rb +9 -9
- data/lib/tp_plus/nodes/position_data_node.rb +64 -50
- data/lib/tp_plus/nodes/position_node.rb +26 -25
- data/lib/tp_plus/nodes/posreg_node.rb +64 -48
- data/lib/tp_plus/nodes/raise_node.rb +13 -13
- data/lib/tp_plus/nodes/real_node.rb +27 -27
- data/lib/tp_plus/nodes/set_skip_node.rb +14 -0
- data/lib/tp_plus/nodes/skip_node.rb +22 -22
- data/lib/tp_plus/nodes/speed_node.rb +29 -29
- data/lib/tp_plus/nodes/string_node.rb +13 -13
- data/lib/tp_plus/nodes/string_register_node.rb +26 -25
- data/lib/tp_plus/nodes/termination_node.rb +23 -18
- data/lib/tp_plus/nodes/terminator_node.rb +16 -16
- data/lib/tp_plus/nodes/time_node.rb +24 -24
- data/lib/tp_plus/nodes/timer_method_node.rb +37 -37
- data/lib/tp_plus/nodes/timer_node.rb +16 -21
- data/lib/tp_plus/nodes/units_node.rb +20 -20
- data/lib/tp_plus/nodes/use_node.rb +21 -21
- data/lib/tp_plus/nodes/user_alarm_node.rb +16 -15
- data/lib/tp_plus/nodes/var_method_node.rb +23 -23
- data/lib/tp_plus/nodes/var_node.rb +39 -39
- data/lib/tp_plus/nodes/vision_register_node.rb +22 -21
- data/lib/tp_plus/nodes/wait_for_node.rb +54 -54
- data/lib/tp_plus/nodes/wait_until_node.rb +65 -65
- data/lib/tp_plus/nodes/while_node.rb +42 -36
- data/lib/tp_plus/parser.rb +1682 -1592
- data/lib/tp_plus/scanner.rb +283 -383
- data/lib/tp_plus/token.rb +97 -0
- data/lib/tp_plus/version.rb +3 -3
- data/lib/tp_plus.rb +66 -62
- data/test/test_helper.rb +5 -5
- data/test/tp_plus/test_interpreter.rb +1309 -1168
- data/test/tp_plus/test_parser.rb +496 -489
- data/test/tp_plus/test_scanner.rb +577 -522
- data/tp_plus.gemspec +31 -28
- metadata +61 -14
- data/lib/tp_plus/nodes/set_node.rb +0 -22
data/lib/tp_plus/scanner.rb
CHANGED
@@ -1,383 +1,283 @@
|
|
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
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
when (text = @ss.scan(/\btimeout_to\b/i))
|
286
|
-
action { [:TIMEOUT, text] }
|
287
|
-
|
288
|
-
when (text = @ss.scan(/\btoggle\b/i))
|
289
|
-
action { [:IO_METHOD, text] }
|
290
|
-
|
291
|
-
when (text = @ss.scan(/\btool_offset\b/i))
|
292
|
-
action { [:OFFSET, text] }
|
293
|
-
|
294
|
-
when (text = @ss.scan(/\bturn_on|turn_off\b/i))
|
295
|
-
action { [:IO_METHOD, text] }
|
296
|
-
|
297
|
-
when (text = @ss.scan(/\bto\b/i))
|
298
|
-
action { [:TO, text] }
|
299
|
-
|
300
|
-
when (text = @ss.scan(/\bunless\b/i))
|
301
|
-
action { [:UNLESS, text] }
|
302
|
-
|
303
|
-
when (text = @ss.scan(/\bvision_offset\b/i))
|
304
|
-
action { [:OFFSET, text] }
|
305
|
-
|
306
|
-
when (text = @ss.scan(/\bwait_for\b/i))
|
307
|
-
action { [:WAIT_FOR, text] }
|
308
|
-
|
309
|
-
when (text = @ss.scan(/\bwait_until\b/i))
|
310
|
-
action { [:WAIT_UNTIL, text] }
|
311
|
-
|
312
|
-
when (text = @ss.scan(/\bwhen\b/i))
|
313
|
-
action { [:WHEN, text] }
|
314
|
-
|
315
|
-
when (text = @ss.scan(/\bwhile\b/i))
|
316
|
-
action { [:WHILE, text] }
|
317
|
-
|
318
|
-
when (text = @ss.scan(/\r?\n/i))
|
319
|
-
action { [:NEWLINE, text] }
|
320
|
-
|
321
|
-
when (text = @ss.scan(/;/i))
|
322
|
-
action { [:SEMICOLON, text] }
|
323
|
-
|
324
|
-
when (text = @ss.scan(/\d+\.\d+|\.\d+/i))
|
325
|
-
action { [:REAL, text.to_f] }
|
326
|
-
|
327
|
-
when (text = @ss.scan(/\./i))
|
328
|
-
action { [:DOT, text] }
|
329
|
-
|
330
|
-
when (text = @ss.scan(/\d+/i))
|
331
|
-
action { [:DIGIT, text.to_i] }
|
332
|
-
|
333
|
-
when (text = @ss.scan(/\!/i))
|
334
|
-
action { [:BANG, text] }
|
335
|
-
|
336
|
-
when (text = @ss.scan(/\s+/i))
|
337
|
-
;
|
338
|
-
|
339
|
-
when (text = @ss.scan(/[\w\?\!_]+/i))
|
340
|
-
action { [:WORD, text] }
|
341
|
-
|
342
|
-
when (text = @ss.scan(/"([^\n\r\f"]|\n|\r\n|\r|\f|[^\0-\177]|\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f])*"|'([^\n\r\f']|\n|\r\n|\r|\f|[^\0-\177]|\\[0-9A-Fa-f]{1,6}(\r\n|[\s])?|\\[^\n\r\f0-9A-Fa-f])*'/i))
|
343
|
-
action { [:STRING, text[1,text.length-2]] }
|
344
|
-
|
345
|
-
when (text = @ss.scan(/./i))
|
346
|
-
action { [text, text] }
|
347
|
-
|
348
|
-
else
|
349
|
-
text = @ss.string[@ss.pos .. -1]
|
350
|
-
raise ScanError, "can not match: '" + text + "'"
|
351
|
-
end # if
|
352
|
-
|
353
|
-
when :LABEL
|
354
|
-
case
|
355
|
-
when (text = @ss.scan(/[\w_0-9]+\b/i))
|
356
|
-
action { @state = nil; [:WORD, text] }
|
357
|
-
|
358
|
-
else
|
359
|
-
text = @ss.string[@ss.pos .. -1]
|
360
|
-
raise ScanError, "can not match: '" + text + "'"
|
361
|
-
end # if
|
362
|
-
|
363
|
-
else
|
364
|
-
raise ScanError, "undefined state: '" + state.to_s + "'"
|
365
|
-
end # case state
|
366
|
-
token
|
367
|
-
end # def _next_token
|
368
|
-
|
369
|
-
end # class
|
370
|
-
|
371
|
-
if __FILE__ == $0
|
372
|
-
exit if ARGV.size != 1
|
373
|
-
filename = ARGV.shift
|
374
|
-
rex = TPPlus::Scanner.new
|
375
|
-
begin
|
376
|
-
rex.load_file filename
|
377
|
-
while token = rex.next_token
|
378
|
-
p token
|
379
|
-
end
|
380
|
-
rescue
|
381
|
-
$stderr.printf "%s:%d:%s\n", rex.filename, rex.lineno, $!.message
|
382
|
-
end
|
383
|
-
end
|
1
|
+
module TPPlus
|
2
|
+
class Scanner
|
3
|
+
def initialize
|
4
|
+
end
|
5
|
+
|
6
|
+
def scan_setup(src)
|
7
|
+
@src = src
|
8
|
+
@lineno = 1
|
9
|
+
@ch = " "
|
10
|
+
@offset = 0
|
11
|
+
@rdOffset = 0
|
12
|
+
@prevDot = false # for groups
|
13
|
+
self.next
|
14
|
+
end
|
15
|
+
|
16
|
+
def next
|
17
|
+
if @rdOffset < @src.length
|
18
|
+
@offset = @rdOffset
|
19
|
+
@ch = @src[@rdOffset]
|
20
|
+
if @ch == "\n"
|
21
|
+
@lineno += 1
|
22
|
+
end
|
23
|
+
@rdOffset += 1
|
24
|
+
else
|
25
|
+
@offset = @src.length
|
26
|
+
@ch = -1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def isDigit?(ch)
|
31
|
+
return false if ch == -1
|
32
|
+
|
33
|
+
case ch
|
34
|
+
when '0','1','2','3','4','5','6','7','8','9'
|
35
|
+
return true
|
36
|
+
else
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def isLetter?(ch)
|
42
|
+
return false if ch == -1
|
43
|
+
|
44
|
+
case ch
|
45
|
+
when 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
|
46
|
+
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
|
47
|
+
'_'
|
48
|
+
return true
|
49
|
+
else
|
50
|
+
return false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def skipWhitespace
|
55
|
+
while @ch == ' ' || @ch == "\t" || @ch == "\r"
|
56
|
+
self.next
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def scanIdentifier
|
61
|
+
offs = @offset
|
62
|
+
while isLetter?(@ch) || isDigit?(@ch)
|
63
|
+
self.next
|
64
|
+
end
|
65
|
+
|
66
|
+
# allow one ? or ! at end
|
67
|
+
if @ch == '?' || @ch == '!'
|
68
|
+
self.next
|
69
|
+
end
|
70
|
+
|
71
|
+
return @src[offs,(@offset-offs)]
|
72
|
+
end
|
73
|
+
|
74
|
+
def scanReal
|
75
|
+
offs = @offset-1
|
76
|
+
while self.isDigit?(@ch)
|
77
|
+
self.next
|
78
|
+
end
|
79
|
+
|
80
|
+
return [:REAL, @src[offs,(@offset-offs)].to_f]
|
81
|
+
end
|
82
|
+
|
83
|
+
def scanNumber
|
84
|
+
offs = @offset
|
85
|
+
while self.isDigit?(@ch)
|
86
|
+
self.next
|
87
|
+
end
|
88
|
+
if @ch == '.'
|
89
|
+
self.next
|
90
|
+
while self.isDigit?(@ch)
|
91
|
+
self.next
|
92
|
+
end
|
93
|
+
|
94
|
+
return [:REAL, @src[offs,(@offset-offs)].to_f]
|
95
|
+
else
|
96
|
+
return [:DIGIT, @src[offs,(@offset-offs)].to_i]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def scanComment
|
101
|
+
offs = @offset-1 # opening # already consumed
|
102
|
+
while @ch != "\n" && @ch != -1
|
103
|
+
self.next
|
104
|
+
end
|
105
|
+
|
106
|
+
return @src[offs,(@offset-offs)]
|
107
|
+
end
|
108
|
+
|
109
|
+
def scanString(type)
|
110
|
+
offs = @offset
|
111
|
+
while @ch != type && @ch != -1
|
112
|
+
self.next
|
113
|
+
end
|
114
|
+
|
115
|
+
# consume close
|
116
|
+
self.next
|
117
|
+
|
118
|
+
return @src[offs, (@offset-offs-1)] # -1 to remove trailing " or '
|
119
|
+
end
|
120
|
+
|
121
|
+
def scanLabel
|
122
|
+
offs = @offset
|
123
|
+
while self.isLetter?(@ch)
|
124
|
+
self.next
|
125
|
+
end
|
126
|
+
|
127
|
+
return @src[offs, (@offset-offs)]
|
128
|
+
end
|
129
|
+
|
130
|
+
# return token
|
131
|
+
def next_token
|
132
|
+
self.skipWhitespace
|
133
|
+
|
134
|
+
tok = nil
|
135
|
+
lit = ""
|
136
|
+
ch = @ch
|
137
|
+
|
138
|
+
if isLetter?(ch)
|
139
|
+
lit = self.scanIdentifier
|
140
|
+
if @ch == '['
|
141
|
+
tok = TPPlus::Token.lookup_data(lit)
|
142
|
+
elsif lit == "DIV"
|
143
|
+
tok = :DIV
|
144
|
+
else
|
145
|
+
# keywords are longer than 1 char, avoid lookup otherwise
|
146
|
+
if lit.length > 1
|
147
|
+
if @prevDot
|
148
|
+
case lit
|
149
|
+
when "gp1","gp2","gp3","gp4","gp5"
|
150
|
+
tok = :GROUP
|
151
|
+
else
|
152
|
+
tok = TPPlus::Token.lookup(lit)
|
153
|
+
end
|
154
|
+
else
|
155
|
+
tok = TPPlus::Token.lookup(lit)
|
156
|
+
end
|
157
|
+
else
|
158
|
+
tok = :WORD
|
159
|
+
end
|
160
|
+
end
|
161
|
+
elsif isDigit?(ch)
|
162
|
+
tok, lit = self.scanNumber
|
163
|
+
else
|
164
|
+
self.next # always make progress
|
165
|
+
case ch
|
166
|
+
when -1
|
167
|
+
return nil
|
168
|
+
when '='
|
169
|
+
if @ch == '='
|
170
|
+
tok = :EEQUAL
|
171
|
+
self.next
|
172
|
+
else
|
173
|
+
tok = :EQUAL
|
174
|
+
end
|
175
|
+
when ':'
|
176
|
+
if @ch == "="
|
177
|
+
tok = :ASSIGN
|
178
|
+
self.next
|
179
|
+
else
|
180
|
+
tok = :COLON
|
181
|
+
end
|
182
|
+
when "<"
|
183
|
+
if @ch == "="
|
184
|
+
tok = :LTE
|
185
|
+
self.next
|
186
|
+
elsif @ch == ">"
|
187
|
+
tok = :NOTEQUAL
|
188
|
+
self.next
|
189
|
+
else
|
190
|
+
tok = :LT
|
191
|
+
end
|
192
|
+
when ">"
|
193
|
+
if @ch == "="
|
194
|
+
tok = :GTE
|
195
|
+
self.next
|
196
|
+
else
|
197
|
+
tok = :GT
|
198
|
+
end
|
199
|
+
when "+"
|
200
|
+
tok = :PLUS
|
201
|
+
when "-"
|
202
|
+
tok = :MINUS
|
203
|
+
when "*"
|
204
|
+
tok = :STAR
|
205
|
+
when "/"
|
206
|
+
tok = :SLASH
|
207
|
+
when "&"
|
208
|
+
if @ch == "&"
|
209
|
+
tok = :AND
|
210
|
+
self.next
|
211
|
+
elsif isLetter?(@ch)
|
212
|
+
tok = :ADDRESS
|
213
|
+
lit = self.scanIdentifier
|
214
|
+
else
|
215
|
+
tok = :ILLEGAL
|
216
|
+
end
|
217
|
+
when "|"
|
218
|
+
if @ch == "|"
|
219
|
+
tok = :OR
|
220
|
+
self.next
|
221
|
+
else
|
222
|
+
tok = :ILLEGAL
|
223
|
+
end
|
224
|
+
when "%"
|
225
|
+
tok = :MOD
|
226
|
+
when ";"
|
227
|
+
tok = :SEMICOLON
|
228
|
+
when "."
|
229
|
+
if self.isDigit?(@ch)
|
230
|
+
tok, lit = self.scanReal
|
231
|
+
else
|
232
|
+
tok = :DOT
|
233
|
+
end
|
234
|
+
when "!"
|
235
|
+
if @ch == "="
|
236
|
+
tok = :NOTEQUAL
|
237
|
+
self.next
|
238
|
+
else
|
239
|
+
tok = :BANG
|
240
|
+
end
|
241
|
+
when "\"", "'"
|
242
|
+
tok = :STRING
|
243
|
+
lit = self.scanString(ch)
|
244
|
+
when "#"
|
245
|
+
tok = :COMMENT
|
246
|
+
lit = self.scanComment
|
247
|
+
when "@"
|
248
|
+
tok = :LABEL
|
249
|
+
lit = self.scanLabel
|
250
|
+
when '('
|
251
|
+
tok = :LPAREN
|
252
|
+
when ')'
|
253
|
+
tok = :RPAREN
|
254
|
+
when ','
|
255
|
+
tok = :COMMA
|
256
|
+
when '['
|
257
|
+
tok = :LBRACK
|
258
|
+
when ']'
|
259
|
+
tok = :RBRACK
|
260
|
+
when '{'
|
261
|
+
tok = :LBRACE
|
262
|
+
when '}'
|
263
|
+
tok = :RBRACE
|
264
|
+
when "\n"
|
265
|
+
tok = :NEWLINE
|
266
|
+
else
|
267
|
+
tok = :ILLEGAL
|
268
|
+
lit = ch
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
if tok == :DOT
|
273
|
+
@prevDot = true
|
274
|
+
else
|
275
|
+
@prevDot = false
|
276
|
+
end
|
277
|
+
|
278
|
+
return [tok, lit]
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
class ScanError < StandardError ; end
|
283
|
+
end
|