tp_plus 0.0.87 → 0.0.88
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +87 -87
- data/Rakefile +35 -35
- data/bin/tpp +92 -92
- data/lib/tp_plus/interpreter.rb +153 -152
- data/lib/tp_plus/namespace.rb +66 -66
- data/lib/tp_plus/nodes/abort_node.rb +9 -9
- data/lib/tp_plus/nodes/acc_node.rb +24 -19
- data/lib/tp_plus/nodes/address_node.rb +22 -22
- data/lib/tp_plus/nodes/argument_node.rb +20 -20
- data/lib/tp_plus/nodes/assignment_node.rb +52 -52
- data/lib/tp_plus/nodes/base_node.rb +9 -9
- 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 +18 -18
- data/lib/tp_plus/nodes/conditional_node.rb +60 -60
- data/lib/tp_plus/nodes/definition_node.rb +22 -22
- data/lib/tp_plus/nodes/digit_node.rb +22 -22
- data/lib/tp_plus/nodes/empty_stmt_node.rb +9 -9
- data/lib/tp_plus/nodes/eval_node.rb +13 -13
- data/lib/tp_plus/nodes/expression_node.rb +71 -68
- 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 +27 -27
- data/lib/tp_plus/nodes/inline_conditional_node.rb +36 -36
- data/lib/tp_plus/nodes/io_method_node.rb +55 -55
- data/lib/tp_plus/nodes/io_node.rb +31 -31
- data/lib/tp_plus/nodes/jpos_node.rb +13 -13
- 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/lpos_node.rb +13 -13
- 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 -26
- data/lib/tp_plus/nodes/offset_node.rb +27 -27
- data/lib/tp_plus/nodes/operator_node.rb +78 -80
- data/lib/tp_plus/nodes/paren_expression_node.rb +17 -17
- data/lib/tp_plus/nodes/pause_node.rb +9 -9
- data/lib/tp_plus/nodes/position_data_node.rb +66 -66
- data/lib/tp_plus/nodes/position_node.rb +26 -26
- data/lib/tp_plus/nodes/posreg_node.rb +64 -64
- 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/return_node.rb +9 -9
- data/lib/tp_plus/nodes/set_skip_node.rb +14 -14
- 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 -26
- data/lib/tp_plus/nodes/termination_node.rb +29 -23
- 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 +33 -33
- data/lib/tp_plus/nodes/timer_node.rb +16 -16
- data/lib/tp_plus/nodes/unary_expression_node.rb +40 -39
- 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 -16
- 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 -22
- data/lib/tp_plus/nodes/wait_for_node.rb +57 -50
- data/lib/tp_plus/nodes/wait_until_node.rb +61 -61
- data/lib/tp_plus/nodes/while_node.rb +40 -40
- data/lib/tp_plus/parser.rb +1749 -1749
- data/lib/tp_plus/scanner.rb +295 -295
- data/lib/tp_plus/token.rb +101 -101
- data/lib/tp_plus/version.rb +3 -3
- data/lib/tp_plus.rb +72 -72
- data/test/test_helper.rb +5 -5
- data/test/tp_plus/test_interpreter.rb +1378 -1372
- data/test/tp_plus/test_parser.rb +502 -502
- data/test/tp_plus/test_scanner.rb +591 -591
- data/tp_plus.gemspec +31 -31
- metadata +4 -3
@@ -1,591 +1,591 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
class TestScanner < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@scanner = TPPlus::Scanner.new
|
6
|
-
end
|
7
|
-
|
8
|
-
def assert_tok(token)
|
9
|
-
assert_token(token, nil)
|
10
|
-
end
|
11
|
-
|
12
|
-
def assert_token(token, text)
|
13
|
-
if text
|
14
|
-
assert_equal [token,text], @scanner.next_token
|
15
|
-
else
|
16
|
-
assert_equal token, @scanner.next_token[0]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_blank_string
|
21
|
-
@scanner.scan_setup ""
|
22
|
-
assert_nil @scanner.next_token
|
23
|
-
#assert_tok :EOF
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_ignore_whitespace
|
27
|
-
@scanner.scan_setup " "
|
28
|
-
assert_nil @scanner.next_token
|
29
|
-
#assert_tok :EOF
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_newline
|
33
|
-
@scanner.scan_setup "\n"
|
34
|
-
assert_tok :NEWLINE
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_no_combine_newlines
|
38
|
-
@scanner.scan_setup "\n\n"
|
39
|
-
assert_tok :NEWLINE
|
40
|
-
assert_tok :NEWLINE
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_semicolon
|
44
|
-
@scanner.scan_setup ";"
|
45
|
-
assert_tok :SEMICOLON
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_real_with_dot
|
49
|
-
@scanner.scan_setup "3.14"
|
50
|
-
assert_token :REAL, 3.14
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_real_with_no_lead
|
54
|
-
@scanner.scan_setup ".10"
|
55
|
-
assert_token :REAL, 0.1
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_digit
|
59
|
-
@scanner.scan_setup "42"
|
60
|
-
assert_token :DIGIT, 42
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_label
|
64
|
-
@scanner.scan_setup "@foo"
|
65
|
-
assert_token :LABEL, "foo"
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_true
|
69
|
-
@scanner.scan_setup "true"
|
70
|
-
assert_token :TRUE_FALSE, "true"
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_false
|
74
|
-
@scanner.scan_setup "false"
|
75
|
-
assert_token :TRUE_FALSE, "false"
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_numreg
|
79
|
-
@scanner.scan_setup "R[42]"
|
80
|
-
assert_token :NUMREG, "R"
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_posreg
|
84
|
-
@scanner.scan_setup "PR[42]"
|
85
|
-
assert_token :POSREG, "PR"
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_timer
|
89
|
-
@scanner.scan_setup "TIMER[1]"
|
90
|
-
assert_token :TIMER, "TIMER"
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_position
|
94
|
-
@scanner.scan_setup "P[42]"
|
95
|
-
assert_token :POSITION, "P"
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_vreg
|
99
|
-
@scanner.scan_setup "VR[1]"
|
100
|
-
assert_token :VREG, "VR"
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_sreg
|
104
|
-
@scanner.scan_setup "SR[1]"
|
105
|
-
assert_token :SREG, "SR"
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_flag
|
109
|
-
@scanner.scan_setup "F[1]"
|
110
|
-
assert_token :OUTPUT, "F"
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_di
|
114
|
-
@scanner.scan_setup "DI[1]"
|
115
|
-
assert_token :INPUT, "DI"
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_do
|
119
|
-
@scanner.scan_setup "DO[1]"
|
120
|
-
assert_token :OUTPUT, "DO"
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_ri
|
124
|
-
@scanner.scan_setup "RI[1]"
|
125
|
-
assert_token :INPUT, "RI"
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_ro
|
129
|
-
@scanner.scan_setup "RO[1]"
|
130
|
-
assert_token :OUTPUT, "RO"
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_ui
|
134
|
-
@scanner.scan_setup "UI[1]"
|
135
|
-
assert_token :INPUT, "UI"
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_uo
|
139
|
-
@scanner.scan_setup "UO[1]"
|
140
|
-
assert_token :OUTPUT, "UO"
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_si
|
144
|
-
@scanner.scan_setup "SI[1]"
|
145
|
-
assert_token :INPUT, "SI"
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_so
|
149
|
-
@scanner.scan_setup "SO[1]"
|
150
|
-
assert_token :OUTPUT, "SO"
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_equal
|
154
|
-
@scanner.scan_setup "="
|
155
|
-
assert_tok :EQUAL
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_not_equal
|
159
|
-
@scanner.scan_setup "<>"
|
160
|
-
assert_tok :NOTEQUAL
|
161
|
-
@scanner.scan_setup "!="
|
162
|
-
assert_tok :NOTEQUAL
|
163
|
-
end
|
164
|
-
|
165
|
-
def test_eequal
|
166
|
-
@scanner.scan_setup "=="
|
167
|
-
assert_tok :EEQUAL
|
168
|
-
end
|
169
|
-
|
170
|
-
def test_gte
|
171
|
-
@scanner.scan_setup ">="
|
172
|
-
assert_tok :GTE
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_lte
|
176
|
-
@scanner.scan_setup "<="
|
177
|
-
assert_tok :LTE
|
178
|
-
end
|
179
|
-
|
180
|
-
def test_lt
|
181
|
-
@scanner.scan_setup "<"
|
182
|
-
assert_tok :LT
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_gt
|
186
|
-
@scanner.scan_setup ">"
|
187
|
-
assert_tok :GT
|
188
|
-
end
|
189
|
-
|
190
|
-
def test_plus
|
191
|
-
@scanner.scan_setup "+"
|
192
|
-
assert_tok :PLUS
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_minus
|
196
|
-
@scanner.scan_setup "-"
|
197
|
-
assert_tok :MINUS
|
198
|
-
end
|
199
|
-
|
200
|
-
def test_star
|
201
|
-
@scanner.scan_setup "*"
|
202
|
-
assert_tok :STAR
|
203
|
-
end
|
204
|
-
|
205
|
-
def test_slash
|
206
|
-
@scanner.scan_setup "/"
|
207
|
-
assert_tok :SLASH
|
208
|
-
end
|
209
|
-
|
210
|
-
def test_and
|
211
|
-
@scanner.scan_setup "&&"
|
212
|
-
assert_tok :AND
|
213
|
-
end
|
214
|
-
|
215
|
-
def test_div
|
216
|
-
@scanner.scan_setup "DIV"
|
217
|
-
assert_tok :DIV
|
218
|
-
end
|
219
|
-
|
220
|
-
def test_or
|
221
|
-
@scanner.scan_setup "||"
|
222
|
-
assert_tok :OR
|
223
|
-
end
|
224
|
-
|
225
|
-
def test_mod
|
226
|
-
@scanner.scan_setup "%"
|
227
|
-
assert_tok :MOD
|
228
|
-
end
|
229
|
-
|
230
|
-
def test_comment
|
231
|
-
@scanner.scan_setup "# foo"
|
232
|
-
assert_token :COMMENT, "# foo"
|
233
|
-
end
|
234
|
-
|
235
|
-
def test_assign
|
236
|
-
@scanner.scan_setup ":="
|
237
|
-
assert_tok :ASSIGN
|
238
|
-
assert_nil @scanner.next_token
|
239
|
-
end
|
240
|
-
|
241
|
-
#def test_at_sym
|
242
|
-
# @scanner.scan_setup "@"
|
243
|
-
# assert_token :AT_SYM, "@"
|
244
|
-
#end
|
245
|
-
|
246
|
-
def test_jump_to
|
247
|
-
@scanner.scan_setup "jump_to"
|
248
|
-
assert_token :JUMP, "jump_to"
|
249
|
-
end
|
250
|
-
|
251
|
-
def test_turn_on
|
252
|
-
@scanner.scan_setup "turn_on"
|
253
|
-
assert_token :IO_METHOD, "turn_on"
|
254
|
-
end
|
255
|
-
|
256
|
-
def test_turn_off
|
257
|
-
@scanner.scan_setup "turn_off"
|
258
|
-
assert_token :IO_METHOD, "turn_off"
|
259
|
-
end
|
260
|
-
|
261
|
-
def test_toggle
|
262
|
-
@scanner.scan_setup "toggle"
|
263
|
-
assert_token :IO_METHOD, "toggle"
|
264
|
-
end
|
265
|
-
|
266
|
-
def test_linear_move
|
267
|
-
@scanner.scan_setup "linear_move"
|
268
|
-
assert_token :MOVE, "linear_move"
|
269
|
-
end
|
270
|
-
|
271
|
-
def test_joint_move
|
272
|
-
@scanner.scan_setup "joint_move"
|
273
|
-
assert_token :MOVE, "joint_move"
|
274
|
-
end
|
275
|
-
|
276
|
-
def test_circular_move
|
277
|
-
@scanner.scan_setup "circular_move"
|
278
|
-
assert_token :MOVE, "circular_move"
|
279
|
-
end
|
280
|
-
|
281
|
-
def test_dot
|
282
|
-
@scanner.scan_setup "."
|
283
|
-
assert_tok :DOT
|
284
|
-
end
|
285
|
-
|
286
|
-
def test_to
|
287
|
-
@scanner.scan_setup "to"
|
288
|
-
assert_token :TO, "to"
|
289
|
-
end
|
290
|
-
|
291
|
-
def test_at
|
292
|
-
@scanner.scan_setup "at"
|
293
|
-
assert_token :AT, "at"
|
294
|
-
end
|
295
|
-
|
296
|
-
def test_term
|
297
|
-
@scanner.scan_setup "term"
|
298
|
-
assert_token :TERM, "term"
|
299
|
-
end
|
300
|
-
|
301
|
-
def test_if
|
302
|
-
@scanner.scan_setup "if"
|
303
|
-
assert_token :IF, "if"
|
304
|
-
end
|
305
|
-
|
306
|
-
def test_else
|
307
|
-
@scanner.scan_setup "else"
|
308
|
-
assert_token :ELSE, "else"
|
309
|
-
end
|
310
|
-
|
311
|
-
def test_end
|
312
|
-
@scanner.scan_setup "end"
|
313
|
-
assert_token :END, "end"
|
314
|
-
end
|
315
|
-
|
316
|
-
def test_unless
|
317
|
-
@scanner.scan_setup "unless"
|
318
|
-
assert_token :UNLESS, "unless"
|
319
|
-
end
|
320
|
-
|
321
|
-
def test_carriage_return_newline_as_one
|
322
|
-
@scanner.scan_setup "\r\n"
|
323
|
-
assert_tok :NEWLINE
|
324
|
-
end
|
325
|
-
|
326
|
-
def test_use_uframe
|
327
|
-
@scanner.scan_setup "use_uframe"
|
328
|
-
assert_token :FANUC_USE, "use_uframe"
|
329
|
-
end
|
330
|
-
|
331
|
-
def test_use_utool
|
332
|
-
@scanner.scan_setup "use_utool"
|
333
|
-
assert_token :FANUC_USE, "use_utool"
|
334
|
-
end
|
335
|
-
|
336
|
-
def test_use_payload
|
337
|
-
@scanner.scan_setup "use_payload"
|
338
|
-
assert_token :FANUC_USE, "use_payload"
|
339
|
-
end
|
340
|
-
|
341
|
-
def test_offset
|
342
|
-
@scanner.scan_setup "offset"
|
343
|
-
assert_token :OFFSET, "offset"
|
344
|
-
end
|
345
|
-
|
346
|
-
def test_time_before
|
347
|
-
@scanner.scan_setup "time_before"
|
348
|
-
assert_token :TIME_SEGMENT, "time_before"
|
349
|
-
end
|
350
|
-
|
351
|
-
def test_time_after
|
352
|
-
@scanner.scan_setup "time_after"
|
353
|
-
assert_token :TIME_SEGMENT, "time_after"
|
354
|
-
end
|
355
|
-
|
356
|
-
def test_word_with_end_in_it
|
357
|
-
@scanner.scan_setup "end_zone"
|
358
|
-
assert_token :WORD, "end_zone"
|
359
|
-
end
|
360
|
-
|
361
|
-
def test_scan_wait_for
|
362
|
-
@scanner.scan_setup "wait_for"
|
363
|
-
assert_token :WAIT_FOR, "wait_for"
|
364
|
-
end
|
365
|
-
|
366
|
-
def test_scan_wait_until
|
367
|
-
@scanner.scan_setup "wait_until"
|
368
|
-
assert_token :WAIT_UNTIL, "wait_until"
|
369
|
-
end
|
370
|
-
|
371
|
-
def test_scan_case
|
372
|
-
@scanner.scan_setup "case"
|
373
|
-
assert_token :CASE, "case"
|
374
|
-
end
|
375
|
-
|
376
|
-
def test_scan_when
|
377
|
-
@scanner.scan_setup "when"
|
378
|
-
assert_token :WHEN, "when"
|
379
|
-
end
|
380
|
-
|
381
|
-
def test_scan_argument
|
382
|
-
@scanner.scan_setup "AR[1]"
|
383
|
-
assert_token :ARG, "AR"
|
384
|
-
end
|
385
|
-
|
386
|
-
def test_scan_set_skip_condition
|
387
|
-
@scanner.scan_setup "set_skip_condition"
|
388
|
-
assert_token :SET_SKIP_CONDITION, "set_skip_condition"
|
389
|
-
end
|
390
|
-
|
391
|
-
def test_scan_skip_to
|
392
|
-
@scanner.scan_setup "skip_to"
|
393
|
-
assert_token :SKIP, "skip_to"
|
394
|
-
end
|
395
|
-
|
396
|
-
def test_scans_bang_separate_from_word
|
397
|
-
@scanner.scan_setup "!foo"
|
398
|
-
assert_tok :BANG
|
399
|
-
assert_token :WORD, "foo"
|
400
|
-
end
|
401
|
-
|
402
|
-
def test_timeout_to
|
403
|
-
@scanner.scan_setup "timeout_to"
|
404
|
-
assert_token :TIMEOUT, "timeout_to"
|
405
|
-
end
|
406
|
-
|
407
|
-
def test_after
|
408
|
-
@scanner.scan_setup "after"
|
409
|
-
assert_token :AFTER, "after"
|
410
|
-
end
|
411
|
-
|
412
|
-
def test_scanning_single_quoted_string
|
413
|
-
@scanner.scan_setup "'string'"
|
414
|
-
assert_token :STRING, "string"
|
415
|
-
end
|
416
|
-
|
417
|
-
def test_scanning_double_quoted_string
|
418
|
-
@scanner.scan_setup '"string"'
|
419
|
-
assert_token :STRING, "string"
|
420
|
-
end
|
421
|
-
|
422
|
-
def test_scan_namespace
|
423
|
-
@scanner.scan_setup "namespace"
|
424
|
-
assert_token :NAMESPACE, "namespace"
|
425
|
-
end
|
426
|
-
|
427
|
-
def test_scan_eval
|
428
|
-
@scanner.scan_setup "eval"
|
429
|
-
assert_token :EVAL, "eval"
|
430
|
-
end
|
431
|
-
|
432
|
-
def test_scan_for
|
433
|
-
@scanner.scan_setup "for"
|
434
|
-
assert_token :FOR, "for"
|
435
|
-
end
|
436
|
-
|
437
|
-
def test_scan_in
|
438
|
-
@scanner.scan_setup "in"
|
439
|
-
assert_token :IN, "in"
|
440
|
-
end
|
441
|
-
|
442
|
-
def test_scan_indirect
|
443
|
-
@scanner.scan_setup "indirect"
|
444
|
-
assert_token :INDIRECT, "indirect"
|
445
|
-
end
|
446
|
-
|
447
|
-
def test_scan_while
|
448
|
-
@scanner.scan_setup "while"
|
449
|
-
assert_token :WHILE, "while"
|
450
|
-
end
|
451
|
-
|
452
|
-
def test_start
|
453
|
-
@scanner.scan_setup "start"
|
454
|
-
assert_token :TIMER_METHOD, "start"
|
455
|
-
end
|
456
|
-
|
457
|
-
def test_stop
|
458
|
-
@scanner.scan_setup "stop"
|
459
|
-
assert_token :TIMER_METHOD, "stop"
|
460
|
-
end
|
461
|
-
|
462
|
-
def test_reset
|
463
|
-
@scanner.scan_setup "reset"
|
464
|
-
assert_token :TIMER_METHOD, "reset"
|
465
|
-
end
|
466
|
-
|
467
|
-
def test_restart
|
468
|
-
@scanner.scan_setup "restart"
|
469
|
-
assert_token :TIMER_METHOD, "restart"
|
470
|
-
end
|
471
|
-
|
472
|
-
def test_position_data
|
473
|
-
@scanner.scan_setup "position_data"
|
474
|
-
assert_token :POSITION_DATA, "position_data"
|
475
|
-
end
|
476
|
-
|
477
|
-
def test_pulse
|
478
|
-
@scanner.scan_setup "pulse"
|
479
|
-
assert_token :IO_METHOD, "pulse"
|
480
|
-
end
|
481
|
-
|
482
|
-
def test_scan_ualm
|
483
|
-
@scanner.scan_setup "UALM[1]"
|
484
|
-
assert_token :UALM, "UALM"
|
485
|
-
end
|
486
|
-
|
487
|
-
def test_scan_raise
|
488
|
-
@scanner.scan_setup "raise"
|
489
|
-
assert_token :RAISE, "raise"
|
490
|
-
end
|
491
|
-
|
492
|
-
def test_scan_run
|
493
|
-
@scanner.scan_setup "run"
|
494
|
-
assert_token :RUN, "run"
|
495
|
-
end
|
496
|
-
|
497
|
-
def test_tp_ignore_pause
|
498
|
-
@scanner.scan_setup "TP_IGNORE_PAUSE"
|
499
|
-
assert_token :TP_HEADER, "TP_IGNORE_PAUSE"
|
500
|
-
end
|
501
|
-
|
502
|
-
def test_tp_comment
|
503
|
-
@scanner.scan_setup "TP_COMMENT"
|
504
|
-
assert_token :TP_HEADER, "TP_COMMENT"
|
505
|
-
end
|
506
|
-
|
507
|
-
def test_tp_groupmask
|
508
|
-
@scanner.scan_setup "TP_GROUPMASK"
|
509
|
-
assert_token :TP_HEADER, "TP_GROUPMASK"
|
510
|
-
end
|
511
|
-
|
512
|
-
def test_tp_subtype
|
513
|
-
@scanner.scan_setup "TP_SUBTYPE"
|
514
|
-
assert_token :TP_HEADER, "TP_SUBTYPE"
|
515
|
-
end
|
516
|
-
|
517
|
-
def test_tool_offset
|
518
|
-
@scanner.scan_setup "tool_offset to toff"
|
519
|
-
assert_token :OFFSET, "tool_offset"
|
520
|
-
assert_token :TO, "to"
|
521
|
-
assert_token :WORD, "toff"
|
522
|
-
end
|
523
|
-
|
524
|
-
def test_vision_offset
|
525
|
-
@scanner.scan_setup "vision_offset"
|
526
|
-
assert_token :OFFSET, "vision_offset"
|
527
|
-
end
|
528
|
-
|
529
|
-
def test_pause
|
530
|
-
@scanner.scan_setup "pause"
|
531
|
-
assert_token :PAUSE, "pause"
|
532
|
-
end
|
533
|
-
|
534
|
-
def test_abort
|
535
|
-
@scanner.scan_setup "abort"
|
536
|
-
assert_token :ABORT, "abort"
|
537
|
-
end
|
538
|
-
|
539
|
-
def test_ident
|
540
|
-
@scanner.scan_setup "foo_bar1 foo? foo!"
|
541
|
-
assert_token :WORD, "foo_bar1"
|
542
|
-
assert_token :WORD, "foo?"
|
543
|
-
assert_token :WORD, "foo!"
|
544
|
-
end
|
545
|
-
|
546
|
-
def test_punctuation
|
547
|
-
pairs = [
|
548
|
-
['(', :LPAREN],
|
549
|
-
[')', :RPAREN],
|
550
|
-
['[', :LBRACK],
|
551
|
-
[']', :RBRACK],
|
552
|
-
['{', :LBRACE],
|
553
|
-
['}', :RBRACE],
|
554
|
-
[',', :COMMA],
|
555
|
-
[':', :COLON]
|
556
|
-
]
|
557
|
-
|
558
|
-
pairs.each do |pair|
|
559
|
-
@scanner.scan_setup pair[0]
|
560
|
-
assert_tok pair[1]
|
561
|
-
end
|
562
|
-
end
|
563
|
-
|
564
|
-
def test_address
|
565
|
-
@scanner.scan_setup "&foo"
|
566
|
-
assert_token :ADDRESS, "foo"
|
567
|
-
end
|
568
|
-
|
569
|
-
def test_linear_position
|
570
|
-
@scanner.scan_setup "get_linear_position"
|
571
|
-
assert_token :LPOS, "get_linear_position"
|
572
|
-
end
|
573
|
-
|
574
|
-
def test_joint_position
|
575
|
-
@scanner.scan_setup "get_joint_position"
|
576
|
-
assert_token :JPOS, "get_joint_position"
|
577
|
-
end
|
578
|
-
|
579
|
-
def test_groups
|
580
|
-
@scanner.scan_setup "gp3 foo.gp3"
|
581
|
-
assert_token :WORD, "gp3"
|
582
|
-
assert_token :WORD, "foo"
|
583
|
-
assert_tok :DOT
|
584
|
-
assert_token :GROUP, "gp3"
|
585
|
-
end
|
586
|
-
|
587
|
-
def test_return
|
588
|
-
@scanner.scan_setup "return"
|
589
|
-
assert_token :RETURN, "return"
|
590
|
-
end
|
591
|
-
end
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class TestScanner < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@scanner = TPPlus::Scanner.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def assert_tok(token)
|
9
|
+
assert_token(token, nil)
|
10
|
+
end
|
11
|
+
|
12
|
+
def assert_token(token, text)
|
13
|
+
if text
|
14
|
+
assert_equal [token,text], @scanner.next_token
|
15
|
+
else
|
16
|
+
assert_equal token, @scanner.next_token[0]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_blank_string
|
21
|
+
@scanner.scan_setup ""
|
22
|
+
assert_nil @scanner.next_token
|
23
|
+
#assert_tok :EOF
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_ignore_whitespace
|
27
|
+
@scanner.scan_setup " "
|
28
|
+
assert_nil @scanner.next_token
|
29
|
+
#assert_tok :EOF
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_newline
|
33
|
+
@scanner.scan_setup "\n"
|
34
|
+
assert_tok :NEWLINE
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_no_combine_newlines
|
38
|
+
@scanner.scan_setup "\n\n"
|
39
|
+
assert_tok :NEWLINE
|
40
|
+
assert_tok :NEWLINE
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_semicolon
|
44
|
+
@scanner.scan_setup ";"
|
45
|
+
assert_tok :SEMICOLON
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_real_with_dot
|
49
|
+
@scanner.scan_setup "3.14"
|
50
|
+
assert_token :REAL, 3.14
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_real_with_no_lead
|
54
|
+
@scanner.scan_setup ".10"
|
55
|
+
assert_token :REAL, 0.1
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_digit
|
59
|
+
@scanner.scan_setup "42"
|
60
|
+
assert_token :DIGIT, 42
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_label
|
64
|
+
@scanner.scan_setup "@foo"
|
65
|
+
assert_token :LABEL, "foo"
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_true
|
69
|
+
@scanner.scan_setup "true"
|
70
|
+
assert_token :TRUE_FALSE, "true"
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_false
|
74
|
+
@scanner.scan_setup "false"
|
75
|
+
assert_token :TRUE_FALSE, "false"
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_numreg
|
79
|
+
@scanner.scan_setup "R[42]"
|
80
|
+
assert_token :NUMREG, "R"
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_posreg
|
84
|
+
@scanner.scan_setup "PR[42]"
|
85
|
+
assert_token :POSREG, "PR"
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_timer
|
89
|
+
@scanner.scan_setup "TIMER[1]"
|
90
|
+
assert_token :TIMER, "TIMER"
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_position
|
94
|
+
@scanner.scan_setup "P[42]"
|
95
|
+
assert_token :POSITION, "P"
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_vreg
|
99
|
+
@scanner.scan_setup "VR[1]"
|
100
|
+
assert_token :VREG, "VR"
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_sreg
|
104
|
+
@scanner.scan_setup "SR[1]"
|
105
|
+
assert_token :SREG, "SR"
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_flag
|
109
|
+
@scanner.scan_setup "F[1]"
|
110
|
+
assert_token :OUTPUT, "F"
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_di
|
114
|
+
@scanner.scan_setup "DI[1]"
|
115
|
+
assert_token :INPUT, "DI"
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_do
|
119
|
+
@scanner.scan_setup "DO[1]"
|
120
|
+
assert_token :OUTPUT, "DO"
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_ri
|
124
|
+
@scanner.scan_setup "RI[1]"
|
125
|
+
assert_token :INPUT, "RI"
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_ro
|
129
|
+
@scanner.scan_setup "RO[1]"
|
130
|
+
assert_token :OUTPUT, "RO"
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_ui
|
134
|
+
@scanner.scan_setup "UI[1]"
|
135
|
+
assert_token :INPUT, "UI"
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_uo
|
139
|
+
@scanner.scan_setup "UO[1]"
|
140
|
+
assert_token :OUTPUT, "UO"
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_si
|
144
|
+
@scanner.scan_setup "SI[1]"
|
145
|
+
assert_token :INPUT, "SI"
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_so
|
149
|
+
@scanner.scan_setup "SO[1]"
|
150
|
+
assert_token :OUTPUT, "SO"
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_equal
|
154
|
+
@scanner.scan_setup "="
|
155
|
+
assert_tok :EQUAL
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_not_equal
|
159
|
+
@scanner.scan_setup "<>"
|
160
|
+
assert_tok :NOTEQUAL
|
161
|
+
@scanner.scan_setup "!="
|
162
|
+
assert_tok :NOTEQUAL
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_eequal
|
166
|
+
@scanner.scan_setup "=="
|
167
|
+
assert_tok :EEQUAL
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_gte
|
171
|
+
@scanner.scan_setup ">="
|
172
|
+
assert_tok :GTE
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_lte
|
176
|
+
@scanner.scan_setup "<="
|
177
|
+
assert_tok :LTE
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_lt
|
181
|
+
@scanner.scan_setup "<"
|
182
|
+
assert_tok :LT
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_gt
|
186
|
+
@scanner.scan_setup ">"
|
187
|
+
assert_tok :GT
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_plus
|
191
|
+
@scanner.scan_setup "+"
|
192
|
+
assert_tok :PLUS
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_minus
|
196
|
+
@scanner.scan_setup "-"
|
197
|
+
assert_tok :MINUS
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_star
|
201
|
+
@scanner.scan_setup "*"
|
202
|
+
assert_tok :STAR
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_slash
|
206
|
+
@scanner.scan_setup "/"
|
207
|
+
assert_tok :SLASH
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_and
|
211
|
+
@scanner.scan_setup "&&"
|
212
|
+
assert_tok :AND
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_div
|
216
|
+
@scanner.scan_setup "DIV"
|
217
|
+
assert_tok :DIV
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_or
|
221
|
+
@scanner.scan_setup "||"
|
222
|
+
assert_tok :OR
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_mod
|
226
|
+
@scanner.scan_setup "%"
|
227
|
+
assert_tok :MOD
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_comment
|
231
|
+
@scanner.scan_setup "# foo"
|
232
|
+
assert_token :COMMENT, "# foo"
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_assign
|
236
|
+
@scanner.scan_setup ":="
|
237
|
+
assert_tok :ASSIGN
|
238
|
+
assert_nil @scanner.next_token
|
239
|
+
end
|
240
|
+
|
241
|
+
#def test_at_sym
|
242
|
+
# @scanner.scan_setup "@"
|
243
|
+
# assert_token :AT_SYM, "@"
|
244
|
+
#end
|
245
|
+
|
246
|
+
def test_jump_to
|
247
|
+
@scanner.scan_setup "jump_to"
|
248
|
+
assert_token :JUMP, "jump_to"
|
249
|
+
end
|
250
|
+
|
251
|
+
def test_turn_on
|
252
|
+
@scanner.scan_setup "turn_on"
|
253
|
+
assert_token :IO_METHOD, "turn_on"
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_turn_off
|
257
|
+
@scanner.scan_setup "turn_off"
|
258
|
+
assert_token :IO_METHOD, "turn_off"
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_toggle
|
262
|
+
@scanner.scan_setup "toggle"
|
263
|
+
assert_token :IO_METHOD, "toggle"
|
264
|
+
end
|
265
|
+
|
266
|
+
def test_linear_move
|
267
|
+
@scanner.scan_setup "linear_move"
|
268
|
+
assert_token :MOVE, "linear_move"
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_joint_move
|
272
|
+
@scanner.scan_setup "joint_move"
|
273
|
+
assert_token :MOVE, "joint_move"
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_circular_move
|
277
|
+
@scanner.scan_setup "circular_move"
|
278
|
+
assert_token :MOVE, "circular_move"
|
279
|
+
end
|
280
|
+
|
281
|
+
def test_dot
|
282
|
+
@scanner.scan_setup "."
|
283
|
+
assert_tok :DOT
|
284
|
+
end
|
285
|
+
|
286
|
+
def test_to
|
287
|
+
@scanner.scan_setup "to"
|
288
|
+
assert_token :TO, "to"
|
289
|
+
end
|
290
|
+
|
291
|
+
def test_at
|
292
|
+
@scanner.scan_setup "at"
|
293
|
+
assert_token :AT, "at"
|
294
|
+
end
|
295
|
+
|
296
|
+
def test_term
|
297
|
+
@scanner.scan_setup "term"
|
298
|
+
assert_token :TERM, "term"
|
299
|
+
end
|
300
|
+
|
301
|
+
def test_if
|
302
|
+
@scanner.scan_setup "if"
|
303
|
+
assert_token :IF, "if"
|
304
|
+
end
|
305
|
+
|
306
|
+
def test_else
|
307
|
+
@scanner.scan_setup "else"
|
308
|
+
assert_token :ELSE, "else"
|
309
|
+
end
|
310
|
+
|
311
|
+
def test_end
|
312
|
+
@scanner.scan_setup "end"
|
313
|
+
assert_token :END, "end"
|
314
|
+
end
|
315
|
+
|
316
|
+
def test_unless
|
317
|
+
@scanner.scan_setup "unless"
|
318
|
+
assert_token :UNLESS, "unless"
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_carriage_return_newline_as_one
|
322
|
+
@scanner.scan_setup "\r\n"
|
323
|
+
assert_tok :NEWLINE
|
324
|
+
end
|
325
|
+
|
326
|
+
def test_use_uframe
|
327
|
+
@scanner.scan_setup "use_uframe"
|
328
|
+
assert_token :FANUC_USE, "use_uframe"
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_use_utool
|
332
|
+
@scanner.scan_setup "use_utool"
|
333
|
+
assert_token :FANUC_USE, "use_utool"
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_use_payload
|
337
|
+
@scanner.scan_setup "use_payload"
|
338
|
+
assert_token :FANUC_USE, "use_payload"
|
339
|
+
end
|
340
|
+
|
341
|
+
def test_offset
|
342
|
+
@scanner.scan_setup "offset"
|
343
|
+
assert_token :OFFSET, "offset"
|
344
|
+
end
|
345
|
+
|
346
|
+
def test_time_before
|
347
|
+
@scanner.scan_setup "time_before"
|
348
|
+
assert_token :TIME_SEGMENT, "time_before"
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_time_after
|
352
|
+
@scanner.scan_setup "time_after"
|
353
|
+
assert_token :TIME_SEGMENT, "time_after"
|
354
|
+
end
|
355
|
+
|
356
|
+
def test_word_with_end_in_it
|
357
|
+
@scanner.scan_setup "end_zone"
|
358
|
+
assert_token :WORD, "end_zone"
|
359
|
+
end
|
360
|
+
|
361
|
+
def test_scan_wait_for
|
362
|
+
@scanner.scan_setup "wait_for"
|
363
|
+
assert_token :WAIT_FOR, "wait_for"
|
364
|
+
end
|
365
|
+
|
366
|
+
def test_scan_wait_until
|
367
|
+
@scanner.scan_setup "wait_until"
|
368
|
+
assert_token :WAIT_UNTIL, "wait_until"
|
369
|
+
end
|
370
|
+
|
371
|
+
def test_scan_case
|
372
|
+
@scanner.scan_setup "case"
|
373
|
+
assert_token :CASE, "case"
|
374
|
+
end
|
375
|
+
|
376
|
+
def test_scan_when
|
377
|
+
@scanner.scan_setup "when"
|
378
|
+
assert_token :WHEN, "when"
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_scan_argument
|
382
|
+
@scanner.scan_setup "AR[1]"
|
383
|
+
assert_token :ARG, "AR"
|
384
|
+
end
|
385
|
+
|
386
|
+
def test_scan_set_skip_condition
|
387
|
+
@scanner.scan_setup "set_skip_condition"
|
388
|
+
assert_token :SET_SKIP_CONDITION, "set_skip_condition"
|
389
|
+
end
|
390
|
+
|
391
|
+
def test_scan_skip_to
|
392
|
+
@scanner.scan_setup "skip_to"
|
393
|
+
assert_token :SKIP, "skip_to"
|
394
|
+
end
|
395
|
+
|
396
|
+
def test_scans_bang_separate_from_word
|
397
|
+
@scanner.scan_setup "!foo"
|
398
|
+
assert_tok :BANG
|
399
|
+
assert_token :WORD, "foo"
|
400
|
+
end
|
401
|
+
|
402
|
+
def test_timeout_to
|
403
|
+
@scanner.scan_setup "timeout_to"
|
404
|
+
assert_token :TIMEOUT, "timeout_to"
|
405
|
+
end
|
406
|
+
|
407
|
+
def test_after
|
408
|
+
@scanner.scan_setup "after"
|
409
|
+
assert_token :AFTER, "after"
|
410
|
+
end
|
411
|
+
|
412
|
+
def test_scanning_single_quoted_string
|
413
|
+
@scanner.scan_setup "'string'"
|
414
|
+
assert_token :STRING, "string"
|
415
|
+
end
|
416
|
+
|
417
|
+
def test_scanning_double_quoted_string
|
418
|
+
@scanner.scan_setup '"string"'
|
419
|
+
assert_token :STRING, "string"
|
420
|
+
end
|
421
|
+
|
422
|
+
def test_scan_namespace
|
423
|
+
@scanner.scan_setup "namespace"
|
424
|
+
assert_token :NAMESPACE, "namespace"
|
425
|
+
end
|
426
|
+
|
427
|
+
def test_scan_eval
|
428
|
+
@scanner.scan_setup "eval"
|
429
|
+
assert_token :EVAL, "eval"
|
430
|
+
end
|
431
|
+
|
432
|
+
def test_scan_for
|
433
|
+
@scanner.scan_setup "for"
|
434
|
+
assert_token :FOR, "for"
|
435
|
+
end
|
436
|
+
|
437
|
+
def test_scan_in
|
438
|
+
@scanner.scan_setup "in"
|
439
|
+
assert_token :IN, "in"
|
440
|
+
end
|
441
|
+
|
442
|
+
def test_scan_indirect
|
443
|
+
@scanner.scan_setup "indirect"
|
444
|
+
assert_token :INDIRECT, "indirect"
|
445
|
+
end
|
446
|
+
|
447
|
+
def test_scan_while
|
448
|
+
@scanner.scan_setup "while"
|
449
|
+
assert_token :WHILE, "while"
|
450
|
+
end
|
451
|
+
|
452
|
+
def test_start
|
453
|
+
@scanner.scan_setup "start"
|
454
|
+
assert_token :TIMER_METHOD, "start"
|
455
|
+
end
|
456
|
+
|
457
|
+
def test_stop
|
458
|
+
@scanner.scan_setup "stop"
|
459
|
+
assert_token :TIMER_METHOD, "stop"
|
460
|
+
end
|
461
|
+
|
462
|
+
def test_reset
|
463
|
+
@scanner.scan_setup "reset"
|
464
|
+
assert_token :TIMER_METHOD, "reset"
|
465
|
+
end
|
466
|
+
|
467
|
+
def test_restart
|
468
|
+
@scanner.scan_setup "restart"
|
469
|
+
assert_token :TIMER_METHOD, "restart"
|
470
|
+
end
|
471
|
+
|
472
|
+
def test_position_data
|
473
|
+
@scanner.scan_setup "position_data"
|
474
|
+
assert_token :POSITION_DATA, "position_data"
|
475
|
+
end
|
476
|
+
|
477
|
+
def test_pulse
|
478
|
+
@scanner.scan_setup "pulse"
|
479
|
+
assert_token :IO_METHOD, "pulse"
|
480
|
+
end
|
481
|
+
|
482
|
+
def test_scan_ualm
|
483
|
+
@scanner.scan_setup "UALM[1]"
|
484
|
+
assert_token :UALM, "UALM"
|
485
|
+
end
|
486
|
+
|
487
|
+
def test_scan_raise
|
488
|
+
@scanner.scan_setup "raise"
|
489
|
+
assert_token :RAISE, "raise"
|
490
|
+
end
|
491
|
+
|
492
|
+
def test_scan_run
|
493
|
+
@scanner.scan_setup "run"
|
494
|
+
assert_token :RUN, "run"
|
495
|
+
end
|
496
|
+
|
497
|
+
def test_tp_ignore_pause
|
498
|
+
@scanner.scan_setup "TP_IGNORE_PAUSE"
|
499
|
+
assert_token :TP_HEADER, "TP_IGNORE_PAUSE"
|
500
|
+
end
|
501
|
+
|
502
|
+
def test_tp_comment
|
503
|
+
@scanner.scan_setup "TP_COMMENT"
|
504
|
+
assert_token :TP_HEADER, "TP_COMMENT"
|
505
|
+
end
|
506
|
+
|
507
|
+
def test_tp_groupmask
|
508
|
+
@scanner.scan_setup "TP_GROUPMASK"
|
509
|
+
assert_token :TP_HEADER, "TP_GROUPMASK"
|
510
|
+
end
|
511
|
+
|
512
|
+
def test_tp_subtype
|
513
|
+
@scanner.scan_setup "TP_SUBTYPE"
|
514
|
+
assert_token :TP_HEADER, "TP_SUBTYPE"
|
515
|
+
end
|
516
|
+
|
517
|
+
def test_tool_offset
|
518
|
+
@scanner.scan_setup "tool_offset to toff"
|
519
|
+
assert_token :OFFSET, "tool_offset"
|
520
|
+
assert_token :TO, "to"
|
521
|
+
assert_token :WORD, "toff"
|
522
|
+
end
|
523
|
+
|
524
|
+
def test_vision_offset
|
525
|
+
@scanner.scan_setup "vision_offset"
|
526
|
+
assert_token :OFFSET, "vision_offset"
|
527
|
+
end
|
528
|
+
|
529
|
+
def test_pause
|
530
|
+
@scanner.scan_setup "pause"
|
531
|
+
assert_token :PAUSE, "pause"
|
532
|
+
end
|
533
|
+
|
534
|
+
def test_abort
|
535
|
+
@scanner.scan_setup "abort"
|
536
|
+
assert_token :ABORT, "abort"
|
537
|
+
end
|
538
|
+
|
539
|
+
def test_ident
|
540
|
+
@scanner.scan_setup "foo_bar1 foo? foo!"
|
541
|
+
assert_token :WORD, "foo_bar1"
|
542
|
+
assert_token :WORD, "foo?"
|
543
|
+
assert_token :WORD, "foo!"
|
544
|
+
end
|
545
|
+
|
546
|
+
def test_punctuation
|
547
|
+
pairs = [
|
548
|
+
['(', :LPAREN],
|
549
|
+
[')', :RPAREN],
|
550
|
+
['[', :LBRACK],
|
551
|
+
[']', :RBRACK],
|
552
|
+
['{', :LBRACE],
|
553
|
+
['}', :RBRACE],
|
554
|
+
[',', :COMMA],
|
555
|
+
[':', :COLON]
|
556
|
+
]
|
557
|
+
|
558
|
+
pairs.each do |pair|
|
559
|
+
@scanner.scan_setup pair[0]
|
560
|
+
assert_tok pair[1]
|
561
|
+
end
|
562
|
+
end
|
563
|
+
|
564
|
+
def test_address
|
565
|
+
@scanner.scan_setup "&foo"
|
566
|
+
assert_token :ADDRESS, "foo"
|
567
|
+
end
|
568
|
+
|
569
|
+
def test_linear_position
|
570
|
+
@scanner.scan_setup "get_linear_position"
|
571
|
+
assert_token :LPOS, "get_linear_position"
|
572
|
+
end
|
573
|
+
|
574
|
+
def test_joint_position
|
575
|
+
@scanner.scan_setup "get_joint_position"
|
576
|
+
assert_token :JPOS, "get_joint_position"
|
577
|
+
end
|
578
|
+
|
579
|
+
def test_groups
|
580
|
+
@scanner.scan_setup "gp3 foo.gp3"
|
581
|
+
assert_token :WORD, "gp3"
|
582
|
+
assert_token :WORD, "foo"
|
583
|
+
assert_tok :DOT
|
584
|
+
assert_token :GROUP, "gp3"
|
585
|
+
end
|
586
|
+
|
587
|
+
def test_return
|
588
|
+
@scanner.scan_setup "return"
|
589
|
+
assert_token :RETURN, "return"
|
590
|
+
end
|
591
|
+
end
|