ruby_parser 3.13.0 → 3.13.1

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.
@@ -7,7 +7,7 @@ require "rp_extensions"
7
7
  require "rp_stringscanner"
8
8
 
9
9
  module RubyParserStuff
10
- VERSION = "3.13.0"
10
+ VERSION = "3.13.1"
11
11
 
12
12
  attr_accessor :lexer, :in_def, :in_single, :file
13
13
  attr_accessor :in_kwarg
@@ -698,6 +698,22 @@ module RubyParserStuff
698
698
  result
699
699
  end
700
700
 
701
+ def new_const_op_asgn val
702
+ lhs, asgn_op, rhs = val[0], val[1].to_sym, val[2]
703
+
704
+ result = case asgn_op
705
+ when :"||" then
706
+ s(:op_asgn_or, lhs, rhs)
707
+ when :"&&" then
708
+ s(:op_asgn_and, lhs, rhs)
709
+ else
710
+ s(:op_asgn, lhs, asgn_op, rhs)
711
+ end
712
+
713
+ result.line = lhs.line
714
+ result
715
+ end
716
+
701
717
  def new_op_asgn2 val
702
718
  recv, call_op, meth, op, arg = val
703
719
  meth = :"#{meth}="
@@ -804,6 +820,7 @@ module RubyParserStuff
804
820
 
805
821
  def new_string val
806
822
  str = val[0]
823
+ str.force_encoding("UTF-8")
807
824
  str.force_encoding("ASCII-8BIT") unless str.valid_encoding?
808
825
  result = s(:str, str)
809
826
  self.lexer.fixup_lineno str.count("\n")
@@ -1168,6 +1185,8 @@ module RubyParserStuff
1168
1185
  end
1169
1186
 
1170
1187
  class Keyword
1188
+ include RubyLexer::State::Values
1189
+
1171
1190
  class KWtable
1172
1191
  attr_accessor :name, :state, :id0, :id1
1173
1192
  def initialize(name, id=[], state=nil)
@@ -1196,48 +1215,50 @@ module RubyParserStuff
1196
1215
  # :expr_value = :expr_beg -- work to remove. Need multi-state support.
1197
1216
 
1198
1217
  wordlist = [
1199
- ["alias", [:kALIAS, :kALIAS ], :expr_fname ],
1200
- ["and", [:kAND, :kAND ], :expr_beg ],
1201
- ["begin", [:kBEGIN, :kBEGIN ], :expr_beg ],
1202
- ["break", [:kBREAK, :kBREAK ], :expr_mid ],
1203
- ["case", [:kCASE, :kCASE ], :expr_beg ],
1204
- ["class", [:kCLASS, :kCLASS ], :expr_class ],
1205
- ["def", [:kDEF, :kDEF ], :expr_fname ],
1206
- ["defined?", [:kDEFINED, :kDEFINED ], :expr_arg ],
1207
- ["do", [:kDO, :kDO ], :expr_beg ],
1208
- ["else", [:kELSE, :kELSE ], :expr_beg ],
1209
- ["elsif", [:kELSIF, :kELSIF ], :expr_beg ],
1210
- ["end", [:kEND, :kEND ], :expr_end ],
1211
- ["ensure", [:kENSURE, :kENSURE ], :expr_beg ],
1212
- ["false", [:kFALSE, :kFALSE ], :expr_end ],
1213
- ["for", [:kFOR, :kFOR ], :expr_beg ],
1214
- ["if", [:kIF, :kIF_MOD ], :expr_beg ],
1215
- ["in", [:kIN, :kIN ], :expr_beg ],
1216
- ["module", [:kMODULE, :kMODULE ], :expr_beg ],
1217
- ["next", [:kNEXT, :kNEXT ], :expr_mid ],
1218
- ["nil", [:kNIL, :kNIL ], :expr_end ],
1219
- ["not", [:kNOT, :kNOT ], :expr_arg ],
1220
- ["or", [:kOR, :kOR ], :expr_beg ],
1221
- ["redo", [:kREDO, :kREDO ], :expr_end ],
1222
- ["rescue", [:kRESCUE, :kRESCUE_MOD ], :expr_mid ],
1223
- ["retry", [:kRETRY, :kRETRY ], :expr_end ],
1224
- ["return", [:kRETURN, :kRETURN ], :expr_mid ],
1225
- ["self", [:kSELF, :kSELF ], :expr_end ],
1226
- ["super", [:kSUPER, :kSUPER ], :expr_arg ],
1227
- ["then", [:kTHEN, :kTHEN ], :expr_beg ],
1228
- ["true", [:kTRUE, :kTRUE ], :expr_end ],
1229
- ["undef", [:kUNDEF, :kUNDEF ], :expr_fname ],
1230
- ["unless", [:kUNLESS, :kUNLESS_MOD ], :expr_beg ],
1231
- ["until", [:kUNTIL, :kUNTIL_MOD ], :expr_beg ],
1232
- ["when", [:kWHEN, :kWHEN ], :expr_beg ],
1233
- ["while", [:kWHILE, :kWHILE_MOD ], :expr_beg ],
1234
- ["yield", [:kYIELD, :kYIELD ], :expr_arg ],
1235
- ["BEGIN", [:klBEGIN, :klBEGIN ], :expr_end ],
1236
- ["END", [:klEND, :klEND ], :expr_end ],
1237
- ["__FILE__", [:k__FILE__, :k__FILE__ ], :expr_end ],
1238
- ["__LINE__", [:k__LINE__, :k__LINE__ ], :expr_end ],
1239
- ["__ENCODING__", [:k__ENCODING__, :k__ENCODING__], :expr_end],
1240
- ].map { |args| KWtable.new(*args) }
1218
+ ["alias", [:kALIAS, :kALIAS ], EXPR_FNAME|EXPR_FITEM],
1219
+ ["and", [:kAND, :kAND ], EXPR_BEG ],
1220
+ ["begin", [:kBEGIN, :kBEGIN ], EXPR_BEG ],
1221
+ ["break", [:kBREAK, :kBREAK ], EXPR_MID ],
1222
+ ["case", [:kCASE, :kCASE ], EXPR_BEG ],
1223
+ ["class", [:kCLASS, :kCLASS ], EXPR_CLASS ],
1224
+ ["def", [:kDEF, :kDEF ], EXPR_FNAME ],
1225
+ ["defined?", [:kDEFINED, :kDEFINED ], EXPR_ARG ],
1226
+ ["do", [:kDO, :kDO ], EXPR_BEG ],
1227
+ ["else", [:kELSE, :kELSE ], EXPR_BEG ],
1228
+ ["elsif", [:kELSIF, :kELSIF ], EXPR_BEG ],
1229
+ ["end", [:kEND, :kEND ], EXPR_END ],
1230
+ ["ensure", [:kENSURE, :kENSURE ], EXPR_BEG ],
1231
+ ["false", [:kFALSE, :kFALSE ], EXPR_END ],
1232
+ ["for", [:kFOR, :kFOR ], EXPR_BEG ],
1233
+ ["if", [:kIF, :kIF_MOD ], EXPR_BEG ],
1234
+ ["in", [:kIN, :kIN ], EXPR_BEG ],
1235
+ ["module", [:kMODULE, :kMODULE ], EXPR_BEG ],
1236
+ ["next", [:kNEXT, :kNEXT ], EXPR_MID ],
1237
+ ["nil", [:kNIL, :kNIL ], EXPR_END ],
1238
+ ["not", [:kNOT, :kNOT ], EXPR_ARG ],
1239
+ ["or", [:kOR, :kOR ], EXPR_BEG ],
1240
+ ["redo", [:kREDO, :kREDO ], EXPR_END ],
1241
+ ["rescue", [:kRESCUE, :kRESCUE_MOD ], EXPR_MID ],
1242
+ ["retry", [:kRETRY, :kRETRY ], EXPR_END ],
1243
+ ["return", [:kRETURN, :kRETURN ], EXPR_MID ],
1244
+ ["self", [:kSELF, :kSELF ], EXPR_END ],
1245
+ ["super", [:kSUPER, :kSUPER ], EXPR_ARG ],
1246
+ ["then", [:kTHEN, :kTHEN ], EXPR_BEG ],
1247
+ ["true", [:kTRUE, :kTRUE ], EXPR_END ],
1248
+ ["undef", [:kUNDEF, :kUNDEF ], EXPR_FNAME|EXPR_FITEM],
1249
+ ["unless", [:kUNLESS, :kUNLESS_MOD ], EXPR_BEG ],
1250
+ ["until", [:kUNTIL, :kUNTIL_MOD ], EXPR_BEG ],
1251
+ ["when", [:kWHEN, :kWHEN ], EXPR_BEG ],
1252
+ ["while", [:kWHILE, :kWHILE_MOD ], EXPR_BEG ],
1253
+ ["yield", [:kYIELD, :kYIELD ], EXPR_ARG ],
1254
+ ["BEGIN", [:klBEGIN, :klBEGIN ], EXPR_END ],
1255
+ ["END", [:klEND, :klEND ], EXPR_END ],
1256
+ ["__FILE__", [:k__FILE__, :k__FILE__ ], EXPR_END ],
1257
+ ["__LINE__", [:k__LINE__, :k__LINE__ ], EXPR_END ],
1258
+ ["__ENCODING__", [:k__ENCODING__, :k__ENCODING__], EXPR_END],
1259
+ ].map { |args|
1260
+ KWtable.new(*args)
1261
+ }
1241
1262
 
1242
1263
  # :startdoc:
1243
1264
 
@@ -1,17 +1,20 @@
1
1
  # encoding: US-ASCII
2
+ # TODO: work this out
2
3
 
3
4
  require "minitest/autorun"
4
5
  require "ruby_lexer"
5
6
  require "ruby_parser"
6
7
 
7
8
  class TestRubyLexer < Minitest::Test
9
+ include RubyLexer::State::Values
10
+
8
11
  attr_accessor :processor, :lex, :parser_class, :lex_state
9
12
 
10
13
  alias :lexer :lex # lets me copy/paste code from parser
11
14
  alias :lexer= :lex=
12
15
 
13
16
  def setup
14
- self.lex_state = :expr_beg
17
+ self.lex_state = EXPR_BEG
15
18
  setup_lexer_class RubyParser.latest.class
16
19
  end
17
20
 
@@ -59,11 +62,11 @@ class TestRubyLexer < Minitest::Test
59
62
  end
60
63
  end
61
64
 
62
- def assert_lex_fname name, type, end_state = :expr_arg # TODO: swap name/type
65
+ def assert_lex_fname name, type, end_state = EXPR_ARG # TODO: swap name/type
63
66
  assert_lex3("def #{name} ",
64
67
  nil,
65
68
 
66
- :kDEF, "def", :expr_fname,
69
+ :kDEF, "def", EXPR_FNAME,
67
70
  type, name, end_state)
68
71
  end
69
72
 
@@ -102,8 +105,8 @@ class TestRubyLexer < Minitest::Test
102
105
  end
103
106
 
104
107
  def assert_read_escape expected, input
105
- @lex.ss.string = input
106
- assert_equal expected, @lex.read_escape, input
108
+ @lex.ss.string = input.dup
109
+ assert_equal expected, @lex.read_escape.b, input
107
110
  end
108
111
 
109
112
  def assert_read_escape_bad input # TODO: rename refute_read_escape
@@ -132,15 +135,15 @@ class TestRubyLexer < Minitest::Test
132
135
  lexer.cmdarg.push false
133
136
 
134
137
  lexer.lex_strterm = nil
135
- lexer.lex_state = :expr_beg
138
+ lexer.lex_state = EXPR_BEG
136
139
 
137
140
  yield
138
141
 
139
- lexer.lex_state = :expr_endarg
140
- assert_next_lexeme :tSTRING_DEND, "}", :expr_endarg, 0
142
+ lexer.lex_state = EXPR_ENDARG
143
+ assert_next_lexeme :tSTRING_DEND, "}", EXPR_ENDARG, 0
141
144
 
142
145
  lexer.lex_strterm = lex_strterm
143
- lexer.lex_state = :expr_beg
146
+ lexer.lex_state = EXPR_BEG
144
147
  lexer.string_nest = string_nest
145
148
  lexer.brace_nest = brace_nest
146
149
 
@@ -158,7 +161,7 @@ class TestRubyLexer < Minitest::Test
158
161
 
159
162
  def test_unicode_ident
160
163
  s = "@\u1088\u1077\u1093\u1072"
161
- assert_lex3(s.dup, nil, :tIVAR, s.dup, :expr_end)
164
+ assert_lex3(s.dup, nil, :tIVAR, s.dup, EXPR_END)
162
165
  end
163
166
 
164
167
  def test_read_escape
@@ -217,9 +220,9 @@ class TestRubyLexer < Minitest::Test
217
220
  def test_yylex_ambiguous_uminus
218
221
  assert_lex3("m -3",
219
222
  nil,
220
- :tIDENTIFIER, "m", :expr_cmdarg,
221
- :tUMINUS_NUM, "-", :expr_beg,
222
- :tINTEGER, 3, :expr_end)
223
+ :tIDENTIFIER, "m", EXPR_CMDARG,
224
+ :tUMINUS_NUM, "-", EXPR_BEG,
225
+ :tINTEGER, 3, EXPR_NUM)
223
226
 
224
227
  # TODO: verify warning
225
228
  end
@@ -227,36 +230,36 @@ class TestRubyLexer < Minitest::Test
227
230
  def test_yylex_ambiguous_uplus
228
231
  assert_lex3("m +3",
229
232
  nil,
230
- :tIDENTIFIER, "m", :expr_cmdarg,
231
- :tINTEGER, 3, :expr_end)
233
+ :tIDENTIFIER, "m", EXPR_CMDARG,
234
+ :tINTEGER, 3, EXPR_NUM)
232
235
 
233
236
  # TODO: verify warning
234
237
  end
235
238
 
236
239
  def test_yylex_and
237
- assert_lex3("&", nil, :tAMPER, "&", :expr_beg)
240
+ assert_lex3("&", nil, :tAMPER, "&", EXPR_BEG)
238
241
  end
239
242
 
240
243
  def test_yylex_and2
241
- assert_lex3("&&", nil, :tANDOP, "&&", :expr_beg)
244
+ assert_lex3("&&", nil, :tANDOP, "&&", EXPR_BEG)
242
245
  end
243
246
 
244
247
  def test_yylex_and2_equals
245
- assert_lex3("&&=", nil, :tOP_ASGN, "&&", :expr_beg)
248
+ assert_lex3("&&=", nil, :tOP_ASGN, "&&", EXPR_BEG)
246
249
  end
247
250
 
248
251
  def test_yylex_and_dot
249
252
  setup_lexer_class RubyParser::V23
250
253
 
251
- assert_lex3("&.", nil, :tLONELY, "&.", :expr_dot)
254
+ assert_lex3("&.", nil, :tLONELY, "&.", EXPR_DOT)
252
255
  end
253
256
 
254
257
  def test_yylex_and_dot_call
255
258
  setup_lexer_class RubyParser::V23
256
259
 
257
260
  assert_lex3("x&.y", nil,
258
- :tIDENTIFIER, "x", :expr_cmdarg,
259
- :tLONELY, "&.", :expr_dot,
261
+ :tIDENTIFIER, "x", EXPR_CMDARG,
262
+ :tLONELY, "&.", EXPR_DOT,
260
263
  :tIDENTIFIER, "y")
261
264
  end
262
265
 
@@ -264,32 +267,32 @@ class TestRubyLexer < Minitest::Test
264
267
  setup_lexer_class Ruby23Parser
265
268
 
266
269
  assert_lex3("x\n&.y", nil,
267
- :tIDENTIFIER, "x", :expr_cmdarg,
268
- :tLONELY, "&.", :expr_dot,
270
+ :tIDENTIFIER, "x", EXPR_CMDARG,
271
+ :tLONELY, "&.", EXPR_DOT,
269
272
  :tIDENTIFIER, "y")
270
273
  end
271
274
 
272
275
  def test_yylex_and_arg
273
- self.lex_state = :expr_arg
276
+ self.lex_state = EXPR_ARG
274
277
 
275
278
  assert_lex3(" &y",
276
279
  nil,
277
- :tAMPER, "&", :expr_beg,
278
- :tIDENTIFIER, "y", :expr_arg)
280
+ :tAMPER, "&", EXPR_BEG,
281
+ :tIDENTIFIER, "y", EXPR_ARG)
279
282
  end
280
283
 
281
284
  def test_yylex_and_equals
282
- assert_lex3("&=", nil, :tOP_ASGN, "&", :expr_beg)
285
+ assert_lex3("&=", nil, :tOP_ASGN, "&", EXPR_BEG)
283
286
  end
284
287
 
285
288
  def test_yylex_and_expr
286
- self.lex_state = :expr_arg
289
+ self.lex_state = EXPR_ARG
287
290
 
288
291
  assert_lex3("x & y",
289
292
  nil,
290
- :tIDENTIFIER, "x", :expr_cmdarg,
291
- :tAMPER2, "&", :expr_beg,
292
- :tIDENTIFIER, "y", :expr_arg)
293
+ :tIDENTIFIER, "x", EXPR_CMDARG,
294
+ :tAMPER2, "&", EXPR_BEG,
295
+ :tIDENTIFIER, "y", EXPR_ARG)
293
296
  end
294
297
 
295
298
  def test_yylex_and_meth
@@ -297,7 +300,7 @@ class TestRubyLexer < Minitest::Test
297
300
  end
298
301
 
299
302
  def test_yylex_assoc
300
- assert_lex3("=>", nil, :tASSOC, "=>", :expr_beg)
303
+ assert_lex3 "=>", nil, :tASSOC, "=>", EXPR_BEG
301
304
  end
302
305
 
303
306
  def test_yylex_label__20
@@ -305,8 +308,8 @@ class TestRubyLexer < Minitest::Test
305
308
 
306
309
  assert_lex3("{a:",
307
310
  nil,
308
- :tLBRACE, "{", :expr_beg,
309
- :tLABEL, "a", :expr_labeled)
311
+ :tLBRACE, "{", EXPR_PAR,
312
+ :tLABEL, "a", EXPR_LAB)
310
313
  end
311
314
 
312
315
  def test_yylex_label_in_params__20
@@ -314,9 +317,9 @@ class TestRubyLexer < Minitest::Test
314
317
 
315
318
  assert_lex3("foo(a:",
316
319
  nil,
317
- :tIDENTIFIER, "foo", :expr_cmdarg,
318
- :tLPAREN2, "(", :expr_beg,
319
- :tLABEL, "a", :expr_labeled)
320
+ :tIDENTIFIER, "foo", EXPR_CMDARG,
321
+ :tLPAREN2, "(", EXPR_PAR,
322
+ :tLABEL, "a", EXPR_LAB)
320
323
  end
321
324
 
322
325
  def test_yylex_paren_string_parens_interpolated
@@ -327,22 +330,22 @@ class TestRubyLexer < Minitest::Test
327
330
  s(:evstr, s(:call, nil, :d)),
328
331
  s(:str, ")")))
329
332
 
330
- assert_next_lexeme :tSTRING_BEG, "%)", :expr_beg, 0, 0
331
- assert_next_lexeme :tSTRING_CONTENT, "(", :expr_beg, 0, 0
332
- assert_next_lexeme :tSTRING_DBEG, nil, :expr_beg, 0, 0
333
+ assert_next_lexeme :tSTRING_BEG, "%)", EXPR_BEG, 0, 0
334
+ assert_next_lexeme :tSTRING_CONTENT, "(", EXPR_BEG, 0, 0
335
+ assert_next_lexeme :tSTRING_DBEG, nil, EXPR_BEG, 0, 0
333
336
 
334
337
  emulate_string_interpolation do
335
- assert_next_lexeme :tIDENTIFIER, "b", :expr_cmdarg, 0, 0
338
+ assert_next_lexeme :tIDENTIFIER, "b", EXPR_CMDARG, 0, 0
336
339
  end
337
340
 
338
- assert_next_lexeme :tSTRING_DBEG, nil, :expr_beg, 0, 0
341
+ assert_next_lexeme :tSTRING_DBEG, nil, EXPR_BEG, 0, 0
339
342
 
340
343
  emulate_string_interpolation do
341
- assert_next_lexeme :tIDENTIFIER, "d", :expr_cmdarg, 0, 0
344
+ assert_next_lexeme :tIDENTIFIER, "d", EXPR_CMDARG, 0, 0
342
345
  end
343
346
 
344
- assert_next_lexeme :tSTRING_CONTENT, ")", :expr_beg, 0, 0
345
- assert_next_lexeme :tSTRING_END, ")", :expr_end, 0, 0
347
+ assert_next_lexeme :tSTRING_CONTENT, ")", EXPR_BEG, 0, 0
348
+ assert_next_lexeme :tSTRING_END, ")", EXPR_END, 0, 0
346
349
 
347
350
  refute_lexeme
348
351
  end
@@ -351,20 +354,20 @@ class TestRubyLexer < Minitest::Test
351
354
  setup_lexer('%( #{(/abcd/)} )',
352
355
  s(:dstr, " ", s(:evstr, s(:lit, /abcd/)), s(:str, " ")))
353
356
 
354
- assert_next_lexeme :tSTRING_BEG, "%)", :expr_beg, 0, 0
355
- assert_next_lexeme :tSTRING_CONTENT, " ", :expr_beg, 0, 0
356
- assert_next_lexeme :tSTRING_DBEG, nil, :expr_beg, 0, 0
357
+ assert_next_lexeme :tSTRING_BEG, "%)", EXPR_BEG, 0, 0
358
+ assert_next_lexeme :tSTRING_CONTENT, " ", EXPR_BEG, 0, 0
359
+ assert_next_lexeme :tSTRING_DBEG, nil, EXPR_BEG, 0, 0
357
360
 
358
361
  emulate_string_interpolation do
359
- assert_next_lexeme :tLPAREN, "(", :expr_beg, 1, 0
360
- assert_next_lexeme :tREGEXP_BEG, "/", :expr_beg, 1, 0
361
- assert_next_lexeme :tSTRING_CONTENT, "abcd", :expr_beg, 1, 0
362
- assert_next_lexeme :tREGEXP_END, "", :expr_end, 1, 0
363
- assert_next_lexeme :tRPAREN, ")", :expr_endfn, 0, 0
362
+ assert_next_lexeme :tLPAREN, "(", EXPR_PAR, 1, 0
363
+ assert_next_lexeme :tREGEXP_BEG, "/", EXPR_PAR, 1, 0
364
+ assert_next_lexeme :tSTRING_CONTENT, "abcd", EXPR_PAR, 1, 0
365
+ assert_next_lexeme :tREGEXP_END, "", EXPR_END, 1, 0
366
+ assert_next_lexeme :tRPAREN, ")", EXPR_ENDFN, 0, 0
364
367
  end
365
368
 
366
- assert_next_lexeme :tSTRING_CONTENT, " ", :expr_beg, 0, 0
367
- assert_next_lexeme :tSTRING_END, ")", :expr_end, 0, 0
369
+ assert_next_lexeme :tSTRING_CONTENT, " ", EXPR_BEG, 0, 0
370
+ assert_next_lexeme :tSTRING_END, ")", EXPR_END, 0, 0
368
371
 
369
372
  refute_lexeme
370
373
  end
@@ -375,26 +378,26 @@ class TestRubyLexer < Minitest::Test
375
378
  assert_lex("def +@; end",
376
379
  s(:defn, :+@, s(:args), s(:nil)),
377
380
 
378
- :kDEF, "def", :expr_fname, 0, 0,
379
- :tUPLUS, "+@", :expr_arg, 0, 0,
380
- :tSEMI, ";", :expr_beg, 0, 0,
381
- :kEND, "end", :expr_end, 0, 0)
381
+ :kDEF, "def", EXPR_FNAME, 0, 0,
382
+ :tUPLUS, "+@", EXPR_ARG, 0, 0,
383
+ :tSEMI, ";", EXPR_BEG, 0, 0,
384
+ :kEND, "end", EXPR_END, 0, 0)
382
385
 
383
386
  assert_lex("def !@; end",
384
387
  s(:defn, :"!@", s(:args), s(:nil)),
385
388
 
386
- :kDEF, "def", :expr_fname, 0, 0,
387
- :tUBANG, "!@", :expr_arg, 0, 0,
388
- :tSEMI, ";", :expr_beg, 0, 0,
389
- :kEND, "end", :expr_end, 0, 0)
389
+ :kDEF, "def", EXPR_FNAME, 0, 0,
390
+ :tUBANG, "!@", EXPR_ARG, 0, 0,
391
+ :tSEMI, ";", EXPR_BEG, 0, 0,
392
+ :kEND, "end", EXPR_END, 0, 0)
390
393
  end
391
394
 
392
395
  def test_yylex_not_at_ivar
393
396
  assert_lex("!@ivar",
394
397
  s(:call, s(:ivar, :@ivar), :"!"),
395
398
 
396
- :tBANG, "!", :expr_beg, 0, 0,
397
- :tIVAR, "@ivar", :expr_end, 0, 0)
399
+ :tBANG, "!", EXPR_BEG, 0, 0,
400
+ :tIVAR, "@ivar", EXPR_END, 0, 0)
398
401
  end
399
402
 
400
403
  def test_yylex_number_times_ident_times_return_number
@@ -403,43 +406,43 @@ class TestRubyLexer < Minitest::Test
403
406
  s(:call, s(:lit, 1), :*, s(:call, nil, :b)),
404
407
  :*, s(:lit, 3)),
405
408
 
406
- :tINTEGER, 1, :expr_end, 0, 0,
407
- :tSTAR2, "*", :expr_beg, 0, 0,
408
- :tIDENTIFIER, "b", :expr_arg, 0, 0,
409
- :tSTAR2, "*", :expr_beg, 0, 0,
410
- :tINTEGER, 3, :expr_end, 0, 0)
409
+ :tINTEGER, 1, EXPR_NUM, 0, 0,
410
+ :tSTAR2, "*", EXPR_BEG, 0, 0,
411
+ :tIDENTIFIER, "b", EXPR_ARG, 0, 0,
412
+ :tSTAR2, "*", EXPR_BEG, 0, 0,
413
+ :tINTEGER, 3, EXPR_NUM, 0, 0)
411
414
 
412
415
  assert_lex("1 * b *\n 3",
413
416
  s(:call,
414
417
  s(:call, s(:lit, 1), :*, s(:call, nil, :b)),
415
418
  :*, s(:lit, 3)),
416
419
 
417
- :tINTEGER, 1, :expr_end, 0, 0,
418
- :tSTAR2, "*", :expr_beg, 0, 0,
419
- :tIDENTIFIER, "b", :expr_arg, 0, 0,
420
- :tSTAR2, "*", :expr_beg, 0, 0,
421
- :tINTEGER, 3, :expr_end, 0, 0)
420
+ :tINTEGER, 1, EXPR_NUM, 0, 0,
421
+ :tSTAR2, "*", EXPR_BEG, 0, 0,
422
+ :tIDENTIFIER, "b", EXPR_ARG, 0, 0,
423
+ :tSTAR2, "*", EXPR_BEG, 0, 0,
424
+ :tINTEGER, 3, EXPR_NUM, 0, 0)
422
425
  end
423
426
 
424
427
  def test_yylex_paren_string_parens_interpolated_regexp
425
428
  setup_lexer('%((#{(/abcd/)}))',
426
429
  s(:dstr, "(", s(:evstr, s(:lit, /abcd/)), s(:str, ")")))
427
430
 
428
- assert_next_lexeme :tSTRING_BEG, "%)", :expr_beg, 0, 0
429
- assert_next_lexeme :tSTRING_CONTENT, "(", :expr_beg, 0, 0
431
+ assert_next_lexeme :tSTRING_BEG, "%)", EXPR_BEG, 0, 0
432
+ assert_next_lexeme :tSTRING_CONTENT, "(", EXPR_BEG, 0, 0
430
433
 
431
- assert_next_lexeme :tSTRING_DBEG, nil, :expr_beg, 0, 0
434
+ assert_next_lexeme :tSTRING_DBEG, nil, EXPR_BEG, 0, 0
432
435
 
433
436
  emulate_string_interpolation do
434
- assert_next_lexeme :tLPAREN, "(", :expr_beg, 1, 0
435
- assert_next_lexeme :tREGEXP_BEG, "/", :expr_beg, 1, 0
436
- assert_next_lexeme :tSTRING_CONTENT, "abcd", :expr_beg, 1, 0
437
- assert_next_lexeme :tREGEXP_END, "", :expr_end, 1, 0
438
- assert_next_lexeme :tRPAREN, ")", :expr_endfn, 0, 0
437
+ assert_next_lexeme :tLPAREN, "(", EXPR_PAR, 1, 0
438
+ assert_next_lexeme :tREGEXP_BEG, "/", EXPR_PAR, 1, 0
439
+ assert_next_lexeme :tSTRING_CONTENT, "abcd", EXPR_PAR, 1, 0
440
+ assert_next_lexeme :tREGEXP_END, "", EXPR_END, 1, 0
441
+ assert_next_lexeme :tRPAREN, ")", EXPR_ENDFN, 0, 0
439
442
  end
440
443
 
441
- assert_next_lexeme :tSTRING_CONTENT, ")", :expr_beg, 0, 0
442
- assert_next_lexeme :tSTRING_END, ")", :expr_end, 0, 0
444
+ assert_next_lexeme :tSTRING_CONTENT, ")", EXPR_BEG, 0, 0
445
+ assert_next_lexeme :tSTRING_END, ")", EXPR_END, 0, 0
443
446
 
444
447
  refute_lexeme
445
448
  end
@@ -447,11 +450,11 @@ class TestRubyLexer < Minitest::Test
447
450
  def test_yylex_method_parens_chevron
448
451
  assert_lex("a()<<1",
449
452
  s(:call, s(:call, nil, :a), :<<, s(:lit, 1)),
450
- :tIDENTIFIER, "a", :expr_cmdarg, 0, 0,
451
- :tLPAREN2, "(", :expr_beg, 1, 0,
452
- :tRPAREN, ")", :expr_endfn, 0, 0,
453
- :tLSHFT, "<<" , :expr_beg, 0, 0,
454
- :tINTEGER, 1, :expr_end, 0, 0)
453
+ :tIDENTIFIER, "a", EXPR_CMDARG, 0, 0,
454
+ :tLPAREN2, "(", EXPR_PAR, 1, 0,
455
+ :tRPAREN, ")", EXPR_ENDFN, 0, 0,
456
+ :tLSHFT, "<<" , EXPR_BEG, 0, 0,
457
+ :tINTEGER, 1, EXPR_NUM, 0, 0)
455
458
  end
456
459
 
457
460
  def test_yylex_lambda_args__20
@@ -461,12 +464,12 @@ class TestRubyLexer < Minitest::Test
461
464
  s(:iter, s(:call, nil, :lambda),
462
465
  s(:args, :a)),
463
466
 
464
- :tLAMBDA, nil, :expr_endfn, 0, 0,
465
- :tLPAREN2, "(", :expr_beg, 1, 0,
466
- :tIDENTIFIER, "a", :expr_arg, 1, 0,
467
- :tRPAREN, ")", :expr_endfn, 0, 0,
468
- :tLCURLY, "{", :expr_beg, 0, 1,
469
- :tRCURLY, "}", :expr_endarg, 0, 0)
467
+ :tLAMBDA, nil, EXPR_ENDFN, 0, 0,
468
+ :tLPAREN2, "(", EXPR_PAR, 1, 0,
469
+ :tIDENTIFIER, "a", EXPR_ARG, 1, 0,
470
+ :tRPAREN, ")", EXPR_ENDFN, 0, 0,
471
+ :tLCURLY, "{", EXPR_PAR, 0, 1,
472
+ :tRCURLY, "}", EXPR_ENDARG, 0, 0)
470
473
  end
471
474
 
472
475
  def test_yylex_lambda_as_args_with_block__20
@@ -474,12 +477,12 @@ class TestRubyLexer < Minitest::Test
474
477
 
475
478
  assert_lex3("a -> do end do end",
476
479
  nil,
477
- :tIDENTIFIER, "a", :expr_cmdarg,
478
- :tLAMBDA, nil, :expr_endfn,
479
- :kDO, "do", :expr_beg,
480
- :kEND, "end", :expr_end,
481
- :kDO, "do", :expr_beg,
482
- :kEND, "end", :expr_end)
480
+ :tIDENTIFIER, "a", EXPR_CMDARG,
481
+ :tLAMBDA, nil, EXPR_ENDFN,
482
+ :kDO, "do", EXPR_BEG,
483
+ :kEND, "end", EXPR_END,
484
+ :kDO, "do", EXPR_BEG,
485
+ :kEND, "end", EXPR_END)
483
486
  end
484
487
 
485
488
  def test_yylex_lambda_args_opt__20
@@ -489,14 +492,14 @@ class TestRubyLexer < Minitest::Test
489
492
  s(:iter, s(:call, nil, :lambda),
490
493
  s(:args, s(:lasgn, :a, s(:nil)))),
491
494
 
492
- :tLAMBDA, nil, :expr_endfn, 0, 0,
493
- :tLPAREN2, "(", :expr_beg, 1, 0,
494
- :tIDENTIFIER, "a", :expr_arg, 1, 0,
495
- :tEQL, "=", :expr_beg, 1, 0,
496
- :kNIL, "nil", :expr_end, 1, 0,
497
- :tRPAREN, ")", :expr_endfn, 0, 0,
498
- :tLCURLY, "{", :expr_beg, 0, 1,
499
- :tRCURLY, "}", :expr_endarg, 0, 0)
495
+ :tLAMBDA, nil, EXPR_ENDFN, 0, 0,
496
+ :tLPAREN2, "(", EXPR_PAR, 1, 0,
497
+ :tIDENTIFIER, "a", EXPR_ARG, 1, 0,
498
+ :tEQL, "=", EXPR_BEG, 1, 0,
499
+ :kNIL, "nil", EXPR_END, 1, 0,
500
+ :tRPAREN, ")", EXPR_ENDFN, 0, 0,
501
+ :tLCURLY, "{", EXPR_PAR, 0, 1,
502
+ :tRCURLY, "}", EXPR_ENDARG, 0, 0)
500
503
  end
501
504
 
502
505
  def test_yylex_lambda_hash__20
@@ -506,15 +509,15 @@ class TestRubyLexer < Minitest::Test
506
509
  s(:iter, s(:call, nil, :lambda),
507
510
  s(:args, s(:lasgn, :a, s(:hash)))),
508
511
 
509
- :tLAMBDA, nil, :expr_endfn, 0, 0,
510
- :tLPAREN2, "(", :expr_beg, 1, 0,
511
- :tIDENTIFIER, "a", :expr_arg, 1, 0,
512
- :tEQL, "=", :expr_beg, 1, 0,
513
- :tLBRACE, "{", :expr_beg, 1, 1,
514
- :tRCURLY, "}", :expr_endarg, 1, 0,
515
- :tRPAREN, ")", :expr_endfn, 0, 0,
516
- :tLCURLY, "{", :expr_beg, 0, 1,
517
- :tRCURLY, "}", :expr_endarg, 0, 0)
512
+ :tLAMBDA, nil, EXPR_ENDFN, 0, 0,
513
+ :tLPAREN2, "(", EXPR_PAR, 1, 0,
514
+ :tIDENTIFIER, "a", EXPR_ARG, 1, 0,
515
+ :tEQL, "=", EXPR_BEG, 1, 0,
516
+ :tLBRACE, "{", EXPR_PAR, 1, 1,
517
+ :tRCURLY, "}", EXPR_ENDARG, 1, 0,
518
+ :tRPAREN, ")", EXPR_ENDFN, 0, 0,
519
+ :tLCURLY, "{", EXPR_PAR, 0, 1,
520
+ :tRCURLY, "}", EXPR_ENDARG, 0, 0)
518
521
  end
519
522
 
520
523
  def test_yylex_iter_array_curly
@@ -523,19 +526,19 @@ class TestRubyLexer < Minitest::Test
523
526
  s(:call, nil, :f, s(:lit, :a), s(:array, s(:lit, :b))),
524
527
  s(:args, :c, :d)),
525
528
 
526
- :tIDENTIFIER, "f", :expr_cmdarg, 0, 0,
527
- :tSYMBOL, "a", :expr_end, 0, 0,
528
- :tCOMMA, ",", :expr_beg, 0, 0,
529
- :tLBRACK, "[", :expr_beg, 1, 0,
530
- :tSYMBOL, "b", :expr_end, 1, 0,
531
- :tRBRACK, "]", :expr_endarg, 0, 0,
532
- :tLBRACE_ARG, "{", :expr_beg, 0, 1,
533
- :tPIPE, "|", :expr_beg, 0, 1,
534
- :tIDENTIFIER, "c", :expr_arg, 0, 1,
535
- :tCOMMA, ",", :expr_beg, 0, 1,
536
- :tIDENTIFIER, "d", :expr_arg, 0, 1,
537
- :tPIPE, "|", :expr_beg, 0, 1,
538
- :tRCURLY, "}", :expr_endarg, 0, 0)
529
+ :tIDENTIFIER, "f", EXPR_CMDARG, 0, 0,
530
+ :tSYMBOL, "a", EXPR_END, 0, 0,
531
+ :tCOMMA, ",", EXPR_PAR, 0, 0,
532
+ :tLBRACK, "[", EXPR_PAR, 1, 0,
533
+ :tSYMBOL, "b", EXPR_END, 1, 0,
534
+ :tRBRACK, "]", EXPR_ENDARG, 0, 0,
535
+ :tLBRACE_ARG, "{", EXPR_BEG, 0, 1,
536
+ :tPIPE, "|", EXPR_PAR, 0, 1,
537
+ :tIDENTIFIER, "c", EXPR_ARG, 0, 1,
538
+ :tCOMMA, ",", EXPR_PAR, 0, 1,
539
+ :tIDENTIFIER, "d", EXPR_ARG, 0, 1,
540
+ :tPIPE, "|", EXPR_PAR, 0, 1,
541
+ :tRCURLY, "}", EXPR_ENDARG, 0, 0)
539
542
  end
540
543
 
541
544
  def test_yylex_const_call_same_name
@@ -547,18 +550,18 @@ class TestRubyLexer < Minitest::Test
547
550
  0,
548
551
  s(:call, nil, :f, s(:lit, :c)))),
549
552
 
550
- :tCONSTANT, "X", :expr_cmdarg, 0, 0,
551
- :tEQL, "=", :expr_beg, 0, 0,
552
- :tIDENTIFIER, "a", :expr_arg, 0, 0,
553
- :tLCURLY, "{", :expr_beg, 0, 1,
554
- :tRCURLY, "}", :expr_endarg, 0, 0,
555
- :tSEMI, ";", :expr_beg, 0, 0,
553
+ :tCONSTANT, "X", EXPR_CMDARG, 0, 0,
554
+ :tEQL, "=", EXPR_BEG, 0, 0,
555
+ :tIDENTIFIER, "a", EXPR_ARG, 0, 0,
556
+ :tLCURLY, "{", EXPR_PAR, 0, 1,
557
+ :tRCURLY, "}", EXPR_ENDARG, 0, 0,
558
+ :tSEMI, ";", EXPR_BEG, 0, 0,
556
559
 
557
- :tIDENTIFIER, "b", :expr_cmdarg, 0, 0,
558
- :tLCURLY, "{", :expr_beg, 0, 1,
559
- :tIDENTIFIER, "f", :expr_cmdarg, 0, 1, # different
560
- :tSYMBOL, "c", :expr_end, 0, 1,
561
- :tRCURLY, "}", :expr_endarg, 0, 0)
560
+ :tIDENTIFIER, "b", EXPR_CMDARG, 0, 0,
561
+ :tLCURLY, "{", EXPR_PAR, 0, 1,
562
+ :tIDENTIFIER, "f", EXPR_CMDARG, 0, 1, # different
563
+ :tSYMBOL, "c", EXPR_END, 0, 1,
564
+ :tRCURLY, "}", EXPR_ENDARG, 0, 0)
562
565
 
563
566
  assert_lex("X = a { }; b { X :c }",
564
567
  s(:block,
@@ -568,18 +571,18 @@ class TestRubyLexer < Minitest::Test
568
571
  0,
569
572
  s(:call, nil, :X, s(:lit, :c)))),
570
573
 
571
- :tCONSTANT, "X", :expr_cmdarg, 0, 0,
572
- :tEQL, "=", :expr_beg, 0, 0,
573
- :tIDENTIFIER, "a", :expr_arg, 0, 0,
574
- :tLCURLY, "{", :expr_beg, 0, 1,
575
- :tRCURLY, "}", :expr_endarg, 0, 0,
576
- :tSEMI, ";", :expr_beg, 0, 0,
574
+ :tCONSTANT, "X", EXPR_CMDARG, 0, 0,
575
+ :tEQL, "=", EXPR_BEG, 0, 0,
576
+ :tIDENTIFIER, "a", EXPR_ARG, 0, 0,
577
+ :tLCURLY, "{", EXPR_PAR, 0, 1,
578
+ :tRCURLY, "}", EXPR_ENDARG, 0, 0,
579
+ :tSEMI, ";", EXPR_BEG, 0, 0,
577
580
 
578
- :tIDENTIFIER, "b", :expr_cmdarg, 0, 0,
579
- :tLCURLY, "{", :expr_beg, 0, 1,
580
- :tCONSTANT, "X", :expr_cmdarg, 0, 1, # same
581
- :tSYMBOL, "c", :expr_end, 0, 1,
582
- :tRCURLY, "}", :expr_endarg, 0, 0)
581
+ :tIDENTIFIER, "b", EXPR_CMDARG, 0, 0,
582
+ :tLCURLY, "{", EXPR_PAR, 0, 1,
583
+ :tCONSTANT, "X", EXPR_CMDARG, 0, 1, # same
584
+ :tSYMBOL, "c", EXPR_END, 0, 1,
585
+ :tRCURLY, "}", EXPR_ENDARG, 0, 0)
583
586
  end
584
587
 
585
588
  def test_yylex_lasgn_call_same_name
@@ -588,47 +591,47 @@ class TestRubyLexer < Minitest::Test
588
591
  s(:call, s(:call, nil, :b), :c,
589
592
  s(:hash, s(:lit, :d), s(:lit, 1)))),
590
593
 
591
- :tIDENTIFIER, "a", :expr_cmdarg, 0, 0,
592
- :tEQL, "=", :expr_beg, 0, 0,
593
- :tIDENTIFIER, "b", :expr_arg, 0, 0,
594
- :tDOT, ".", :expr_dot, 0, 0,
595
- :tIDENTIFIER, "c", :expr_arg, 0, 0, # different
596
- :tSYMBOL, "d", :expr_end, 0, 0,
597
- :tASSOC, "=>", :expr_beg, 0, 0,
598
- :tINTEGER, 1, :expr_end, 0, 0)
594
+ :tIDENTIFIER, "a", EXPR_CMDARG, 0, 0,
595
+ :tEQL, "=", EXPR_BEG, 0, 0,
596
+ :tIDENTIFIER, "b", EXPR_ARG, 0, 0,
597
+ :tDOT, ".", EXPR_DOT, 0, 0,
598
+ :tIDENTIFIER, "c", EXPR_ARG, 0, 0, # different
599
+ :tSYMBOL, "d", EXPR_END, 0, 0,
600
+ :tASSOC, "=>", EXPR_BEG, 0, 0,
601
+ :tINTEGER, 1, EXPR_NUM, 0, 0)
599
602
 
600
603
  assert_lex("a = b.a :d => 1",
601
604
  s(:lasgn, :a,
602
605
  s(:call, s(:call, nil, :b), :a,
603
606
  s(:hash, s(:lit, :d), s(:lit, 1)))),
604
607
 
605
- :tIDENTIFIER, "a", :expr_cmdarg, 0, 0,
606
- :tEQL, "=", :expr_beg, 0, 0,
607
- :tIDENTIFIER, "b", :expr_arg, 0, 0,
608
- :tDOT, ".", :expr_dot, 0, 0,
609
- :tIDENTIFIER, "a", :expr_arg, 0, 0, # same as lvar
610
- :tSYMBOL, "d", :expr_end, 0, 0,
611
- :tASSOC, "=>", :expr_beg, 0, 0,
612
- :tINTEGER, 1, :expr_end, 0, 0)
608
+ :tIDENTIFIER, "a", EXPR_CMDARG, 0, 0,
609
+ :tEQL, "=", EXPR_BEG, 0, 0,
610
+ :tIDENTIFIER, "b", EXPR_ARG, 0, 0,
611
+ :tDOT, ".", EXPR_DOT, 0, 0,
612
+ :tIDENTIFIER, "a", EXPR_ARG, 0, 0, # same as lvar
613
+ :tSYMBOL, "d", EXPR_END, 0, 0,
614
+ :tASSOC, "=>", EXPR_BEG, 0, 0,
615
+ :tINTEGER, 1, EXPR_NUM, 0, 0)
613
616
  end
614
617
 
615
618
  def test_yylex_back_ref
616
619
  assert_lex3("[$&, $`, $', $+]",
617
620
  nil,
618
- :tLBRACK, "[", :expr_beg,
619
- :tBACK_REF, :&, :expr_end, :tCOMMA, ",", :expr_beg,
620
- :tBACK_REF, :"`", :expr_end, :tCOMMA, ",", :expr_beg,
621
- :tBACK_REF, :"'", :expr_end, :tCOMMA, ",", :expr_beg,
622
- :tBACK_REF, :+, :expr_end,
623
- :tRBRACK, "]", :expr_endarg)
621
+ :tLBRACK, "[", EXPR_PAR,
622
+ :tBACK_REF, :&, EXPR_END, :tCOMMA, ",", EXPR_PAR,
623
+ :tBACK_REF, :"`", EXPR_END, :tCOMMA, ",", EXPR_PAR,
624
+ :tBACK_REF, :"'", EXPR_END, :tCOMMA, ",", EXPR_PAR,
625
+ :tBACK_REF, :+, EXPR_END,
626
+ :tRBRACK, "]", EXPR_ENDARG)
624
627
  end
625
628
 
626
629
  def test_yylex_backslash
627
630
  assert_lex3("1 \\\n+ 2",
628
631
  nil,
629
- :tINTEGER, 1, :expr_end,
630
- :tPLUS, "+", :expr_beg,
631
- :tINTEGER, 2, :expr_end)
632
+ :tINTEGER, 1, EXPR_NUM,
633
+ :tPLUS, "+", EXPR_BEG,
634
+ :tINTEGER, 2, EXPR_NUM)
632
635
  end
633
636
 
634
637
  def test_yylex_backslash_bad
@@ -638,37 +641,37 @@ class TestRubyLexer < Minitest::Test
638
641
  def test_yylex_backtick
639
642
  assert_lex3("`ls`",
640
643
  nil,
641
- :tXSTRING_BEG, "`", :expr_beg,
642
- :tSTRING_CONTENT, "ls", :expr_beg,
643
- :tSTRING_END, "`", :expr_end)
644
+ :tXSTRING_BEG, "`", EXPR_BEG,
645
+ :tSTRING_CONTENT, "ls", EXPR_BEG,
646
+ :tSTRING_END, "`", EXPR_END)
644
647
  end
645
648
 
646
649
  def test_yylex_backtick_cmdarg
647
- self.lex_state = :expr_dot
650
+ self.lex_state = EXPR_DOT
648
651
 
649
652
  # \n ensures expr_cmd (TODO: why?)
650
- assert_lex3("\n`", nil, :tBACK_REF2, "`", :expr_cmdarg)
653
+ assert_lex3("\n`", nil, :tBACK_REF2, "`", EXPR_CMDARG)
651
654
  end
652
655
 
653
656
  def test_yylex_backtick_dot
654
- self.lex_state = :expr_dot
657
+ self.lex_state = EXPR_DOT
655
658
 
656
659
  assert_lex3("a.`(3)",
657
660
  nil,
658
- :tIDENTIFIER, "a", :expr_cmdarg,
659
- :tDOT, ".", :expr_dot,
660
- :tBACK_REF2, "`", :expr_arg,
661
- :tLPAREN2, "(", :expr_beg,
662
- :tINTEGER, 3, :expr_end,
663
- :tRPAREN, ")", :expr_endfn)
661
+ :tIDENTIFIER, "a", EXPR_CMDARG,
662
+ :tDOT, ".", EXPR_DOT,
663
+ :tBACK_REF2, "`", EXPR_ARG,
664
+ :tLPAREN2, "(", EXPR_PAR,
665
+ :tINTEGER, 3, EXPR_NUM,
666
+ :tRPAREN, ")", EXPR_ENDFN)
664
667
  end
665
668
 
666
669
  def test_yylex_backtick_method
667
- self.lex_state = :expr_fname
670
+ self.lex_state = EXPR_FNAME
668
671
 
669
672
  assert_lex3("`",
670
673
  nil,
671
- :tBACK_REF2, "`", :expr_end)
674
+ :tBACK_REF2, "`", EXPR_END)
672
675
  end
673
676
 
674
677
  def test_yylex_bad_char
@@ -676,24 +679,24 @@ class TestRubyLexer < Minitest::Test
676
679
  end
677
680
 
678
681
  def test_yylex_bang
679
- assert_lex3("!", nil, :tBANG, "!", :expr_beg)
682
+ assert_lex3("!", nil, :tBANG, "!", EXPR_BEG)
680
683
  end
681
684
 
682
685
  def test_yylex_bang_equals
683
- assert_lex3("!=", nil, :tNEQ, "!=", :expr_beg)
686
+ assert_lex3("!=", nil, :tNEQ, "!=", EXPR_BEG)
684
687
  end
685
688
 
686
689
  def test_yylex_bang_tilde
687
- assert_lex3("!~", nil, :tNMATCH, "!~", :expr_beg)
690
+ assert_lex3("!~", nil, :tNMATCH, "!~", EXPR_BEG)
688
691
  end
689
692
 
690
693
  def test_yylex_block_bug_1
691
694
  assert_lex3("a do end",
692
695
  s(:iter, s(:call, nil, :a), 0),
693
696
 
694
- :tIDENTIFIER, "a", :expr_cmdarg,
695
- :kDO, "do", :expr_beg,
696
- :kEND, "end", :expr_end)
697
+ :tIDENTIFIER, "a", EXPR_CMDARG,
698
+ :kDO, "do", EXPR_BEG,
699
+ :kEND, "end", EXPR_END)
697
700
  end
698
701
 
699
702
  def test_yylex_block_bug_2
@@ -702,70 +705,70 @@ class TestRubyLexer < Minitest::Test
702
705
  s(:lasgn, :a, s(:lit, 1)),
703
706
  s(:iter, s(:call, nil, :a), 0)),
704
707
 
705
- :tIDENTIFIER, "a", :expr_cmdarg,
706
- :tEQL, "=", :expr_beg,
707
- :tINTEGER, 1, :expr_end,
708
- :tNL, nil, :expr_beg,
709
- :tIDENTIFIER, "a", :expr_cmdarg,
710
- :kDO, "do", :expr_beg,
711
- :kEND, "end", :expr_end)
708
+ :tIDENTIFIER, "a", EXPR_CMDARG,
709
+ :tEQL, "=", EXPR_BEG,
710
+ :tINTEGER, 1, EXPR_NUM,
711
+ :tNL, nil, EXPR_BEG,
712
+ :tIDENTIFIER, "a", EXPR_CMDARG,
713
+ :kDO, "do", EXPR_BEG,
714
+ :kEND, "end", EXPR_END)
712
715
  end
713
716
 
714
717
  def test_yylex_block_bug_3
715
718
  assert_lex3("a { }",
716
719
  s(:iter, s(:call, nil, :a), 0),
717
720
 
718
- :tIDENTIFIER, "a", :expr_cmdarg, # verified
719
- :tLCURLY, "{", :expr_beg, # TODO: expr_beg|expr_label
720
- :tRCURLY, "}", :expr_endarg)
721
+ :tIDENTIFIER, "a", EXPR_CMDARG, # verified
722
+ :tLCURLY, "{", EXPR_PAR,
723
+ :tRCURLY, "}", EXPR_ENDARG)
721
724
  end
722
725
 
723
726
  def test_yylex_carat
724
- assert_lex3("^", nil, :tCARET, "^", :expr_beg)
727
+ assert_lex3("^", nil, :tCARET, "^", EXPR_BEG)
725
728
  end
726
729
 
727
730
  def test_yylex_carat_equals
728
- assert_lex3("^=", nil, :tOP_ASGN, "^", :expr_beg)
731
+ assert_lex3("^=", nil, :tOP_ASGN, "^", EXPR_BEG)
729
732
  end
730
733
 
731
734
  def test_yylex_colon2
732
735
  assert_lex3("A::B",
733
736
  nil,
734
- :tCONSTANT, "A", :expr_cmdarg,
735
- :tCOLON2, "::", :expr_dot,
736
- :tCONSTANT, "B", :expr_arg)
737
+ :tCONSTANT, "A", EXPR_CMDARG,
738
+ :tCOLON2, "::", EXPR_DOT,
739
+ :tCONSTANT, "B", EXPR_ARG)
737
740
  end
738
741
 
739
742
  def test_yylex_colon2_argh
740
743
  assert_lex3("module X::Y\n c\nend",
741
744
  nil,
742
- :kMODULE, "module", :expr_beg,
743
- :tCONSTANT, "X", :expr_cmdarg,
744
- :tCOLON2, "::", :expr_dot,
745
- :tCONSTANT, "Y", :expr_arg,
746
- :tNL, nil, :expr_beg,
747
- :tIDENTIFIER, "c", :expr_cmdarg,
748
- :tNL, nil, :expr_beg,
749
- :kEND, "end", :expr_end)
745
+ :kMODULE, "module", EXPR_BEG,
746
+ :tCONSTANT, "X", EXPR_CMDARG,
747
+ :tCOLON2, "::", EXPR_DOT,
748
+ :tCONSTANT, "Y", EXPR_ARG,
749
+ :tNL, nil, EXPR_BEG,
750
+ :tIDENTIFIER, "c", EXPR_CMDARG,
751
+ :tNL, nil, EXPR_BEG,
752
+ :kEND, "end", EXPR_END)
750
753
  end
751
754
 
752
755
  def test_yylex_colon3
753
756
  assert_lex3("::Array",
754
757
  nil,
755
- :tCOLON3, "::", :expr_beg,
756
- :tCONSTANT, "Array", :expr_arg)
758
+ :tCOLON3, "::", EXPR_BEG,
759
+ :tCONSTANT, "Array", EXPR_ARG)
757
760
  end
758
761
 
759
762
  def test_yylex_comma
760
- assert_lex3(",", nil, :tCOMMA, ",", :expr_beg)
763
+ assert_lex3(",", nil, :tCOMMA, ",", EXPR_PAR)
761
764
  end
762
765
 
763
766
  def test_yylex_comment
764
767
  assert_lex3("1 # one\n# two\n2",
765
768
  nil,
766
- :tINTEGER, 1, :expr_end,
767
- :tNL, nil, :expr_beg,
768
- :tINTEGER, 2, :expr_end)
769
+ :tINTEGER, 1, EXPR_NUM,
770
+ :tNL, nil, EXPR_BEG,
771
+ :tINTEGER, 2, EXPR_NUM)
769
772
 
770
773
  assert_equal "# one\n# two\n", @lex.comments
771
774
  end
@@ -773,7 +776,7 @@ class TestRubyLexer < Minitest::Test
773
776
  def test_yylex_comment_begin
774
777
  assert_lex3("=begin\nblah\nblah\n=end\n42",
775
778
  nil,
776
- :tINTEGER, 42, :expr_end)
779
+ :tINTEGER, 42, EXPR_NUM)
777
780
 
778
781
  assert_equal "=begin\nblah\nblah\n=end\n", @lex.comments
779
782
  end
@@ -787,14 +790,14 @@ class TestRubyLexer < Minitest::Test
787
790
  def test_yylex_comment_begin_not_comment
788
791
  assert_lex3("beginfoo = 5\np x \\\n=beginfoo",
789
792
  nil,
790
- :tIDENTIFIER, "beginfoo", :expr_cmdarg,
791
- :tEQL, "=", :expr_beg,
792
- :tINTEGER, 5, :expr_end,
793
- :tNL, nil, :expr_beg,
794
- :tIDENTIFIER, "p", :expr_cmdarg,
795
- :tIDENTIFIER, "x", :expr_arg,
796
- :tEQL, "=", :expr_beg,
797
- :tIDENTIFIER, "beginfoo", :expr_arg)
793
+ :tIDENTIFIER, "beginfoo", EXPR_CMDARG,
794
+ :tEQL, "=", EXPR_BEG,
795
+ :tINTEGER, 5, EXPR_NUM,
796
+ :tNL, nil, EXPR_BEG,
797
+ :tIDENTIFIER, "p", EXPR_CMDARG,
798
+ :tIDENTIFIER, "x", EXPR_ARG,
799
+ :tEQL, "=", EXPR_BEG,
800
+ :tIDENTIFIER, "beginfoo", EXPR_ARG)
798
801
  end
799
802
 
800
803
  def test_yylex_comment_begin_space
@@ -814,18 +817,18 @@ class TestRubyLexer < Minitest::Test
814
817
  end
815
818
 
816
819
  def test_yylex_constant
817
- assert_lex3("ArgumentError", nil, :tCONSTANT, "ArgumentError", :expr_cmdarg)
820
+ assert_lex3("ArgumentError", nil, :tCONSTANT, "ArgumentError", EXPR_CMDARG)
818
821
  end
819
822
 
820
823
  def test_yylex_constant_semi
821
824
  assert_lex3("ArgumentError;",
822
825
  nil,
823
- :tCONSTANT, "ArgumentError", :expr_cmdarg,
824
- :tSEMI, ";", :expr_beg)
826
+ :tCONSTANT, "ArgumentError", EXPR_CMDARG,
827
+ :tSEMI, ";", EXPR_BEG)
825
828
  end
826
829
 
827
830
  def test_yylex_cvar
828
- assert_lex3("@@blah", nil, :tCVAR, "@@blah", :expr_end)
831
+ assert_lex3("@@blah", nil, :tCVAR, "@@blah", EXPR_END)
829
832
  end
830
833
 
831
834
  def test_yylex_cvar_bad
@@ -835,75 +838,75 @@ class TestRubyLexer < Minitest::Test
835
838
  end
836
839
 
837
840
  def test_yylex_def_bad_name
838
- self.lex_state = :expr_fname
841
+ self.lex_state = EXPR_FNAME
839
842
  refute_lex("def [ ", :kDEF, "def")
840
843
  end
841
844
 
842
845
  def test_yylex_div
843
846
  assert_lex3("a / 2",
844
847
  nil,
845
- :tIDENTIFIER, "a", :expr_cmdarg,
846
- :tDIVIDE, "/", :expr_beg,
847
- :tINTEGER, 2, :expr_end)
848
+ :tIDENTIFIER, "a", EXPR_CMDARG,
849
+ :tDIVIDE, "/", EXPR_BEG,
850
+ :tINTEGER, 2, EXPR_NUM)
848
851
  end
849
852
 
850
853
  def test_yylex_div_equals
851
854
  assert_lex3("a /= 2",
852
855
  nil,
853
- :tIDENTIFIER, "a", :expr_cmdarg,
854
- :tOP_ASGN, "/", :expr_beg,
855
- :tINTEGER, 2, :expr_end)
856
+ :tIDENTIFIER, "a", EXPR_CMDARG,
857
+ :tOP_ASGN, "/", EXPR_BEG,
858
+ :tINTEGER, 2, EXPR_NUM)
856
859
  end
857
860
 
858
861
  def test_yylex_do
859
862
  assert_lex3("x do 42 end",
860
863
  nil,
861
- :tIDENTIFIER, "x", :expr_cmdarg,
862
- :kDO, "do", :expr_beg,
863
- :tINTEGER, 42, :expr_end,
864
- :kEND, "end", :expr_end)
864
+ :tIDENTIFIER, "x", EXPR_CMDARG,
865
+ :kDO, "do", EXPR_BEG,
866
+ :tINTEGER, 42, EXPR_NUM,
867
+ :kEND, "end", EXPR_END)
865
868
  end
866
869
 
867
870
  def test_yylex_do_block
868
- self.lex_state = :expr_endarg
871
+ self.lex_state = EXPR_ENDARG
869
872
 
870
873
  assert_lex3("x.y do 42 end",
871
874
  nil,
872
- :tIDENTIFIER, "x", :expr_end,
873
- :tDOT, ".", :expr_dot,
874
- :tIDENTIFIER, "y", :expr_arg,
875
- :kDO_BLOCK, "do", :expr_beg,
876
- :tINTEGER, 42, :expr_end,
877
- :kEND, "end", :expr_end) do
875
+ :tIDENTIFIER, "x", EXPR_END,
876
+ :tDOT, ".", EXPR_DOT,
877
+ :tIDENTIFIER, "y", EXPR_ARG,
878
+ :kDO_BLOCK, "do", EXPR_BEG,
879
+ :tINTEGER, 42, EXPR_NUM,
880
+ :kEND, "end", EXPR_END) do
878
881
  @lex.cmdarg.push true
879
882
  end
880
883
  end
881
884
 
882
885
  def test_yylex_do_block2
883
- self.lex_state = :expr_endarg
886
+ self.lex_state = EXPR_ENDARG
884
887
 
885
888
  assert_lex3("do 42 end",
886
889
  nil,
887
- :kDO_BLOCK, "do", :expr_beg,
888
- :tINTEGER, 42, :expr_end,
889
- :kEND, "end", :expr_end)
890
+ :kDO_BLOCK, "do", EXPR_BEG,
891
+ :tINTEGER, 42, EXPR_NUM,
892
+ :kEND, "end", EXPR_END)
890
893
  end
891
894
 
892
895
  def test_yylex_is_your_spacebar_broken?
893
896
  assert_lex3(":a!=:b",
894
897
  nil,
895
- :tSYMBOL, "a", :expr_end,
896
- :tNEQ, "!=", :expr_beg,
897
- :tSYMBOL, "b", :expr_end)
898
+ :tSYMBOL, "a", EXPR_END,
899
+ :tNEQ, "!=", EXPR_BEG,
900
+ :tSYMBOL, "b", EXPR_END)
898
901
  end
899
902
 
900
903
  def test_yylex_do_cond
901
904
  assert_lex3("x do 42 end",
902
905
  nil,
903
- :tIDENTIFIER, "x", :expr_cmdarg,
904
- :kDO_COND, "do", :expr_beg,
905
- :tINTEGER, 42, :expr_end,
906
- :kEND, "end", :expr_end) do
906
+ :tIDENTIFIER, "x", EXPR_CMDARG,
907
+ :kDO_COND, "do", EXPR_BEG,
908
+ :tINTEGER, 42, EXPR_NUM,
909
+ :kEND, "end", EXPR_END) do
907
910
  @lex.cond.push true
908
911
  end
909
912
  end
@@ -914,40 +917,40 @@ class TestRubyLexer < Minitest::Test
914
917
  end
915
918
 
916
919
  def test_yylex_dollar_eos
917
- assert_lex3("$", nil, "$", "$", :expr_end) # FIX: wtf is this?!?
920
+ assert_lex3("$", nil, "$", "$", EXPR_END) # FIX: wtf is this?!?
918
921
  end
919
922
 
920
923
  def test_yylex_dot # HINT message sends
921
- assert_lex3(".", nil, :tDOT, ".", :expr_dot)
924
+ assert_lex3(".", nil, :tDOT, ".", EXPR_DOT)
922
925
  end
923
926
 
924
927
  def test_yylex_dot2
925
- assert_lex3("..", nil, :tDOT2, "..", :expr_beg)
928
+ assert_lex3("..", nil, :tDOT2, "..", EXPR_BEG)
926
929
  end
927
930
 
928
931
  def test_yylex_dot3
929
- assert_lex3("...", nil, :tDOT3, "...", :expr_beg)
932
+ assert_lex3("...", nil, :tDOT3, "...", EXPR_BEG)
930
933
  end
931
934
 
932
935
  def test_yylex_equals
933
936
  # FIX: this sucks
934
- assert_lex3("=", nil, :tEQL, "=", :expr_beg)
937
+ assert_lex3("=", nil, :tEQL, "=", EXPR_BEG)
935
938
  end
936
939
 
937
940
  def test_yylex_equals2
938
- assert_lex3("==", nil, :tEQ, "==", :expr_beg)
941
+ assert_lex3("==", nil, :tEQ, "==", EXPR_BEG)
939
942
  end
940
943
 
941
944
  def test_yylex_equals3
942
- assert_lex3("===", nil, :tEQQ, "===", :expr_beg)
945
+ assert_lex3("===", nil, :tEQQ, "===", EXPR_BEG)
943
946
  end
944
947
 
945
948
  def test_yylex_equals_tilde
946
- assert_lex3("=~", nil, :tMATCH, "=~", :expr_beg)
949
+ assert_lex3("=~", nil, :tMATCH, "=~", EXPR_BEG)
947
950
  end
948
951
 
949
952
  def test_yylex_float
950
- assert_lex3("1.0", nil, :tFLOAT, 1.0, :expr_end)
953
+ assert_lex3("1.0", nil, :tFLOAT, 1.0, EXPR_NUM)
951
954
  end
952
955
 
953
956
  def test_yylex_float_bad_no_underscores
@@ -965,55 +968,55 @@ class TestRubyLexer < Minitest::Test
965
968
  def test_yylex_float_call
966
969
  assert_lex3("1.0.to_s",
967
970
  nil,
968
- :tFLOAT, 1.0, :expr_end,
969
- :tDOT, ".", :expr_dot,
970
- :tIDENTIFIER, "to_s", :expr_arg)
971
+ :tFLOAT, 1.0, EXPR_NUM,
972
+ :tDOT, ".", EXPR_DOT,
973
+ :tIDENTIFIER, "to_s", EXPR_ARG)
971
974
  end
972
975
 
973
976
  def test_yylex_float_dot_E
974
977
  assert_lex3("1.0E10",
975
978
  nil,
976
- :tFLOAT, 10000000000.0, :expr_end)
979
+ :tFLOAT, 10000000000.0, EXPR_NUM)
977
980
  end
978
981
 
979
982
  def test_yylex_float_dot_E_neg
980
983
  assert_lex3("-1.0E10",
981
984
  nil,
982
- :tUMINUS_NUM, "-", :expr_beg,
983
- :tFLOAT, 10000000000.0, :expr_end)
985
+ :tUMINUS_NUM, "-", EXPR_BEG,
986
+ :tFLOAT, 10000000000.0, EXPR_NUM)
984
987
  end
985
988
 
986
989
  def test_yylex_float_dot_e
987
990
  assert_lex3("1.0e10",
988
991
  nil,
989
- :tFLOAT, 10000000000.0, :expr_end)
992
+ :tFLOAT, 10000000000.0, EXPR_NUM)
990
993
  end
991
994
 
992
995
  def test_yylex_float_dot_e_neg
993
996
  assert_lex3("-1.0e10",
994
997
  nil,
995
- :tUMINUS_NUM, "-", :expr_beg,
996
- :tFLOAT, 10000000000.0, :expr_end)
998
+ :tUMINUS_NUM, "-", EXPR_BEG,
999
+ :tFLOAT, 10000000000.0, EXPR_NUM)
997
1000
  end
998
1001
 
999
1002
  def test_yylex_float_e
1000
1003
  assert_lex3("1e10",
1001
1004
  nil,
1002
- :tFLOAT, 10000000000.0, :expr_end)
1005
+ :tFLOAT, 10000000000.0, EXPR_NUM)
1003
1006
  end
1004
1007
 
1005
1008
  def test_yylex_float_e_bad_double_e
1006
1009
  assert_lex3("1e2e3",
1007
1010
  nil,
1008
- :tFLOAT, 100, :expr_end,
1009
- :tIDENTIFIER, "e3", :expr_end)
1011
+ :tFLOAT, 100, EXPR_NUM,
1012
+ :tIDENTIFIER, "e3", EXPR_END)
1010
1013
  end
1011
1014
 
1012
1015
  def test_yylex_float_if_modifier
1013
1016
  assert_lex3("1e2if",
1014
1017
  nil,
1015
- :tFLOAT, 100, :expr_end,
1016
- :kIF_MOD, "if", :expr_beg)
1018
+ :tFLOAT, 100, EXPR_NUM,
1019
+ :kIF_MOD, "if", EXPR_PAR)
1017
1020
  end
1018
1021
 
1019
1022
  def test_yylex_float_e_bad_trailing_underscore
@@ -1021,157 +1024,157 @@ class TestRubyLexer < Minitest::Test
1021
1024
  end
1022
1025
 
1023
1026
  def test_yylex_float_e_minus
1024
- assert_lex3("1e-10", nil, :tFLOAT, 1.0e-10, :expr_end)
1027
+ assert_lex3("1e-10", nil, :tFLOAT, 1.0e-10, EXPR_NUM)
1025
1028
  end
1026
1029
 
1027
1030
  def test_yylex_float_e_neg
1028
1031
  assert_lex3("-1e10",
1029
1032
  nil,
1030
- :tUMINUS_NUM, "-", :expr_beg,
1031
- :tFLOAT, 10000000000.0, :expr_end)
1033
+ :tUMINUS_NUM, "-", EXPR_BEG,
1034
+ :tFLOAT, 10000000000.0, EXPR_NUM)
1032
1035
  end
1033
1036
 
1034
1037
  def test_yylex_float_e_neg_minus
1035
1038
  assert_lex3("-1e-10",
1036
1039
  nil,
1037
- :tUMINUS_NUM, "-", :expr_beg,
1038
- :tFLOAT, 1.0e-10, :expr_end)
1040
+ :tUMINUS_NUM, "-", EXPR_BEG,
1041
+ :tFLOAT, 1.0e-10, EXPR_NUM)
1039
1042
  end
1040
1043
 
1041
1044
  def test_yylex_float_e_neg_plus
1042
1045
  assert_lex3("-1e+10",
1043
1046
  nil,
1044
- :tUMINUS_NUM, "-", :expr_beg,
1045
- :tFLOAT, 10000000000.0, :expr_end)
1047
+ :tUMINUS_NUM, "-", EXPR_BEG,
1048
+ :tFLOAT, 10000000000.0, EXPR_NUM)
1046
1049
  end
1047
1050
 
1048
1051
  def test_yylex_float_e_plus
1049
- assert_lex3("1e+10", nil, :tFLOAT, 10000000000.0, :expr_end)
1052
+ assert_lex3("1e+10", nil, :tFLOAT, 10000000000.0, EXPR_NUM)
1050
1053
  end
1051
1054
 
1052
1055
  def test_yylex_float_e_zero
1053
- assert_lex3("0e0", nil, :tFLOAT, 0.0, :expr_end)
1056
+ assert_lex3("0e0", nil, :tFLOAT, 0.0, EXPR_NUM)
1054
1057
  end
1055
1058
 
1056
1059
  def test_yylex_float_neg
1057
1060
  assert_lex3("-1.0",
1058
1061
  nil,
1059
- :tUMINUS_NUM, "-", :expr_beg,
1060
- :tFLOAT, 1.0, :expr_end)
1062
+ :tUMINUS_NUM, "-", EXPR_BEG,
1063
+ :tFLOAT, 1.0, EXPR_NUM)
1061
1064
  end
1062
1065
 
1063
1066
  def test_yylex_ge
1064
1067
  assert_lex3("a >= 2",
1065
1068
  nil,
1066
- :tIDENTIFIER, "a", :expr_cmdarg,
1067
- :tGEQ, ">=", :expr_beg,
1068
- :tINTEGER, 2, :expr_end)
1069
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1070
+ :tGEQ, ">=", EXPR_BEG,
1071
+ :tINTEGER, 2, EXPR_NUM)
1069
1072
  end
1070
1073
 
1071
1074
  def test_yylex_global
1072
- assert_lex3("$blah", nil, :tGVAR, "$blah", :expr_end)
1075
+ assert_lex3("$blah", nil, :tGVAR, "$blah", EXPR_END)
1073
1076
  end
1074
1077
 
1075
1078
  def test_yylex_global_backref
1076
- self.lex_state = :expr_fname
1079
+ self.lex_state = EXPR_FNAME
1077
1080
 
1078
- assert_lex3("$`", nil, :tGVAR, "$`", :expr_end)
1081
+ assert_lex3("$`", nil, :tGVAR, "$`", EXPR_END)
1079
1082
  end
1080
1083
 
1081
1084
  def test_yylex_global_dash_nothing
1082
- assert_lex3("$- ", nil, :tGVAR, "$-", :expr_end)
1085
+ assert_lex3("$- ", nil, :tGVAR, "$-", EXPR_END)
1083
1086
  end
1084
1087
 
1085
1088
  def test_yylex_global_dash_something
1086
- assert_lex3("$-x", nil, :tGVAR, "$-x", :expr_end)
1089
+ assert_lex3("$-x", nil, :tGVAR, "$-x", EXPR_END)
1087
1090
  end
1088
1091
 
1089
1092
  def test_yylex_global_number
1090
- self.lex_state = :expr_fname
1093
+ self.lex_state = EXPR_FNAME
1091
1094
 
1092
- assert_lex3("$1", nil, :tGVAR, "$1", :expr_end)
1095
+ assert_lex3("$1", nil, :tGVAR, "$1", EXPR_END)
1093
1096
  end
1094
1097
 
1095
1098
  def test_yylex_global_number_big
1096
- self.lex_state = :expr_fname
1099
+ self.lex_state = EXPR_FNAME
1097
1100
 
1098
- assert_lex3("$1234", nil, :tGVAR, "$1234", :expr_end)
1101
+ assert_lex3("$1234", nil, :tGVAR, "$1234", EXPR_END)
1099
1102
  end
1100
1103
 
1101
1104
  def test_yylex_global_other
1102
1105
  assert_lex3("[$~, $*, $$, $?, $!, $@, $/, $\\, $;, $,, $., $=, $:, $<, $>, $\"]",
1103
1106
  nil,
1104
- :tLBRACK, "[", :expr_beg,
1105
- :tGVAR, "$~", :expr_end, :tCOMMA, ",", :expr_beg,
1106
- :tGVAR, "$*", :expr_end, :tCOMMA, ",", :expr_beg,
1107
- :tGVAR, "$$", :expr_end, :tCOMMA, ",", :expr_beg,
1108
- :tGVAR, "$?", :expr_end, :tCOMMA, ",", :expr_beg,
1109
- :tGVAR, "$!", :expr_end, :tCOMMA, ",", :expr_beg,
1110
- :tGVAR, "$@", :expr_end, :tCOMMA, ",", :expr_beg,
1111
- :tGVAR, "$/", :expr_end, :tCOMMA, ",", :expr_beg,
1112
- :tGVAR, "$\\", :expr_end, :tCOMMA, ",", :expr_beg,
1113
- :tGVAR, "$;", :expr_end, :tCOMMA, ",", :expr_beg,
1114
- :tGVAR, "$,", :expr_end, :tCOMMA, ",", :expr_beg,
1115
- :tGVAR, "$.", :expr_end, :tCOMMA, ",", :expr_beg,
1116
- :tGVAR, "$=", :expr_end, :tCOMMA, ",", :expr_beg,
1117
- :tGVAR, "$:", :expr_end, :tCOMMA, ",", :expr_beg,
1118
- :tGVAR, "$<", :expr_end, :tCOMMA, ",", :expr_beg,
1119
- :tGVAR, "$>", :expr_end, :tCOMMA, ",", :expr_beg,
1120
- :tGVAR, "$\"", :expr_end,
1121
- :tRBRACK, "]", :expr_endarg)
1107
+ :tLBRACK, "[", EXPR_PAR,
1108
+ :tGVAR, "$~", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1109
+ :tGVAR, "$*", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1110
+ :tGVAR, "$$", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1111
+ :tGVAR, "$?", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1112
+ :tGVAR, "$!", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1113
+ :tGVAR, "$@", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1114
+ :tGVAR, "$/", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1115
+ :tGVAR, "$\\", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1116
+ :tGVAR, "$;", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1117
+ :tGVAR, "$,", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1118
+ :tGVAR, "$.", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1119
+ :tGVAR, "$=", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1120
+ :tGVAR, "$:", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1121
+ :tGVAR, "$<", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1122
+ :tGVAR, "$>", EXPR_END, :tCOMMA, ",", EXPR_PAR,
1123
+ :tGVAR, "$\"", EXPR_END,
1124
+ :tRBRACK, "]", EXPR_ENDARG)
1122
1125
  end
1123
1126
 
1124
1127
  def test_yylex_global_underscore
1125
- assert_lex3("$_", nil, :tGVAR, "$_", :expr_end)
1128
+ assert_lex3("$_", nil, :tGVAR, "$_", EXPR_END)
1126
1129
  end
1127
1130
 
1128
1131
  def test_yylex_global_wierd
1129
- assert_lex3("$__blah", nil, :tGVAR, "$__blah", :expr_end)
1132
+ assert_lex3("$__blah", nil, :tGVAR, "$__blah", EXPR_END)
1130
1133
  end
1131
1134
 
1132
1135
  def test_yylex_global_zero
1133
- assert_lex3("$0", nil, :tGVAR, "$0", :expr_end)
1136
+ assert_lex3("$0", nil, :tGVAR, "$0", EXPR_END)
1134
1137
  end
1135
1138
 
1136
1139
  def test_yylex_gt
1137
1140
  assert_lex3("a > 2",
1138
1141
  nil,
1139
- :tIDENTIFIER, "a", :expr_cmdarg,
1140
- :tGT, ">", :expr_beg,
1141
- :tINTEGER, 2, :expr_end)
1142
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1143
+ :tGT, ">", EXPR_BEG,
1144
+ :tINTEGER, 2, EXPR_NUM)
1142
1145
  end
1143
1146
 
1144
1147
  def test_yylex_heredoc_backtick
1145
1148
  assert_lex3("a = <<`EOF`\n blah blah\nEOF\n\n",
1146
1149
  nil,
1147
- :tIDENTIFIER, "a", :expr_cmdarg,
1148
- :tEQL, "=", :expr_beg,
1149
- :tXSTRING_BEG, "`", :expr_beg,
1150
- :tSTRING_CONTENT, " blah blah\n", :expr_beg,
1151
- :tSTRING_END, "EOF", :expr_end,
1152
- :tNL, nil, :expr_beg)
1150
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1151
+ :tEQL, "=", EXPR_BEG,
1152
+ :tXSTRING_BEG, "`", EXPR_BEG,
1153
+ :tSTRING_CONTENT, " blah blah\n", EXPR_BEG,
1154
+ :tSTRING_END, "EOF", EXPR_END,
1155
+ :tNL, nil, EXPR_BEG)
1153
1156
  end
1154
1157
 
1155
1158
  def test_yylex_heredoc_double
1156
1159
  assert_lex3("a = <<\"EOF\"\n blah blah\nEOF\n\n",
1157
1160
  nil,
1158
- :tIDENTIFIER, "a", :expr_cmdarg,
1159
- :tEQL, "=", :expr_beg,
1160
- :tSTRING_BEG, "\"", :expr_beg,
1161
- :tSTRING_CONTENT, " blah blah\n", :expr_beg,
1162
- :tSTRING_END, "EOF", :expr_end,
1163
- :tNL, nil, :expr_beg)
1161
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1162
+ :tEQL, "=", EXPR_BEG,
1163
+ :tSTRING_BEG, "\"", EXPR_BEG,
1164
+ :tSTRING_CONTENT, " blah blah\n", EXPR_BEG,
1165
+ :tSTRING_END, "EOF", EXPR_END,
1166
+ :tNL, nil, EXPR_BEG)
1164
1167
  end
1165
1168
 
1166
1169
  def test_yylex_heredoc_double_dash
1167
1170
  assert_lex3("a = <<-\"EOF\"\n blah blah\n EOF\n\n",
1168
1171
  nil,
1169
- :tIDENTIFIER, "a", :expr_cmdarg,
1170
- :tEQL, "=", :expr_beg,
1171
- :tSTRING_BEG, "\"", :expr_beg,
1172
- :tSTRING_CONTENT, " blah blah\n", :expr_beg,
1173
- :tSTRING_END, "EOF", :expr_end,
1174
- :tNL, nil, :expr_beg)
1172
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1173
+ :tEQL, "=", EXPR_BEG,
1174
+ :tSTRING_BEG, "\"", EXPR_BEG,
1175
+ :tSTRING_CONTENT, " blah blah\n", EXPR_BEG,
1176
+ :tSTRING_END, "EOF", EXPR_END,
1177
+ :tNL, nil, EXPR_BEG)
1175
1178
  end
1176
1179
 
1177
1180
  def test_yylex_heredoc_double_squiggly
@@ -1179,12 +1182,12 @@ class TestRubyLexer < Minitest::Test
1179
1182
 
1180
1183
  assert_lex3("a = <<~\"EOF\"\n blah blah\n EOF\n\n",
1181
1184
  nil,
1182
- :tIDENTIFIER, "a", :expr_cmdarg,
1183
- :tEQL, "=", :expr_beg,
1184
- :tSTRING_BEG, "\"", :expr_beg,
1185
- :tSTRING_CONTENT, "blah blah\n", :expr_beg,
1186
- :tSTRING_END, "EOF", :expr_end,
1187
- :tNL, nil, :expr_beg)
1185
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1186
+ :tEQL, "=", EXPR_BEG,
1187
+ :tSTRING_BEG, "\"", EXPR_BEG,
1188
+ :tSTRING_CONTENT, "blah blah\n", EXPR_BEG,
1189
+ :tSTRING_END, "EOF", EXPR_END,
1190
+ :tNL, nil, EXPR_BEG)
1188
1191
  end
1189
1192
 
1190
1193
  # mri handles tabs in a pretty specific way:
@@ -1194,12 +1197,12 @@ class TestRubyLexer < Minitest::Test
1194
1197
 
1195
1198
  assert_lex3("a = <<~\"EOF\"\n blah blah\n \tblah blah\n EOF\n\n",
1196
1199
  nil,
1197
- :tIDENTIFIER, "a", :expr_cmdarg,
1198
- :tEQL, "=", :expr_beg,
1199
- :tSTRING_BEG, "\"", :expr_beg,
1200
- :tSTRING_CONTENT, "blah blah\n\tblah blah\n", :expr_beg,
1201
- :tSTRING_END, "EOF", :expr_end,
1202
- :tNL, nil, :expr_beg)
1200
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1201
+ :tEQL, "=", EXPR_BEG,
1202
+ :tSTRING_BEG, "\"", EXPR_BEG,
1203
+ :tSTRING_CONTENT, "blah blah\n\tblah blah\n", EXPR_BEG,
1204
+ :tSTRING_END, "EOF", EXPR_END,
1205
+ :tNL, nil, EXPR_BEG)
1203
1206
  end
1204
1207
 
1205
1208
  def test_yylex_heredoc_double_squiggly_with_tab_indentation_removed
@@ -1207,12 +1210,12 @@ class TestRubyLexer < Minitest::Test
1207
1210
 
1208
1211
  assert_lex3("a = <<~\"EOF\"\n blah blah\n\t blah blah\n EOF\n\n",
1209
1212
  nil,
1210
- :tIDENTIFIER, "a", :expr_cmdarg,
1211
- :tEQL, "=", :expr_beg,
1212
- :tSTRING_BEG, "\"", :expr_beg,
1213
- :tSTRING_CONTENT, "blah blah\n blah blah\n", :expr_beg,
1214
- :tSTRING_END, "EOF", :expr_end,
1215
- :tNL, nil, :expr_beg)
1213
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1214
+ :tEQL, "=", EXPR_BEG,
1215
+ :tSTRING_BEG, "\"", EXPR_BEG,
1216
+ :tSTRING_CONTENT, "blah blah\n blah blah\n", EXPR_BEG,
1217
+ :tSTRING_END, "EOF", EXPR_END,
1218
+ :tNL, nil, EXPR_BEG)
1216
1219
  end
1217
1220
 
1218
1221
  def test_yylex_heredoc_double_eos
@@ -1230,41 +1233,43 @@ class TestRubyLexer < Minitest::Test
1230
1233
  end
1231
1234
 
1232
1235
  def test_yylex_heredoc_double_interp
1233
- assert_lex3("a = <<\"EOF\"\n#x a \#@a b \#$b c \#{3} \nEOF\n\n",
1234
- nil,
1235
- :tIDENTIFIER, "a", :expr_cmdarg,
1236
- :tEQL, "=", :expr_beg,
1237
- :tSTRING_BEG, "\"", :expr_beg,
1238
- :tSTRING_CONTENT, "#x a ", :expr_beg,
1239
- :tSTRING_DVAR, "\#@", :expr_beg,
1240
- :tSTRING_CONTENT, "@a b ", :expr_beg, # HUH?
1241
- :tSTRING_DVAR, "\#$", :expr_beg,
1242
- :tSTRING_CONTENT, "$b c ", :expr_beg, # HUH?
1243
- :tSTRING_DBEG, "\#{", :expr_beg,
1244
- :tSTRING_CONTENT, "3} \n", :expr_beg, # HUH?
1245
- :tSTRING_END, "EOF", :expr_end,
1246
- :tNL, nil, :expr_beg)
1236
+ assert_lex3("a = <<\"EOF\"\n#x a \#@a b \#$b c \#@@d \#{3} \nEOF\n\n",
1237
+ nil,
1238
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1239
+ :tEQL, "=", EXPR_BEG,
1240
+ :tSTRING_BEG, "\"", EXPR_BEG,
1241
+ :tSTRING_CONTENT, "#x a ", EXPR_BEG,
1242
+ :tSTRING_DVAR, "\#@", EXPR_BEG,
1243
+ :tSTRING_CONTENT, "@a b ", EXPR_BEG, # HUH?
1244
+ :tSTRING_DVAR, "\#$", EXPR_BEG,
1245
+ :tSTRING_CONTENT, "$b c ", EXPR_BEG, # HUH?
1246
+ :tSTRING_DVAR, "\#@", EXPR_BEG,
1247
+ :tSTRING_CONTENT, "@@d ", EXPR_BEG, # HUH?
1248
+ :tSTRING_DBEG, "\#{", EXPR_BEG,
1249
+ :tSTRING_CONTENT, "3} \n", EXPR_BEG,
1250
+ :tSTRING_END, "EOF", EXPR_END,
1251
+ :tNL, nil, EXPR_BEG)
1247
1252
  end
1248
1253
 
1249
1254
  def test_yylex_heredoc_empty
1250
1255
  assert_lex3("<<\"\"\n\#{x}\nblah2\n\n\n",
1251
1256
  nil,
1252
- :tSTRING_BEG, "\"", :expr_beg,
1253
- :tSTRING_DBEG, "\#{", :expr_beg,
1254
- :tSTRING_CONTENT, "x}\nblah2\n", :expr_beg,
1255
- :tSTRING_END, "", :expr_end,
1256
- :tNL, nil, :expr_beg)
1257
+ :tSTRING_BEG, "\"", EXPR_BEG,
1258
+ :tSTRING_DBEG, "\#{", EXPR_BEG,
1259
+ :tSTRING_CONTENT, "x}\nblah2\n", EXPR_BEG,
1260
+ :tSTRING_END, "", EXPR_END,
1261
+ :tNL, nil, EXPR_BEG)
1257
1262
  end
1258
1263
 
1259
1264
  def test_yylex_heredoc_none
1260
1265
  assert_lex3("a = <<EOF\nblah\nblah\nEOF\n",
1261
1266
  nil,
1262
- :tIDENTIFIER, "a", :expr_cmdarg,
1263
- :tEQL, "=", :expr_beg,
1264
- :tSTRING_BEG, "\"", :expr_beg,
1265
- :tSTRING_CONTENT, "blah\nblah\n", :expr_beg,
1266
- :tSTRING_END, "EOF", :expr_end,
1267
- :tNL, nil, :expr_beg)
1267
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1268
+ :tEQL, "=", EXPR_BEG,
1269
+ :tSTRING_BEG, "\"", EXPR_BEG,
1270
+ :tSTRING_CONTENT, "blah\nblah\n", EXPR_BEG,
1271
+ :tSTRING_END, "EOF", EXPR_END,
1272
+ :tNL, nil, EXPR_BEG)
1268
1273
  end
1269
1274
 
1270
1275
  def test_yylex_heredoc_none_bad_eos
@@ -1277,12 +1282,12 @@ class TestRubyLexer < Minitest::Test
1277
1282
  def test_yylex_heredoc_none_dash
1278
1283
  assert_lex3("a = <<-EOF\nblah\nblah\n EOF\n",
1279
1284
  nil,
1280
- :tIDENTIFIER, "a", :expr_cmdarg,
1281
- :tEQL, "=", :expr_beg,
1282
- :tSTRING_BEG, "\"", :expr_beg,
1283
- :tSTRING_CONTENT, "blah\nblah\n", :expr_beg,
1284
- :tSTRING_END, "EOF", :expr_end,
1285
- :tNL, nil, :expr_beg)
1285
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1286
+ :tEQL, "=", EXPR_BEG,
1287
+ :tSTRING_BEG, "\"", EXPR_BEG,
1288
+ :tSTRING_CONTENT, "blah\nblah\n", EXPR_BEG,
1289
+ :tSTRING_END, "EOF", EXPR_END,
1290
+ :tNL, nil, EXPR_BEG)
1286
1291
  end
1287
1292
 
1288
1293
  def test_yylex_heredoc_none_squiggly
@@ -1290,23 +1295,23 @@ class TestRubyLexer < Minitest::Test
1290
1295
 
1291
1296
  assert_lex3("a = <<~EOF\n blah\n blah\n EOF\n",
1292
1297
  nil,
1293
- :tIDENTIFIER, "a", :expr_cmdarg,
1294
- :tEQL, "=", :expr_beg,
1295
- :tSTRING_BEG, "\"", :expr_beg,
1296
- :tSTRING_CONTENT, "blah\nblah\n", :expr_beg,
1297
- :tSTRING_END, "EOF", :expr_end,
1298
- :tNL, nil, :expr_beg)
1298
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1299
+ :tEQL, "=", EXPR_BEG,
1300
+ :tSTRING_BEG, "\"", EXPR_BEG,
1301
+ :tSTRING_CONTENT, "blah\nblah\n", EXPR_BEG,
1302
+ :tSTRING_END, "EOF", EXPR_END,
1303
+ :tNL, nil, EXPR_BEG)
1299
1304
  end
1300
1305
 
1301
1306
  def test_yylex_heredoc_single
1302
1307
  assert_lex3("a = <<'EOF'\n blah blah\nEOF\n\n",
1303
1308
  nil,
1304
- :tIDENTIFIER, "a", :expr_cmdarg,
1305
- :tEQL, "=", :expr_beg,
1306
- :tSTRING_BEG, "\"", :expr_beg,
1307
- :tSTRING_CONTENT, " blah blah\n", :expr_beg,
1308
- :tSTRING_END, "EOF", :expr_end,
1309
- :tNL, nil, :expr_beg)
1309
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1310
+ :tEQL, "=", EXPR_BEG,
1311
+ :tSTRING_BEG, "\"", EXPR_BEG,
1312
+ :tSTRING_CONTENT, " blah blah\n", EXPR_BEG,
1313
+ :tSTRING_END, "EOF", EXPR_END,
1314
+ :tNL, nil, EXPR_BEG)
1310
1315
  end
1311
1316
 
1312
1317
  def test_yylex_heredoc_single_bad_eos_body
@@ -1340,12 +1345,12 @@ class TestRubyLexer < Minitest::Test
1340
1345
  def test_yylex_heredoc_single_dash
1341
1346
  assert_lex3("a = <<-'EOF'\n blah blah\n EOF\n\n",
1342
1347
  nil,
1343
- :tIDENTIFIER, "a", :expr_cmdarg,
1344
- :tEQL, "=", :expr_beg,
1345
- :tSTRING_BEG, "\"", :expr_beg,
1346
- :tSTRING_CONTENT, " blah blah\n", :expr_beg,
1347
- :tSTRING_END, "EOF", :expr_end,
1348
- :tNL, nil, :expr_beg)
1348
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1349
+ :tEQL, "=", EXPR_BEG,
1350
+ :tSTRING_BEG, "\"", EXPR_BEG,
1351
+ :tSTRING_CONTENT, " blah blah\n", EXPR_BEG,
1352
+ :tSTRING_END, "EOF", EXPR_END,
1353
+ :tNL, nil, EXPR_BEG)
1349
1354
  end
1350
1355
 
1351
1356
  def test_yylex_heredoc_single_squiggly
@@ -1353,24 +1358,24 @@ class TestRubyLexer < Minitest::Test
1353
1358
 
1354
1359
  assert_lex3("a = <<~'EOF'\n blah blah\n EOF\n\n",
1355
1360
  nil,
1356
- :tIDENTIFIER, "a", :expr_cmdarg,
1357
- :tEQL, "=", :expr_beg,
1358
- :tSTRING_BEG, "\"", :expr_beg,
1359
- :tSTRING_CONTENT, "blah blah\n", :expr_beg,
1360
- :tSTRING_END, "EOF", :expr_end,
1361
- :tNL, nil, :expr_beg)
1361
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1362
+ :tEQL, "=", EXPR_BEG,
1363
+ :tSTRING_BEG, "\"", EXPR_BEG,
1364
+ :tSTRING_CONTENT, "blah blah\n", EXPR_BEG,
1365
+ :tSTRING_END, "EOF", EXPR_END,
1366
+ :tNL, nil, EXPR_BEG)
1362
1367
  end
1363
1368
 
1364
1369
  def test_yylex_identifier
1365
1370
  assert_lex3("identifier",
1366
1371
  nil,
1367
- :tIDENTIFIER, "identifier", :expr_cmdarg)
1372
+ :tIDENTIFIER, "identifier", EXPR_CMDARG)
1368
1373
  end
1369
1374
 
1370
1375
  def test_yylex_identifier_bang
1371
1376
  assert_lex3("identifier!",
1372
1377
  nil,
1373
- :tFID, "identifier!", :expr_cmdarg)
1378
+ :tFID, "identifier!", EXPR_CMDARG)
1374
1379
  end
1375
1380
 
1376
1381
  def test_yylex_identifier_cmp
@@ -1380,34 +1385,34 @@ class TestRubyLexer < Minitest::Test
1380
1385
  def test_yylex_identifier_def__20
1381
1386
  setup_lexer_class RubyParser::V20
1382
1387
 
1383
- assert_lex_fname "identifier", :tIDENTIFIER, :expr_endfn
1388
+ assert_lex_fname "identifier", :tIDENTIFIER, EXPR_ENDFN
1384
1389
  end
1385
1390
 
1386
1391
  def test_yylex_identifier_eh
1387
- assert_lex3("identifier?", nil, :tFID, "identifier?", :expr_cmdarg)
1392
+ assert_lex3("identifier?", nil, :tFID, "identifier?", EXPR_CMDARG)
1388
1393
  end
1389
1394
 
1390
1395
  def test_yylex_identifier_equals_arrow
1391
1396
  assert_lex3(":blah==>",
1392
1397
  nil,
1393
- :tSYMBOL, "blah=", :expr_end,
1394
- :tASSOC, "=>", :expr_beg)
1398
+ :tSYMBOL, "blah=", EXPR_END,
1399
+ :tASSOC, "=>", EXPR_BEG)
1395
1400
  end
1396
1401
 
1397
1402
  def test_yylex_identifier_equals3
1398
1403
  assert_lex3(":a===b",
1399
1404
  nil,
1400
- :tSYMBOL, "a", :expr_end,
1401
- :tEQQ, "===", :expr_beg,
1402
- :tIDENTIFIER, "b", :expr_arg)
1405
+ :tSYMBOL, "a", EXPR_END,
1406
+ :tEQQ, "===", EXPR_BEG,
1407
+ :tIDENTIFIER, "b", EXPR_ARG)
1403
1408
  end
1404
1409
 
1405
1410
  def test_yylex_identifier_equals_equals_arrow
1406
1411
  assert_lex3(":a==>b",
1407
1412
  nil,
1408
- :tSYMBOL, "a=", :expr_end,
1409
- :tASSOC, "=>", :expr_beg,
1410
- :tIDENTIFIER, "b", :expr_arg)
1413
+ :tSYMBOL, "a=", EXPR_END,
1414
+ :tASSOC, "=>", EXPR_BEG,
1415
+ :tIDENTIFIER, "b", EXPR_ARG)
1411
1416
  end
1412
1417
 
1413
1418
  def test_yylex_identifier_equals_caret
@@ -1417,7 +1422,7 @@ class TestRubyLexer < Minitest::Test
1417
1422
  def test_yylex_identifier_equals_def__20
1418
1423
  setup_lexer_class RubyParser::V20
1419
1424
 
1420
- assert_lex_fname "identifier=", :tIDENTIFIER, :expr_endfn
1425
+ assert_lex_fname "identifier=", :tIDENTIFIER, EXPR_ENDFN
1421
1426
  end
1422
1427
 
1423
1428
  def test_yylex_identifier_equals_def2
@@ -1425,12 +1430,12 @@ class TestRubyLexer < Minitest::Test
1425
1430
  end
1426
1431
 
1427
1432
  def test_yylex_identifier_equals_expr
1428
- self.lex_state = :expr_dot
1433
+ self.lex_state = EXPR_DOT
1429
1434
  assert_lex3("y = arg",
1430
1435
  nil,
1431
- :tIDENTIFIER, "y", :expr_cmdarg,
1432
- :tEQL, "=", :expr_beg,
1433
- :tIDENTIFIER, "arg", :expr_arg)
1436
+ :tIDENTIFIER, "y", EXPR_CMDARG,
1437
+ :tEQL, "=", EXPR_BEG,
1438
+ :tIDENTIFIER, "arg", EXPR_ARG)
1434
1439
  end
1435
1440
 
1436
1441
  def test_yylex_identifier_equals_or
@@ -1442,12 +1447,12 @@ class TestRubyLexer < Minitest::Test
1442
1447
  end
1443
1448
 
1444
1449
  def test_yylex_identifier_equals_tilde
1445
- self.lex_state = :expr_fname # can only set via parser's defs
1450
+ self.lex_state = EXPR_FNAME # can only set via parser's defs
1446
1451
 
1447
1452
  assert_lex3("identifier=~",
1448
1453
  nil,
1449
- :tIDENTIFIER, "identifier", :expr_endfn,
1450
- :tMATCH, "=~", :expr_beg)
1454
+ :tIDENTIFIER, "identifier", EXPR_ENDFN,
1455
+ :tMATCH, "=~", EXPR_BEG)
1451
1456
  end
1452
1457
 
1453
1458
  def test_yylex_identifier_gt
@@ -1475,11 +1480,11 @@ class TestRubyLexer < Minitest::Test
1475
1480
  end
1476
1481
 
1477
1482
  def test_yylex_integer
1478
- assert_lex3("42", nil, :tINTEGER, 42, :expr_end)
1483
+ assert_lex3("42", nil, :tINTEGER, 42, EXPR_NUM)
1479
1484
  end
1480
1485
 
1481
1486
  def test_yylex_integer_bin
1482
- assert_lex3("0b101010", nil, :tINTEGER, 42, :expr_end)
1487
+ assert_lex3("0b101010", nil, :tINTEGER, 42, EXPR_NUM)
1483
1488
  end
1484
1489
 
1485
1490
  def test_yylex_integer_bin_bad_none
@@ -1491,7 +1496,7 @@ class TestRubyLexer < Minitest::Test
1491
1496
  end
1492
1497
 
1493
1498
  def test_yylex_integer_dec
1494
- assert_lex3("42", nil, :tINTEGER, 42, :expr_end)
1499
+ assert_lex3("42", nil, :tINTEGER, 42, EXPR_NUM)
1495
1500
  end
1496
1501
 
1497
1502
  def test_yylex_integer_dec_bad_underscores
@@ -1499,7 +1504,7 @@ class TestRubyLexer < Minitest::Test
1499
1504
  end
1500
1505
 
1501
1506
  def test_yylex_integer_dec_d
1502
- assert_lex3("0d42", nil, :tINTEGER, 42, :expr_end)
1507
+ assert_lex3("0d42", nil, :tINTEGER, 42, EXPR_NUM)
1503
1508
  end
1504
1509
 
1505
1510
  def test_yylex_integer_dec_d_bad_none
@@ -1513,24 +1518,24 @@ class TestRubyLexer < Minitest::Test
1513
1518
  def test_yylex_integer_if_modifier
1514
1519
  assert_lex3("123if",
1515
1520
  nil,
1516
- :tINTEGER, 123, :expr_end,
1517
- :kIF_MOD, "if", :expr_beg)
1521
+ :tINTEGER, 123, EXPR_NUM,
1522
+ :kIF_MOD, "if", EXPR_PAR)
1518
1523
  end
1519
1524
 
1520
1525
  def test_yylex_question_eh_a__20
1521
1526
  setup_lexer_class RubyParser::V20
1522
1527
 
1523
- assert_lex3("?a", nil, :tSTRING, "a", :expr_end)
1528
+ assert_lex3("?a", nil, :tSTRING, "a", EXPR_END)
1524
1529
  end
1525
1530
 
1526
1531
  def test_yylex_question_eh_escape_M_escape_C__20
1527
1532
  setup_lexer_class RubyParser::V20
1528
1533
 
1529
- assert_lex3("?\\M-\\C-a", nil, :tSTRING, "\M-\C-a", :expr_end)
1534
+ assert_lex3("?\\M-\\C-a", nil, :tSTRING, "\M-\C-a", EXPR_END)
1530
1535
  end
1531
1536
 
1532
1537
  def test_yylex_integer_hex
1533
- assert_lex3 "0x2a", nil, :tINTEGER, 42, :expr_end
1538
+ assert_lex3 "0x2a", nil, :tINTEGER, 42, EXPR_NUM
1534
1539
  end
1535
1540
 
1536
1541
  def test_yylex_integer_hex_bad_none
@@ -1542,7 +1547,7 @@ class TestRubyLexer < Minitest::Test
1542
1547
  end
1543
1548
 
1544
1549
  def test_yylex_integer_oct
1545
- assert_lex3("052", nil, :tINTEGER, 42, :expr_end)
1550
+ assert_lex3("052", nil, :tINTEGER, 42, EXPR_NUM)
1546
1551
  end
1547
1552
 
1548
1553
  def test_yylex_integer_oct_bad_range
@@ -1558,7 +1563,7 @@ class TestRubyLexer < Minitest::Test
1558
1563
  end
1559
1564
 
1560
1565
  def test_yylex_integer_oct_O
1561
- assert_lex3 "0O52", nil, :tINTEGER, 42, :expr_end
1566
+ assert_lex3 "0O52", nil, :tINTEGER, 42, EXPR_NUM
1562
1567
  end
1563
1568
 
1564
1569
  def test_yylex_integer_oct_O_bad_range
@@ -1570,11 +1575,11 @@ class TestRubyLexer < Minitest::Test
1570
1575
  end
1571
1576
 
1572
1577
  def test_yylex_integer_oct_O_not_bad_none
1573
- assert_lex3 "0O ", nil, :tINTEGER, 0, :expr_end
1578
+ assert_lex3 "0O ", nil, :tINTEGER, 0, EXPR_NUM
1574
1579
  end
1575
1580
 
1576
1581
  def test_yylex_integer_oct_o
1577
- assert_lex3 "0o52", nil, :tINTEGER, 42, :expr_end
1582
+ assert_lex3 "0o52", nil, :tINTEGER, 42, EXPR_NUM
1578
1583
  end
1579
1584
 
1580
1585
  def test_yylex_integer_oct_o_bad_range
@@ -1586,19 +1591,19 @@ class TestRubyLexer < Minitest::Test
1586
1591
  end
1587
1592
 
1588
1593
  def test_yylex_integer_oct_o_not_bad_none
1589
- assert_lex3 "0o ", nil, :tINTEGER, 0, :expr_end
1594
+ assert_lex3 "0o ", nil, :tINTEGER, 0, EXPR_NUM
1590
1595
  end
1591
1596
 
1592
1597
  def test_yylex_integer_trailing
1593
1598
  assert_lex3("1.to_s",
1594
1599
  nil,
1595
- :tINTEGER, 1, :expr_end,
1596
- :tDOT, ".", :expr_dot,
1597
- :tIDENTIFIER, "to_s", :expr_arg)
1600
+ :tINTEGER, 1, EXPR_NUM,
1601
+ :tDOT, ".", EXPR_DOT,
1602
+ :tIDENTIFIER, "to_s", EXPR_ARG)
1598
1603
  end
1599
1604
 
1600
1605
  def test_yylex_integer_underscore
1601
- assert_lex3("4_2", nil, :tINTEGER, 42, :expr_end)
1606
+ assert_lex3("4_2", nil, :tINTEGER, 42, EXPR_NUM)
1602
1607
  end
1603
1608
 
1604
1609
  def test_yylex_integer_underscore_bad
@@ -1606,11 +1611,11 @@ class TestRubyLexer < Minitest::Test
1606
1611
  end
1607
1612
 
1608
1613
  def test_yylex_integer_zero
1609
- assert_lex3 "0", nil, :tINTEGER, 0, :expr_end
1614
+ assert_lex3 "0", nil, :tINTEGER, 0, EXPR_NUM
1610
1615
  end
1611
1616
 
1612
1617
  def test_yylex_ivar
1613
- assert_lex3("@blah", nil, :tIVAR, "@blah", :expr_end)
1618
+ assert_lex3("@blah", nil, :tIVAR, "@blah", EXPR_END)
1614
1619
  end
1615
1620
 
1616
1621
  def test_yylex_ivar_bad
@@ -1618,237 +1623,237 @@ class TestRubyLexer < Minitest::Test
1618
1623
  end
1619
1624
 
1620
1625
  def test_yylex_ivar_bad_0_length
1621
- refute_lex "1+@\n", :tINTEGER, 1, :tPLUS, "+", :expr_end
1626
+ refute_lex "1+@\n", :tINTEGER, 1, :tPLUS, "+", EXPR_NUM
1622
1627
  end
1623
1628
 
1624
1629
  def test_yylex_keyword_expr
1625
- self.lex_state = :expr_endarg
1630
+ self.lex_state = EXPR_ENDARG
1626
1631
 
1627
- assert_lex3("if", nil, :kIF_MOD, "if", :expr_beg)
1632
+ assert_lex3("if", nil, :kIF_MOD, "if", EXPR_PAR)
1628
1633
  end
1629
1634
 
1630
1635
  def test_yylex_lt
1631
- assert_lex3("<", nil, :tLT, "<", :expr_beg)
1636
+ assert_lex3("<", nil, :tLT, "<", EXPR_BEG)
1632
1637
  end
1633
1638
 
1634
1639
  def test_yylex_lt2
1635
1640
  assert_lex3("a << b",
1636
1641
  nil,
1637
- :tIDENTIFIER, "a", :expr_cmdarg,
1638
- :tLSHFT, "<<", :expr_beg,
1639
- :tIDENTIFIER, "b", :expr_arg)
1642
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1643
+ :tLSHFT, "<<", EXPR_BEG,
1644
+ :tIDENTIFIER, "b", EXPR_ARG)
1640
1645
  end
1641
1646
 
1642
1647
  def test_yylex_lt2_equals
1643
1648
  assert_lex3("a <<= b",
1644
1649
  nil,
1645
- :tIDENTIFIER, "a", :expr_cmdarg,
1646
- :tOP_ASGN, "<<", :expr_beg,
1647
- :tIDENTIFIER, "b", :expr_arg)
1650
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1651
+ :tOP_ASGN, "<<", EXPR_BEG,
1652
+ :tIDENTIFIER, "b", EXPR_ARG)
1648
1653
  end
1649
1654
 
1650
1655
  def test_yylex_lt_equals
1651
- assert_lex3("<=", nil, :tLEQ, "<=", :expr_beg)
1656
+ assert_lex3("<=", nil, :tLEQ, "<=", EXPR_BEG)
1652
1657
  end
1653
1658
 
1654
1659
  def test_yylex_minus
1655
1660
  assert_lex3("1 - 2",
1656
1661
  nil,
1657
- :tINTEGER, 1, :expr_end,
1658
- :tMINUS, "-", :expr_beg,
1659
- :tINTEGER, 2, :expr_end)
1662
+ :tINTEGER, 1, EXPR_NUM,
1663
+ :tMINUS, "-", EXPR_BEG,
1664
+ :tINTEGER, 2, EXPR_NUM)
1660
1665
  end
1661
1666
 
1662
1667
  def test_yylex_minus_equals
1663
- assert_lex3("-=", nil, :tOP_ASGN, "-", :expr_beg)
1668
+ assert_lex3("-=", nil, :tOP_ASGN, "-", EXPR_BEG)
1664
1669
  end
1665
1670
 
1666
1671
  def test_yylex_minus_method
1667
- self.lex_state = :expr_fname
1672
+ self.lex_state = EXPR_FNAME
1668
1673
 
1669
- assert_lex3("-", nil, :tMINUS, "-", :expr_arg)
1674
+ assert_lex3("-", nil, :tMINUS, "-", EXPR_ARG)
1670
1675
  end
1671
1676
 
1672
1677
  def test_yylex_minus_unary_method
1673
- self.lex_state = :expr_fname
1678
+ self.lex_state = EXPR_FNAME
1674
1679
 
1675
- assert_lex3("-@", nil, :tUMINUS, "-@", :expr_arg)
1680
+ assert_lex3("-@", nil, :tUMINUS, "-@", EXPR_ARG)
1676
1681
  end
1677
1682
 
1678
1683
  def test_yylex_minus_unary_number
1679
1684
  assert_lex3("-42",
1680
1685
  nil,
1681
- :tUMINUS_NUM, "-", :expr_beg,
1682
- :tINTEGER, 42, :expr_end)
1686
+ :tUMINUS_NUM, "-", EXPR_BEG,
1687
+ :tINTEGER, 42, EXPR_NUM)
1683
1688
  end
1684
1689
 
1685
1690
  def test_yylex_nth_ref
1686
1691
  assert_lex3("[$1, $2, $3, $4, $5, $6, $7, $8, $9]",
1687
1692
  nil,
1688
- :tLBRACK, "[", :expr_beg,
1689
- :tNTH_REF, 1, :expr_end, :tCOMMA, ",", :expr_beg,
1690
- :tNTH_REF, 2, :expr_end, :tCOMMA, ",", :expr_beg,
1691
- :tNTH_REF, 3, :expr_end, :tCOMMA, ",", :expr_beg,
1692
- :tNTH_REF, 4, :expr_end, :tCOMMA, ",", :expr_beg,
1693
- :tNTH_REF, 5, :expr_end, :tCOMMA, ",", :expr_beg,
1694
- :tNTH_REF, 6, :expr_end, :tCOMMA, ",", :expr_beg,
1695
- :tNTH_REF, 7, :expr_end, :tCOMMA, ",", :expr_beg,
1696
- :tNTH_REF, 8, :expr_end, :tCOMMA, ",", :expr_beg,
1697
- :tNTH_REF, 9, :expr_end,
1698
- :tRBRACK, "]", :expr_endarg)
1693
+ :tLBRACK, "[", EXPR_PAR,
1694
+ :tNTH_REF, 1, EXPR_END, :tCOMMA, ",", EXPR_PAR,
1695
+ :tNTH_REF, 2, EXPR_END, :tCOMMA, ",", EXPR_PAR,
1696
+ :tNTH_REF, 3, EXPR_END, :tCOMMA, ",", EXPR_PAR,
1697
+ :tNTH_REF, 4, EXPR_END, :tCOMMA, ",", EXPR_PAR,
1698
+ :tNTH_REF, 5, EXPR_END, :tCOMMA, ",", EXPR_PAR,
1699
+ :tNTH_REF, 6, EXPR_END, :tCOMMA, ",", EXPR_PAR,
1700
+ :tNTH_REF, 7, EXPR_END, :tCOMMA, ",", EXPR_PAR,
1701
+ :tNTH_REF, 8, EXPR_END, :tCOMMA, ",", EXPR_PAR,
1702
+ :tNTH_REF, 9, EXPR_END,
1703
+ :tRBRACK, "]", EXPR_ENDARG)
1699
1704
  end
1700
1705
 
1701
1706
  def test_yylex_open_bracket
1702
- assert_lex3("(", nil, :tLPAREN, "(", :expr_beg)
1707
+ assert_lex3("(", nil, :tLPAREN, "(", EXPR_PAR)
1703
1708
  end
1704
1709
 
1705
1710
  def test_yylex_open_bracket_cmdarg
1706
- self.lex_state = :expr_cmdarg
1711
+ self.lex_state = EXPR_CMDARG
1707
1712
 
1708
- assert_lex3(" (", nil, :tLPAREN_ARG, "(", :expr_beg)
1713
+ assert_lex3(" (", nil, :tLPAREN_ARG, "(", EXPR_PAR)
1709
1714
  end
1710
1715
 
1711
1716
  def test_yylex_open_bracket_exprarg__20
1712
1717
  setup_lexer_class RubyParser::V20
1713
- self.lex_state = :expr_arg
1718
+ self.lex_state = EXPR_ARG
1714
1719
 
1715
- assert_lex3(" (", nil, :tLPAREN_ARG, "(", :expr_beg)
1720
+ assert_lex3(" (", nil, :tLPAREN_ARG, "(", EXPR_PAR)
1716
1721
  end
1717
1722
 
1718
1723
  def test_yylex_open_curly_bracket
1719
- assert_lex3("{", nil, :tLBRACE, "{", :expr_beg)
1724
+ assert_lex3("{", nil, :tLBRACE, "{", EXPR_PAR)
1720
1725
  end
1721
1726
 
1722
1727
  def test_yylex_open_curly_bracket_arg
1723
- self.lex_state = :expr_arg
1728
+ self.lex_state = EXPR_ARG
1724
1729
 
1725
1730
  assert_lex3("m { 3 }",
1726
1731
  nil,
1727
- :tIDENTIFIER, "m", :expr_cmdarg,
1728
- :tLCURLY, "{", :expr_beg,
1729
- :tINTEGER, 3, :expr_end,
1730
- :tRCURLY, "}", :expr_endarg)
1732
+ :tIDENTIFIER, "m", EXPR_CMDARG,
1733
+ :tLCURLY, "{", EXPR_PAR,
1734
+ :tINTEGER, 3, EXPR_NUM,
1735
+ :tRCURLY, "}", EXPR_ENDARG)
1731
1736
  end
1732
1737
 
1733
1738
  def test_yylex_open_curly_bracket_block
1734
- self.lex_state = :expr_endarg # seen m(3)
1739
+ self.lex_state = EXPR_ENDARG # seen m(3)
1735
1740
 
1736
1741
  assert_lex3("{ 4 }",
1737
1742
  nil,
1738
- :tLBRACE_ARG, "{", :expr_beg,
1739
- :tINTEGER, 4, :expr_end,
1740
- :tRCURLY, "}", :expr_endarg)
1743
+ :tLBRACE_ARG, "{", EXPR_BEG,
1744
+ :tINTEGER, 4, EXPR_NUM,
1745
+ :tRCURLY, "}", EXPR_ENDARG)
1741
1746
  end
1742
1747
 
1743
1748
  def test_yylex_open_square_bracket_arg
1744
- self.lex_state = :expr_arg
1749
+ self.lex_state = EXPR_ARG
1745
1750
 
1746
1751
  assert_lex3("m [ 3 ]",
1747
1752
  nil,
1748
- :tIDENTIFIER, "m", :expr_cmdarg,
1749
- :tLBRACK, "[", :expr_beg,
1750
- :tINTEGER, 3, :expr_end,
1751
- :tRBRACK, "]", :expr_endarg)
1753
+ :tIDENTIFIER, "m", EXPR_CMDARG,
1754
+ :tLBRACK, "[", EXPR_PAR,
1755
+ :tINTEGER, 3, EXPR_NUM,
1756
+ :tRBRACK, "]", EXPR_ENDARG)
1752
1757
  end
1753
1758
 
1754
1759
  def test_yylex_open_square_bracket_ary
1755
1760
  assert_lex3("[1, 2, 3]",
1756
1761
  nil,
1757
- :tLBRACK, "[", :expr_beg,
1758
- :tINTEGER, 1, :expr_end, :tCOMMA, ",", :expr_beg,
1759
- :tINTEGER, 2, :expr_end, :tCOMMA, ",", :expr_beg,
1760
- :tINTEGER, 3, :expr_end,
1761
- :tRBRACK, "]", :expr_endarg)
1762
+ :tLBRACK, "[", EXPR_PAR,
1763
+ :tINTEGER, 1, EXPR_NUM, :tCOMMA, ",", EXPR_PAR,
1764
+ :tINTEGER, 2, EXPR_NUM, :tCOMMA, ",", EXPR_PAR,
1765
+ :tINTEGER, 3, EXPR_NUM,
1766
+ :tRBRACK, "]", EXPR_ENDARG)
1762
1767
  end
1763
1768
 
1764
1769
  def test_yylex_open_square_bracket_meth
1765
1770
  assert_lex3("m[3]",
1766
1771
  nil,
1767
- :tIDENTIFIER, "m", :expr_cmdarg,
1768
- :tLBRACK2, "[", :expr_beg,
1769
- :tINTEGER, 3, :expr_end,
1770
- :tRBRACK, "]", :expr_endarg)
1772
+ :tIDENTIFIER, "m", EXPR_CMDARG,
1773
+ :tLBRACK2, "[", EXPR_PAR,
1774
+ :tINTEGER, 3, EXPR_NUM,
1775
+ :tRBRACK, "]", EXPR_ENDARG)
1771
1776
  end
1772
1777
 
1773
1778
  def test_yylex_or
1774
- assert_lex3("|", nil, :tPIPE, "|", :expr_beg)
1779
+ assert_lex3("|", nil, :tPIPE, "|", EXPR_PAR)
1775
1780
  end
1776
1781
 
1777
1782
  def test_yylex_or2
1778
- assert_lex3("||", nil, :tOROP, "||", :expr_beg)
1783
+ assert_lex3("||", nil, :tOROP, "||", EXPR_BEG)
1779
1784
  end
1780
1785
 
1781
1786
  def test_yylex_or2_equals
1782
- assert_lex3("||=", nil, :tOP_ASGN, "||", :expr_beg)
1787
+ assert_lex3("||=", nil, :tOP_ASGN, "||", EXPR_BEG)
1783
1788
  end
1784
1789
 
1785
1790
  def test_yylex_or_equals
1786
- assert_lex3("|=", nil, :tOP_ASGN, "|", :expr_beg)
1791
+ assert_lex3("|=", nil, :tOP_ASGN, "|", EXPR_BEG)
1787
1792
  end
1788
1793
 
1789
1794
  def test_yylex_percent
1790
1795
  assert_lex3("a % 2",
1791
1796
  nil,
1792
- :tIDENTIFIER, "a", :expr_cmdarg,
1793
- :tPERCENT, "%", :expr_beg,
1794
- :tINTEGER, 2, :expr_end)
1797
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1798
+ :tPERCENT, "%", EXPR_BEG,
1799
+ :tINTEGER, 2, EXPR_NUM)
1795
1800
  end
1796
1801
 
1797
1802
  def test_yylex_percent_equals
1798
1803
  assert_lex3("a %= 2",
1799
1804
  nil,
1800
- :tIDENTIFIER, "a", :expr_cmdarg,
1801
- :tOP_ASGN, "%", :expr_beg,
1802
- :tINTEGER, 2, :expr_end)
1805
+ :tIDENTIFIER, "a", EXPR_CMDARG,
1806
+ :tOP_ASGN, "%", EXPR_BEG,
1807
+ :tINTEGER, 2, EXPR_NUM)
1803
1808
  end
1804
1809
 
1805
1810
  def test_yylex_plus
1806
1811
  assert_lex3("1 + 1", # TODO lex_state?
1807
1812
  nil,
1808
- :tINTEGER, 1, :expr_end,
1809
- :tPLUS, "+", :expr_beg,
1810
- :tINTEGER, 1, :expr_end)
1813
+ :tINTEGER, 1, EXPR_NUM,
1814
+ :tPLUS, "+", EXPR_BEG,
1815
+ :tINTEGER, 1, EXPR_NUM)
1811
1816
  end
1812
1817
 
1813
1818
  def test_yylex_plus_equals
1814
- assert_lex3("+=", nil, :tOP_ASGN, "+", :expr_beg)
1819
+ assert_lex3("+=", nil, :tOP_ASGN, "+", EXPR_BEG)
1815
1820
  end
1816
1821
 
1817
1822
  def test_yylex_plus_method
1818
- self.lex_state = :expr_fname
1823
+ self.lex_state = EXPR_FNAME
1819
1824
 
1820
- assert_lex3("+", nil, :tPLUS, "+", :expr_arg)
1825
+ assert_lex3("+", nil, :tPLUS, "+", EXPR_ARG)
1821
1826
  end
1822
1827
 
1823
1828
  def test_yylex_plus_unary_method
1824
- self.lex_state = :expr_fname
1829
+ self.lex_state = EXPR_FNAME
1825
1830
 
1826
- assert_lex3("+@", nil, :tUPLUS, "+@", :expr_arg)
1831
+ assert_lex3("+@", nil, :tUPLUS, "+@", EXPR_ARG)
1827
1832
  end
1828
1833
 
1829
1834
  def test_yylex_not_unary_method
1830
- self.lex_state = :expr_fname
1835
+ self.lex_state = EXPR_FNAME
1831
1836
 
1832
- assert_lex3("!@", nil, :tUBANG, "!@", :expr_arg)
1837
+ assert_lex3("!@", nil, :tUBANG, "!@", EXPR_ARG)
1833
1838
  end
1834
1839
 
1835
1840
  def test_yylex_numbers
1836
- assert_lex3("0b10", nil, :tINTEGER, 2, :expr_end)
1837
- assert_lex3("0B10", nil, :tINTEGER, 2, :expr_end)
1841
+ assert_lex3("0b10", nil, :tINTEGER, 2, EXPR_NUM)
1842
+ assert_lex3("0B10", nil, :tINTEGER, 2, EXPR_NUM)
1838
1843
 
1839
- assert_lex3("0d10", nil, :tINTEGER, 10, :expr_end)
1840
- assert_lex3("0D10", nil, :tINTEGER, 10, :expr_end)
1844
+ assert_lex3("0d10", nil, :tINTEGER, 10, EXPR_NUM)
1845
+ assert_lex3("0D10", nil, :tINTEGER, 10, EXPR_NUM)
1841
1846
 
1842
- assert_lex3("0x10", nil, :tINTEGER, 16, :expr_end)
1843
- assert_lex3("0X10", nil, :tINTEGER, 16, :expr_end)
1847
+ assert_lex3("0x10", nil, :tINTEGER, 16, EXPR_NUM)
1848
+ assert_lex3("0X10", nil, :tINTEGER, 16, EXPR_NUM)
1844
1849
 
1845
- assert_lex3("0o10", nil, :tINTEGER, 8, :expr_end)
1846
- assert_lex3("0O10", nil, :tINTEGER, 8, :expr_end)
1850
+ assert_lex3("0o10", nil, :tINTEGER, 8, EXPR_NUM)
1851
+ assert_lex3("0O10", nil, :tINTEGER, 8, EXPR_NUM)
1847
1852
 
1848
- assert_lex3("0o", nil, :tINTEGER, 0, :expr_end)
1849
- assert_lex3("0O", nil, :tINTEGER, 0, :expr_end)
1853
+ assert_lex3("0o", nil, :tINTEGER, 0, EXPR_NUM)
1854
+ assert_lex3("0O", nil, :tINTEGER, 0, EXPR_NUM)
1850
1855
 
1851
- assert_lex3("0", nil, :tINTEGER, 0, :expr_end)
1856
+ assert_lex3("0", nil, :tINTEGER, 0, EXPR_NUM)
1852
1857
 
1853
1858
  refute_lex "0x"
1854
1859
  refute_lex "0X"
@@ -1870,7 +1875,7 @@ class TestRubyLexer < Minitest::Test
1870
1875
  end
1871
1876
 
1872
1877
  def test_yylex_plus_unary_number
1873
- assert_lex3("+42", nil, :tINTEGER, 42, :expr_end)
1878
+ assert_lex3("+42", nil, :tINTEGER, 42, EXPR_NUM)
1874
1879
  end
1875
1880
 
1876
1881
  def test_yylex_question_bad_eos
@@ -1878,31 +1883,31 @@ class TestRubyLexer < Minitest::Test
1878
1883
  end
1879
1884
 
1880
1885
  def test_yylex_question_ws
1881
- assert_lex3("? ", nil, :tEH, "?", :expr_value)
1882
- assert_lex3("?\n", nil, :tEH, "?", :expr_value)
1883
- assert_lex3("?\t", nil, :tEH, "?", :expr_value)
1884
- assert_lex3("?\v", nil, :tEH, "?", :expr_value)
1885
- assert_lex3("?\r", nil, :tEH, "?", :expr_value)
1886
- assert_lex3("?\f", nil, :tEH, "?", :expr_value)
1886
+ assert_lex3("? ", nil, :tEH, "?", EXPR_BEG)
1887
+ assert_lex3("?\n", nil, :tEH, "?", EXPR_BEG)
1888
+ assert_lex3("?\t", nil, :tEH, "?", EXPR_BEG)
1889
+ assert_lex3("?\v", nil, :tEH, "?", EXPR_BEG)
1890
+ assert_lex3("?\r", nil, :tEH, "?", EXPR_BEG)
1891
+ assert_lex3("?\f", nil, :tEH, "?", EXPR_BEG)
1887
1892
  end
1888
1893
 
1889
1894
  def test_yylex_question_ws_backslashed__20
1890
1895
  setup_lexer_class RubyParser::V20
1891
1896
 
1892
- assert_lex3("?\\ ", nil, :tSTRING, " ", :expr_end)
1893
- assert_lex3("?\\n", nil, :tSTRING, "\n", :expr_end)
1894
- assert_lex3("?\\t", nil, :tSTRING, "\t", :expr_end)
1895
- assert_lex3("?\\v", nil, :tSTRING, "\v", :expr_end)
1896
- assert_lex3("?\\r", nil, :tSTRING, "\r", :expr_end)
1897
- assert_lex3("?\\f", nil, :tSTRING, "\f", :expr_end)
1897
+ assert_lex3("?\\ ", nil, :tSTRING, " ", EXPR_END)
1898
+ assert_lex3("?\\n", nil, :tSTRING, "\n", EXPR_END)
1899
+ assert_lex3("?\\t", nil, :tSTRING, "\t", EXPR_END)
1900
+ assert_lex3("?\\v", nil, :tSTRING, "\v", EXPR_END)
1901
+ assert_lex3("?\\r", nil, :tSTRING, "\r", EXPR_END)
1902
+ assert_lex3("?\\f", nil, :tSTRING, "\f", EXPR_END)
1898
1903
  end
1899
1904
 
1900
1905
  def test_yylex_rbracket
1901
- assert_lex3("]", nil, :tRBRACK, "]", :expr_endarg)
1906
+ assert_lex3("]", nil, :tRBRACK, "]", EXPR_ENDARG)
1902
1907
  end
1903
1908
 
1904
1909
  def test_yylex_rcurly
1905
- assert_lex("}", nil, :tRCURLY, "}", :expr_endarg, 0, 1) do
1910
+ assert_lex("}", nil, :tRCURLY, "}", EXPR_ENDARG, 0, 1) do
1906
1911
  lexer.brace_nest += 2
1907
1912
  end
1908
1913
  end
@@ -1910,18 +1915,18 @@ class TestRubyLexer < Minitest::Test
1910
1915
  def test_yylex_regexp
1911
1916
  assert_lex3("/regexp/",
1912
1917
  nil,
1913
- :tREGEXP_BEG, "/", :expr_beg,
1914
- :tSTRING_CONTENT, "regexp", :expr_beg,
1915
- :tREGEXP_END, "", :expr_end)
1918
+ :tREGEXP_BEG, "/", EXPR_BEG,
1919
+ :tSTRING_CONTENT, "regexp", EXPR_BEG,
1920
+ :tREGEXP_END, "", EXPR_END)
1916
1921
  end
1917
1922
 
1918
1923
  def test_yylex_regexp_ambiguous
1919
1924
  assert_lex3("method /regexp/",
1920
1925
  nil,
1921
- :tIDENTIFIER, "method", :expr_cmdarg,
1922
- :tREGEXP_BEG, "/", :expr_cmdarg,
1923
- :tSTRING_CONTENT, "regexp", :expr_cmdarg,
1924
- :tREGEXP_END, "", :expr_end)
1926
+ :tIDENTIFIER, "method", EXPR_CMDARG,
1927
+ :tREGEXP_BEG, "/", EXPR_CMDARG,
1928
+ :tSTRING_CONTENT, "regexp", EXPR_CMDARG,
1929
+ :tREGEXP_END, "", EXPR_END)
1925
1930
  end
1926
1931
 
1927
1932
  def test_yylex_regexp_bad
@@ -1933,25 +1938,25 @@ class TestRubyLexer < Minitest::Test
1933
1938
  def test_yylex_regexp_escape_C
1934
1939
  assert_lex3("/regex\\C-x/",
1935
1940
  nil,
1936
- :tREGEXP_BEG, "/", :expr_beg,
1937
- :tSTRING_CONTENT, "regex\\C-x", :expr_beg,
1938
- :tREGEXP_END, "", :expr_end)
1941
+ :tREGEXP_BEG, "/", EXPR_BEG,
1942
+ :tSTRING_CONTENT, "regex\\C-x", EXPR_BEG,
1943
+ :tREGEXP_END, "", EXPR_END)
1939
1944
  end
1940
1945
 
1941
1946
  def test_yylex_regexp_escape_C_M
1942
1947
  assert_lex3("/regex\\C-\\M-x/",
1943
1948
  nil,
1944
- :tREGEXP_BEG, "/", :expr_beg,
1945
- :tSTRING_CONTENT, "regex\\C-\\M-x", :expr_beg,
1946
- :tREGEXP_END, "", :expr_end)
1949
+ :tREGEXP_BEG, "/", EXPR_BEG,
1950
+ :tSTRING_CONTENT, "regex\\C-\\M-x", EXPR_BEG,
1951
+ :tREGEXP_END, "", EXPR_END)
1947
1952
  end
1948
1953
 
1949
1954
  def test_yylex_regexp_escape_C_M_craaaazy
1950
1955
  assert_lex3("/regex\\C-\\\n\\M-x/",
1951
1956
  nil,
1952
- :tREGEXP_BEG, "/", :expr_beg,
1953
- :tSTRING_CONTENT, "regex\\C-\\M-x", :expr_beg,
1954
- :tREGEXP_END, "", :expr_end)
1957
+ :tREGEXP_BEG, "/", EXPR_BEG,
1958
+ :tSTRING_CONTENT, "regex\\C-\\M-x", EXPR_BEG,
1959
+ :tREGEXP_END, "", EXPR_END)
1955
1960
  end
1956
1961
 
1957
1962
  def test_yylex_regexp_escape_C_bad_dash
@@ -1977,17 +1982,17 @@ class TestRubyLexer < Minitest::Test
1977
1982
  def test_yylex_regexp_escape_M
1978
1983
  assert_lex3("/regex\\M-x/",
1979
1984
  nil,
1980
- :tREGEXP_BEG, "/", :expr_beg,
1981
- :tSTRING_CONTENT, "regex\\M-x", :expr_beg,
1982
- :tREGEXP_END, "", :expr_end)
1985
+ :tREGEXP_BEG, "/", EXPR_BEG,
1986
+ :tSTRING_CONTENT, "regex\\M-x", EXPR_BEG,
1987
+ :tREGEXP_END, "", EXPR_END)
1983
1988
  end
1984
1989
 
1985
1990
  def test_yylex_regexp_escape_M_C
1986
1991
  assert_lex3("/regex\\M-\\C-x/",
1987
1992
  nil,
1988
- :tREGEXP_BEG, "/", :expr_beg,
1989
- :tSTRING_CONTENT, "regex\\M-\\C-x", :expr_beg,
1990
- :tREGEXP_END, "", :expr_end)
1993
+ :tREGEXP_BEG, "/", EXPR_BEG,
1994
+ :tSTRING_CONTENT, "regex\\M-\\C-x", EXPR_BEG,
1995
+ :tREGEXP_END, "", EXPR_END)
1991
1996
  end
1992
1997
 
1993
1998
  def test_yylex_regexp_escape_M_bad_dash
@@ -2009,49 +2014,49 @@ class TestRubyLexer < Minitest::Test
2009
2014
  def test_yylex_regexp_escape_backslash_slash
2010
2015
  assert_lex3("/\\//",
2011
2016
  nil,
2012
- :tREGEXP_BEG, "/", :expr_beg,
2013
- :tSTRING_CONTENT, "\\/", :expr_beg,
2014
- :tREGEXP_END, "", :expr_end)
2017
+ :tREGEXP_BEG, "/", EXPR_BEG,
2018
+ :tSTRING_CONTENT, "\\/", EXPR_BEG,
2019
+ :tREGEXP_END, "", EXPR_END)
2015
2020
  end
2016
2021
 
2017
2022
  def test_yylex_regexp_escape_backslash_terminator
2018
2023
  assert_lex3("%r%blah\\%blah%",
2019
2024
  nil,
2020
- :tREGEXP_BEG, "%r\000", :expr_beg,
2021
- :tSTRING_CONTENT, "blah\\%blah", :expr_beg,
2022
- :tREGEXP_END, "", :expr_end)
2025
+ :tREGEXP_BEG, "%r\000", EXPR_BEG,
2026
+ :tSTRING_CONTENT, "blah\\%blah", EXPR_BEG,
2027
+ :tREGEXP_END, "", EXPR_END)
2023
2028
  end
2024
2029
 
2025
2030
  def test_yylex_regexp_escaped_delim
2026
2031
  assert_lex3("%r!blah(?\\!blah)!",
2027
2032
  nil,
2028
- :tREGEXP_BEG, "%r\000", :expr_beg,
2029
- :tSTRING_CONTENT, "blah(?!blah)", :expr_beg,
2030
- :tREGEXP_END, "", :expr_end)
2033
+ :tREGEXP_BEG, "%r\000", EXPR_BEG,
2034
+ :tSTRING_CONTENT, "blah(?!blah)", EXPR_BEG,
2035
+ :tREGEXP_END, "", EXPR_END)
2031
2036
  end
2032
2037
 
2033
2038
  def test_yylex_regexp_escape_backslash_terminator_meta1
2034
2039
  assert_lex3("%r{blah\\}blah}",
2035
2040
  nil,
2036
- :tREGEXP_BEG, "%r{", :expr_beg, # FIX ?!?
2037
- :tSTRING_CONTENT, "blah\\}blah", :expr_beg,
2038
- :tREGEXP_END, "", :expr_end)
2041
+ :tREGEXP_BEG, "%r{", EXPR_BEG, # FIX ?!?
2042
+ :tSTRING_CONTENT, "blah\\}blah", EXPR_BEG,
2043
+ :tREGEXP_END, "", EXPR_END)
2039
2044
  end
2040
2045
 
2041
2046
  def test_yylex_regexp_escape_backslash_terminator_meta2
2042
2047
  assert_lex3("%r/blah\\/blah/",
2043
2048
  nil,
2044
- :tREGEXP_BEG, "%r\000", :expr_beg,
2045
- :tSTRING_CONTENT, "blah\\/blah", :expr_beg,
2046
- :tREGEXP_END, "", :expr_end)
2049
+ :tREGEXP_BEG, "%r\000", EXPR_BEG,
2050
+ :tSTRING_CONTENT, "blah\\/blah", EXPR_BEG,
2051
+ :tREGEXP_END, "", EXPR_END)
2047
2052
  end
2048
2053
 
2049
2054
  def test_yylex_regexp_escape_backslash_terminator_meta3
2050
2055
  assert_lex3("%r/blah\\%blah/",
2051
2056
  nil,
2052
- :tREGEXP_BEG, "%r\000", :expr_beg,
2053
- :tSTRING_CONTENT, "blah\\%blah", :expr_beg,
2054
- :tREGEXP_END, "", :expr_end)
2057
+ :tREGEXP_BEG, "%r\000", EXPR_BEG,
2058
+ :tSTRING_CONTENT, "blah\\%blah", EXPR_BEG,
2059
+ :tREGEXP_END, "", EXPR_END)
2055
2060
  end
2056
2061
 
2057
2062
  def test_yylex_regexp_escape_bad_eos
@@ -2061,50 +2066,50 @@ class TestRubyLexer < Minitest::Test
2061
2066
  def test_yylex_regexp_escape_bs
2062
2067
  assert_lex3("/regex\\\\regex/",
2063
2068
  nil,
2064
- :tREGEXP_BEG, "/", :expr_beg,
2065
- :tSTRING_CONTENT, "regex\\\\regex", :expr_beg,
2066
- :tREGEXP_END, "", :expr_end)
2069
+ :tREGEXP_BEG, "/", EXPR_BEG,
2070
+ :tSTRING_CONTENT, "regex\\\\regex", EXPR_BEG,
2071
+ :tREGEXP_END, "", EXPR_END)
2067
2072
  end
2068
2073
 
2069
2074
  def test_yylex_regexp_escape_c
2070
2075
  assert_lex3("/regex\\cxxx/",
2071
2076
  nil,
2072
- :tREGEXP_BEG, "/", :expr_beg,
2073
- :tSTRING_CONTENT, "regex\\cxxx", :expr_beg,
2074
- :tREGEXP_END, "", :expr_end)
2077
+ :tREGEXP_BEG, "/", EXPR_BEG,
2078
+ :tSTRING_CONTENT, "regex\\cxxx", EXPR_BEG,
2079
+ :tREGEXP_END, "", EXPR_END)
2075
2080
  end
2076
2081
 
2077
2082
  def test_yylex_regexp_escape_c_backslash
2078
2083
  assert_lex3("/regex\\c\\n/",
2079
2084
  nil,
2080
- :tREGEXP_BEG, "/", :expr_beg,
2081
- :tSTRING_CONTENT, "regex\\c\\n", :expr_beg,
2082
- :tREGEXP_END, "", :expr_end)
2085
+ :tREGEXP_BEG, "/", EXPR_BEG,
2086
+ :tSTRING_CONTENT, "regex\\c\\n", EXPR_BEG,
2087
+ :tREGEXP_END, "", EXPR_END)
2083
2088
  end
2084
2089
 
2085
2090
  def test_yylex_regexp_escape_chars
2086
2091
  assert_lex3("/re\\tge\\nxp/",
2087
2092
  nil,
2088
- :tREGEXP_BEG, "/", :expr_beg,
2089
- :tSTRING_CONTENT, "re\\tge\\nxp", :expr_beg,
2090
- :tREGEXP_END, "", :expr_end)
2093
+ :tREGEXP_BEG, "/", EXPR_BEG,
2094
+ :tSTRING_CONTENT, "re\\tge\\nxp", EXPR_BEG,
2095
+ :tREGEXP_END, "", EXPR_END)
2091
2096
  end
2092
2097
 
2093
2098
  def test_yylex_regexp_escape_double_backslash
2094
2099
  regexp = '/[\\/\\\\]$/'
2095
2100
  assert_lex3(regexp.dup,
2096
2101
  nil,
2097
- :tREGEXP_BEG, "/", :expr_beg,
2098
- :tSTRING_CONTENT, "[\\/\\\\]$", :expr_beg,
2099
- :tREGEXP_END, "", :expr_end)
2102
+ :tREGEXP_BEG, "/", EXPR_BEG,
2103
+ :tSTRING_CONTENT, "[\\/\\\\]$", EXPR_BEG,
2104
+ :tREGEXP_END, "", EXPR_END)
2100
2105
  end
2101
2106
 
2102
2107
  def test_yylex_regexp_escape_hex
2103
2108
  assert_lex3("/regex\\x61xp/",
2104
2109
  nil,
2105
- :tREGEXP_BEG, "/", :expr_beg,
2106
- :tSTRING_CONTENT, "regex\\x61xp", :expr_beg,
2107
- :tREGEXP_END, "", :expr_end)
2110
+ :tREGEXP_BEG, "/", EXPR_BEG,
2111
+ :tSTRING_CONTENT, "regex\\x61xp", EXPR_BEG,
2112
+ :tREGEXP_END, "", EXPR_END)
2108
2113
  end
2109
2114
 
2110
2115
  def test_yylex_regexp_escape_hex_bad
@@ -2114,133 +2119,133 @@ class TestRubyLexer < Minitest::Test
2114
2119
  def test_yylex_regexp_escape_hex_one
2115
2120
  assert_lex3("/^[\\xd\\xa]{2}/on",
2116
2121
  nil,
2117
- :tREGEXP_BEG, "/", :expr_beg,
2118
- :tSTRING_CONTENT, "^[\\xd\\xa]{2}", :expr_beg,
2119
- :tREGEXP_END, "on", :expr_end)
2122
+ :tREGEXP_BEG, "/", EXPR_BEG,
2123
+ :tSTRING_CONTENT, "^[\\xd\\xa]{2}", EXPR_BEG,
2124
+ :tREGEXP_END, "on", EXPR_END)
2120
2125
  end
2121
2126
 
2122
2127
  def test_yylex_regexp_escape_oct1
2123
2128
  assert_lex3("/regex\\0xp/",
2124
2129
  nil,
2125
- :tREGEXP_BEG, "/", :expr_beg,
2126
- :tSTRING_CONTENT, "regex\\0xp", :expr_beg,
2127
- :tREGEXP_END, "", :expr_end)
2130
+ :tREGEXP_BEG, "/", EXPR_BEG,
2131
+ :tSTRING_CONTENT, "regex\\0xp", EXPR_BEG,
2132
+ :tREGEXP_END, "", EXPR_END)
2128
2133
  end
2129
2134
 
2130
2135
  def test_yylex_regexp_escape_oct2
2131
2136
  assert_lex3("/regex\\07xp/",
2132
2137
  nil,
2133
- :tREGEXP_BEG, "/", :expr_beg,
2134
- :tSTRING_CONTENT, "regex\\07xp", :expr_beg,
2135
- :tREGEXP_END, "", :expr_end)
2138
+ :tREGEXP_BEG, "/", EXPR_BEG,
2139
+ :tSTRING_CONTENT, "regex\\07xp", EXPR_BEG,
2140
+ :tREGEXP_END, "", EXPR_END)
2136
2141
  end
2137
2142
 
2138
2143
  def test_yylex_regexp_escape_oct3
2139
2144
  assert_lex3("/regex\\10142/",
2140
2145
  nil,
2141
- :tREGEXP_BEG, "/", :expr_beg,
2142
- :tSTRING_CONTENT, "regex\\10142", :expr_beg,
2143
- :tREGEXP_END, "", :expr_end)
2146
+ :tREGEXP_BEG, "/", EXPR_BEG,
2147
+ :tSTRING_CONTENT, "regex\\10142", EXPR_BEG,
2148
+ :tREGEXP_END, "", EXPR_END)
2144
2149
  end
2145
2150
 
2146
2151
  def test_yylex_regexp_escape_return
2147
2152
  assert_lex3("/regex\\\nregex/",
2148
2153
  nil,
2149
- :tREGEXP_BEG, "/", :expr_beg,
2150
- :tSTRING_CONTENT, "regexregex", :expr_beg,
2151
- :tREGEXP_END, "", :expr_end)
2154
+ :tREGEXP_BEG, "/", EXPR_BEG,
2155
+ :tSTRING_CONTENT, "regexregex", EXPR_BEG,
2156
+ :tREGEXP_END, "", EXPR_END)
2152
2157
  end
2153
2158
 
2154
2159
  def test_yylex_regexp_nm
2155
2160
  assert_lex3("/.*/nm",
2156
2161
  nil,
2157
- :tREGEXP_BEG, "/", :expr_beg,
2158
- :tSTRING_CONTENT, ".*", :expr_beg,
2159
- :tREGEXP_END, "nm", :expr_end)
2162
+ :tREGEXP_BEG, "/", EXPR_BEG,
2163
+ :tSTRING_CONTENT, ".*", EXPR_BEG,
2164
+ :tREGEXP_END, "nm", EXPR_END)
2160
2165
  end
2161
2166
 
2162
2167
  def test_yylex_rparen
2163
- assert_lex3(")", nil, :tRPAREN, ")", :expr_endfn)
2168
+ assert_lex3(")", nil, :tRPAREN, ")", EXPR_ENDFN)
2164
2169
  end
2165
2170
 
2166
2171
  def test_yylex_rshft
2167
2172
  assert_lex3("a >> 2",
2168
2173
  nil,
2169
- :tIDENTIFIER, "a", :expr_cmdarg,
2170
- :tRSHFT, ">>", :expr_beg,
2171
- :tINTEGER, 2, :expr_end)
2174
+ :tIDENTIFIER, "a", EXPR_CMDARG,
2175
+ :tRSHFT, ">>", EXPR_BEG,
2176
+ :tINTEGER, 2, EXPR_NUM)
2172
2177
  end
2173
2178
 
2174
2179
  def test_yylex_rshft_equals
2175
2180
  assert_lex3("a >>= 2",
2176
2181
  nil,
2177
- :tIDENTIFIER, "a", :expr_cmdarg,
2178
- :tOP_ASGN, ">>", :expr_beg,
2179
- :tINTEGER, 2, :expr_end)
2182
+ :tIDENTIFIER, "a", EXPR_CMDARG,
2183
+ :tOP_ASGN, ">>", EXPR_BEG,
2184
+ :tINTEGER, 2, EXPR_NUM)
2180
2185
  end
2181
2186
 
2182
2187
  def test_yylex_star
2183
2188
  assert_lex3("a * ",
2184
2189
  nil,
2185
- :tIDENTIFIER, "a", :expr_cmdarg,
2186
- :tSTAR2, "*", :expr_beg)
2190
+ :tIDENTIFIER, "a", EXPR_CMDARG,
2191
+ :tSTAR2, "*", EXPR_BEG)
2187
2192
  end
2188
2193
 
2189
2194
  def test_yylex_star2
2190
2195
  assert_lex3("a ** ",
2191
2196
  nil,
2192
- :tIDENTIFIER, "a", :expr_cmdarg,
2193
- :tPOW, "**", :expr_beg)
2197
+ :tIDENTIFIER, "a", EXPR_CMDARG,
2198
+ :tPOW, "**", EXPR_BEG)
2194
2199
  end
2195
2200
 
2196
2201
  def test_yylex_star2_equals
2197
2202
  assert_lex3("a **= ",
2198
2203
  nil,
2199
- :tIDENTIFIER, "a", :expr_cmdarg,
2200
- :tOP_ASGN, "**", :expr_beg)
2204
+ :tIDENTIFIER, "a", EXPR_CMDARG,
2205
+ :tOP_ASGN, "**", EXPR_BEG)
2201
2206
  end
2202
2207
 
2203
2208
  def test_yylex_star_arg
2204
- self.lex_state = :expr_arg
2209
+ self.lex_state = EXPR_ARG
2205
2210
 
2206
2211
  assert_lex3(" *a",
2207
2212
  nil,
2208
- :tSTAR, "*", :expr_beg,
2209
- :tIDENTIFIER, "a", :expr_arg)
2213
+ :tSTAR, "*", EXPR_BEG,
2214
+ :tIDENTIFIER, "a", EXPR_ARG)
2210
2215
  end
2211
2216
 
2212
2217
  def test_yylex_star_arg_beg
2213
- self.lex_state = :expr_beg
2218
+ self.lex_state = EXPR_BEG
2214
2219
 
2215
2220
  assert_lex3("*a",
2216
2221
  nil,
2217
- :tSTAR, "*", :expr_beg,
2218
- :tIDENTIFIER, "a", :expr_arg)
2222
+ :tSTAR, "*", EXPR_BEG,
2223
+ :tIDENTIFIER, "a", EXPR_ARG)
2219
2224
  end
2220
2225
 
2221
2226
  def test_yylex_star_arg_beg_fname
2222
- self.lex_state = :expr_fname
2227
+ self.lex_state = EXPR_FNAME
2223
2228
 
2224
2229
  assert_lex3("*a",
2225
2230
  nil,
2226
- :tSTAR2, "*", :expr_arg,
2227
- :tIDENTIFIER, "a", :expr_arg)
2231
+ :tSTAR2, "*", EXPR_ARG,
2232
+ :tIDENTIFIER, "a", EXPR_ARG)
2228
2233
  end
2229
2234
 
2230
2235
  def test_yylex_star_arg_beg_fname2
2231
- self.lex_state = :expr_fname
2236
+ self.lex_state = EXPR_FNAME
2232
2237
 
2233
2238
  assert_lex3("*a",
2234
2239
  nil,
2235
- :tSTAR2, "*", :expr_arg,
2236
- :tIDENTIFIER, "a", :expr_arg)
2240
+ :tSTAR2, "*", EXPR_ARG,
2241
+ :tIDENTIFIER, "a", EXPR_ARG)
2237
2242
  end
2238
2243
 
2239
2244
  def test_yylex_star_equals
2240
2245
  assert_lex3("a *= ",
2241
2246
  nil,
2242
- :tIDENTIFIER, "a", :expr_cmdarg,
2243
- :tOP_ASGN, "*", :expr_beg)
2247
+ :tIDENTIFIER, "a", EXPR_CMDARG,
2248
+ :tOP_ASGN, "*", EXPR_BEG)
2244
2249
  end
2245
2250
 
2246
2251
  def test_yylex_string_bad_eos
@@ -2252,31 +2257,31 @@ class TestRubyLexer < Minitest::Test
2252
2257
  end
2253
2258
 
2254
2259
  def test_yylex_string_double
2255
- assert_lex3("\"string\"", nil, :tSTRING, "string", :expr_end)
2260
+ assert_lex3("\"string\"", nil, :tSTRING, "string", EXPR_END)
2256
2261
  end
2257
2262
 
2258
2263
  def test_yylex_string_double_escape_C
2259
- assert_lex3("\"\\C-a\"", nil, :tSTRING, "\001", :expr_end)
2264
+ assert_lex3("\"\\C-a\"", nil, :tSTRING, "\001", EXPR_END)
2260
2265
  end
2261
2266
 
2262
2267
  def test_yylex_string_double_escape_C_backslash
2263
2268
  assert_lex3("\"\\C-\\\\\"",
2264
2269
  nil,
2265
- :tSTRING_BEG, "\"", :expr_beg,
2266
- :tSTRING_CONTENT, "\034", :expr_beg,
2267
- :tSTRING_END, "\"", :expr_end)
2270
+ :tSTRING_BEG, "\"", EXPR_BEG,
2271
+ :tSTRING_CONTENT, "\034", EXPR_BEG,
2272
+ :tSTRING_END, "\"", EXPR_END)
2268
2273
  end
2269
2274
 
2270
2275
  def test_yylex_string_double_escape_C_escape
2271
2276
  assert_lex3("\"\\C-\\M-a\"",
2272
2277
  nil,
2273
- :tSTRING_BEG, "\"", :expr_beg,
2274
- :tSTRING_CONTENT, "\201", :expr_beg,
2275
- :tSTRING_END, "\"", :expr_end)
2278
+ :tSTRING_BEG, "\"", EXPR_BEG,
2279
+ :tSTRING_CONTENT, "\201", EXPR_BEG,
2280
+ :tSTRING_END, "\"", EXPR_END)
2276
2281
  end
2277
2282
 
2278
2283
  def test_yylex_string_double_escape_C_question
2279
- assert_lex3("\"\\C-?\"", nil, :tSTRING, "\177", :expr_end)
2284
+ assert_lex3("\"\\C-?\"", nil, :tSTRING, "\177", EXPR_END)
2280
2285
  end
2281
2286
 
2282
2287
  def test_yylex_string_utf8_simple
@@ -2284,7 +2289,22 @@ class TestRubyLexer < Minitest::Test
2284
2289
 
2285
2290
  assert_lex3('"\u{3024}"',
2286
2291
  s(:str, chr),
2287
- :tSTRING, chr, :expr_end)
2292
+ :tSTRING, chr, EXPR_END)
2293
+ end
2294
+
2295
+ def test_yylex_string_utf8_trailing_hex
2296
+ chr = [0x3024].pack("U")
2297
+ str = "#{chr}abz"
2298
+
2299
+ assert_lex3('"\u3024abz"',
2300
+ s(:str, str),
2301
+ :tSTRING, str, EXPR_END)
2302
+ end
2303
+
2304
+ def test_yylex_string_utf8_missing_hex
2305
+ refute_lex('"\u3zzz"')
2306
+ refute_lex('"\u30zzz"')
2307
+ refute_lex('"\u302zzz"')
2288
2308
  end
2289
2309
 
2290
2310
  def test_yylex_string_utf8_complex
@@ -2292,234 +2312,282 @@ class TestRubyLexer < Minitest::Test
2292
2312
 
2293
2313
  assert_lex3('"#@a\u{3024}"',
2294
2314
  s(:dstr, "", s(:evstr, s(:ivar, :@a)), s(:str, chr)),
2295
- :tSTRING_BEG, '"', :expr_beg,
2296
- :tSTRING_DVAR, nil, :expr_beg,
2297
- :tSTRING_CONTENT, "@a"+chr, :expr_beg,
2298
- :tSTRING_END, '"', :expr_end)
2315
+ :tSTRING_BEG, '"', EXPR_BEG,
2316
+ :tSTRING_DVAR, nil, EXPR_BEG,
2317
+ :tSTRING_CONTENT, "@a"+chr, EXPR_BEG,
2318
+ :tSTRING_END, '"', EXPR_END)
2319
+ end
2320
+
2321
+ def test_yylex_string_utf8_complex_trailing_hex
2322
+ chr = [0x3024].pack("U")
2323
+ str = "#{chr}abz"
2324
+
2325
+ assert_lex3('"#@a\u3024abz"',
2326
+ s(:dstr, "", s(:evstr, s(:ivar, :@a)), s(:str, str)),
2327
+ :tSTRING_BEG, '"', EXPR_BEG,
2328
+ :tSTRING_DVAR, nil, EXPR_BEG,
2329
+ :tSTRING_CONTENT, "@a"+str, EXPR_BEG,
2330
+ :tSTRING_END, '"', EXPR_END)
2331
+ end
2332
+
2333
+ def test_yylex_string_utf8_complex_missing_hex
2334
+ chr = [0x302].pack("U")
2335
+ str = "#{chr}zzz"
2336
+
2337
+ refute_lex('"#@a\u302zzz"',
2338
+ :tSTRING_BEG, '"',
2339
+ :tSTRING_DVAR, nil,
2340
+ :tSTRING_CONTENT, "@a"+str,
2341
+ :tSTRING_END, '"')
2342
+
2343
+ chr = [0x30].pack("U")
2344
+ str = "#{chr}zzz"
2345
+
2346
+ refute_lex('"#@a\u30zzz"',
2347
+ :tSTRING_BEG, '"',
2348
+ :tSTRING_DVAR, nil,
2349
+ :tSTRING_CONTENT, "@a"+str,
2350
+ :tSTRING_END, '"')
2351
+
2352
+ chr = [0x3].pack("U")
2353
+ str = "#{chr}zzz"
2354
+
2355
+ refute_lex('"#@a\u3zzz"',
2356
+ :tSTRING_BEG, '"',
2357
+ :tSTRING_DVAR, nil,
2358
+ :tSTRING_CONTENT, "@a"+str,
2359
+ :tSTRING_END, '"')
2299
2360
  end
2300
2361
 
2301
2362
  def test_yylex_string_double_escape_M
2302
2363
  chr = "\341"
2303
- chr.force_encoding("UTF-8") if RubyLexer::HAS_ENC
2304
2364
 
2305
- assert_lex3("\"\\M-a\"", nil, :tSTRING, chr, :expr_end)
2365
+ assert_lex3("\"\\M-a\"", nil, :tSTRING, chr, EXPR_END)
2306
2366
  end
2307
2367
 
2308
2368
  def test_why_does_ruby_hate_me?
2309
2369
  assert_lex3("\"Nl%\\000\\000A\\000\\999\"", # you should be ashamed
2310
2370
  nil,
2311
- :tSTRING, ["Nl%","\x00","\x00","A","\x00","999"].join, :expr_end)
2371
+ :tSTRING, ["Nl%","\x00","\x00","A","\x00","999"].join, EXPR_END)
2312
2372
  end
2313
2373
 
2314
2374
  def test_yylex_string_double_escape_M_backslash
2315
2375
  assert_lex3("\"\\M-\\\\\"",
2316
2376
  nil,
2317
- :tSTRING_BEG, "\"", :expr_beg,
2318
- :tSTRING_CONTENT, "\334", :expr_beg,
2319
- :tSTRING_END, "\"", :expr_end)
2377
+ :tSTRING_BEG, "\"", EXPR_BEG,
2378
+ :tSTRING_CONTENT, "\334", EXPR_BEG,
2379
+ :tSTRING_END, "\"", EXPR_END)
2320
2380
  end
2321
2381
 
2322
2382
  def test_yylex_string_double_escape_M_escape
2323
2383
  assert_lex3("\"\\M-\\C-a\"",
2324
2384
  nil,
2325
- :tSTRING_BEG, "\"", :expr_beg,
2326
- :tSTRING_CONTENT, "\201", :expr_beg,
2327
- :tSTRING_END, "\"", :expr_end)
2385
+ :tSTRING_BEG, "\"", EXPR_BEG,
2386
+ :tSTRING_CONTENT, "\201", EXPR_BEG,
2387
+ :tSTRING_END, "\"", EXPR_END)
2328
2388
  end
2329
2389
 
2330
2390
  def test_yylex_string_double_escape_bs1
2331
- assert_lex3("\"a\\a\\a\"", nil, :tSTRING, "a\a\a", :expr_end)
2391
+ assert_lex3("\"a\\a\\a\"", nil, :tSTRING, "a\a\a", EXPR_END)
2332
2392
  end
2333
2393
 
2334
2394
  def test_yylex_string_double_escape_bs2
2335
- assert_lex3("\"a\\\\a\"", nil, :tSTRING, "a\\a", :expr_end)
2395
+ assert_lex3("\"a\\\\a\"", nil, :tSTRING, "a\\a", EXPR_END)
2336
2396
  end
2337
2397
 
2338
2398
  def test_yylex_string_double_escape_c
2339
- assert_lex3("\"\\ca\"", nil, :tSTRING, "\001", :expr_end)
2399
+ assert_lex3("\"\\ca\"", nil, :tSTRING, "\001", EXPR_END)
2340
2400
  end
2341
2401
 
2342
2402
  def test_yylex_string_double_escape_c_backslash
2343
2403
  assert_lex3("\"\\c\\\"",
2344
2404
  nil,
2345
- :tSTRING_BEG, "\"", :expr_beg,
2346
- :tSTRING_CONTENT, "\034", :expr_beg,
2347
- :tSTRING_END, "\"", :expr_end)
2405
+ :tSTRING_BEG, "\"", EXPR_BEG,
2406
+ :tSTRING_CONTENT, "\034", EXPR_BEG,
2407
+ :tSTRING_END, "\"", EXPR_END)
2348
2408
  end
2349
2409
 
2350
2410
  def test_yylex_string_double_escape_c_escape
2351
2411
  assert_lex3("\"\\c\\M-a\"",
2352
2412
  nil,
2353
- :tSTRING_BEG, "\"", :expr_beg,
2354
- :tSTRING_CONTENT, "\201", :expr_beg,
2355
- :tSTRING_END, "\"", :expr_end)
2413
+ :tSTRING_BEG, "\"", EXPR_BEG,
2414
+ :tSTRING_CONTENT, "\201", EXPR_BEG,
2415
+ :tSTRING_END, "\"", EXPR_END)
2356
2416
  end
2357
2417
 
2358
2418
  def test_yylex_string_double_escape_c_question
2359
- assert_lex3("\"\\c?\"", nil, :tSTRING, "\177", :expr_end)
2419
+ assert_lex3("\"\\c?\"", nil, :tSTRING, "\177", EXPR_END)
2360
2420
  end
2361
2421
 
2362
2422
  def test_yylex_string_double_escape_chars
2363
- assert_lex3("\"s\\tri\\ng\"", nil, :tSTRING, "s\tri\ng", :expr_end)
2423
+ assert_lex3("\"s\\tri\\ng\"", nil, :tSTRING, "s\tri\ng", EXPR_END)
2364
2424
  end
2365
2425
 
2366
2426
  def test_yylex_string_double_escape_hex
2367
- assert_lex3("\"n = \\x61\\x62\\x63\"", nil, :tSTRING, "n = abc", :expr_end)
2427
+ assert_lex3("\"n = \\x61\\x62\\x63\"", nil, :tSTRING, "n = abc", EXPR_END)
2368
2428
  end
2369
2429
 
2370
2430
  def test_yylex_string_double_escape_octal
2371
- assert_lex3("\"n = \\101\\102\\103\"", nil, :tSTRING, "n = ABC", :expr_end)
2431
+ assert_lex3("\"n = \\101\\102\\103\"", nil, :tSTRING, "n = ABC", EXPR_END)
2372
2432
  end
2373
2433
 
2374
2434
  def test_yylex_string_double_escape_octal_fucked
2375
- assert_lex3("\"n = \\444\"", nil, :tSTRING, "n = $", :expr_end)
2435
+ assert_lex3("\"n = \\444\"", nil, :tSTRING, "n = $", EXPR_END)
2376
2436
  end
2377
2437
 
2378
2438
  def test_yylex_string_double_interp
2379
2439
  assert_lex3("\"blah #x a \#@a b \#$b c \#{3} # \"",
2380
2440
  nil,
2381
- :tSTRING_BEG, "\"", :expr_beg,
2382
- :tSTRING_CONTENT, "blah #x a ", :expr_beg,
2383
- :tSTRING_DVAR, nil, :expr_beg,
2384
- :tSTRING_CONTENT, "@a b ", :expr_beg,
2385
- :tSTRING_DVAR, nil, :expr_beg,
2386
- :tSTRING_CONTENT, "$b c ", :expr_beg,
2387
- :tSTRING_DBEG, nil, :expr_beg,
2388
- :tSTRING_CONTENT, "3} # ", :expr_beg,
2389
- :tSTRING_END, "\"", :expr_end)
2441
+ :tSTRING_BEG, "\"", EXPR_BEG,
2442
+ :tSTRING_CONTENT, "blah #x a ", EXPR_BEG,
2443
+ :tSTRING_DVAR, nil, EXPR_BEG,
2444
+ :tSTRING_CONTENT, "@a b ", EXPR_BEG,
2445
+ :tSTRING_DVAR, nil, EXPR_BEG,
2446
+ :tSTRING_CONTENT, "$b c ", EXPR_BEG,
2447
+ :tSTRING_DBEG, nil, EXPR_BEG,
2448
+ :tSTRING_CONTENT, "3} # ", EXPR_BEG,
2449
+ :tSTRING_END, "\"", EXPR_END)
2390
2450
  end
2391
2451
 
2392
2452
  def test_yylex_string_double_pound_dollar_bad
2393
2453
  assert_lex3('"#$%"', nil,
2394
2454
 
2395
- :tSTRING_BEG, "\"", :expr_beg,
2396
- :tSTRING_CONTENT, '#$%', :expr_beg,
2397
- :tSTRING_END, "\"", :expr_end)
2455
+ :tSTRING_BEG, "\"", EXPR_BEG,
2456
+ :tSTRING_CONTENT, '#$%', EXPR_BEG,
2457
+ :tSTRING_END, "\"", EXPR_END)
2398
2458
  end
2399
2459
 
2400
2460
  def test_yylex_string_double_nested_curlies
2401
2461
  assert_lex3("%{nest{one{two}one}nest}",
2402
2462
  nil,
2403
- :tSTRING_BEG, "%}", :expr_beg,
2404
- :tSTRING_CONTENT, "nest{one{two}one}nest", :expr_beg,
2405
- :tSTRING_END, "}", :expr_end)
2463
+ :tSTRING_BEG, "%}", EXPR_BEG,
2464
+ :tSTRING_CONTENT, "nest{one{two}one}nest", EXPR_BEG,
2465
+ :tSTRING_END, "}", EXPR_END)
2406
2466
  end
2407
2467
 
2408
2468
  def test_yylex_string_double_no_interp
2409
- assert_lex3("\"# blah\"", nil, :tSTRING, "# blah", :expr_end)
2410
- assert_lex3("\"blah # blah\"", nil, :tSTRING, "blah # blah", :expr_end)
2469
+ assert_lex3("\"# blah\"", nil, :tSTRING, "# blah", EXPR_END)
2470
+ assert_lex3("\"blah # blah\"", nil, :tSTRING, "blah # blah", EXPR_END)
2411
2471
  end
2412
2472
 
2413
2473
  def test_yylex_string_escape_x_single
2414
- assert_lex3("\"\\x0\"", nil, :tSTRING, "\000", :expr_end)
2474
+ assert_lex3("\"\\x0\"", nil, :tSTRING, "\000", EXPR_END)
2415
2475
  end
2416
2476
 
2417
2477
  def test_yylex_string_pct_i
2418
2478
  assert_lex3("%i[s1 s2\ns3]",
2419
2479
  nil,
2420
- :tQSYMBOLS_BEG, "%i[", :expr_beg,
2421
- :tSTRING_CONTENT, "s1", :expr_beg,
2422
- :tSPACE, nil, :expr_beg,
2423
- :tSTRING_CONTENT, "s2", :expr_beg,
2424
- :tSPACE, nil, :expr_beg,
2425
- :tSTRING_CONTENT, "s3", :expr_beg,
2426
- :tSPACE, nil, :expr_beg,
2427
- :tSTRING_END, nil, :expr_end)
2480
+ :tQSYMBOLS_BEG, "%i[", EXPR_BEG,
2481
+ :tSTRING_CONTENT, "s1", EXPR_BEG,
2482
+ :tSPACE, nil, EXPR_BEG,
2483
+ :tSTRING_CONTENT, "s2", EXPR_BEG,
2484
+ :tSPACE, nil, EXPR_BEG,
2485
+ :tSTRING_CONTENT, "s3", EXPR_BEG,
2486
+ :tSPACE, nil, EXPR_BEG,
2487
+ :tSTRING_END, nil, EXPR_END)
2428
2488
  end
2429
2489
 
2430
2490
  def test_yylex_string_pct_I
2431
2491
  assert_lex3("%I[s1 s2\ns3]",
2432
2492
  nil,
2433
- :tSYMBOLS_BEG, "%I[", :expr_beg,
2434
- :tSTRING_CONTENT, "s1", :expr_beg,
2435
- :tSPACE, nil, :expr_beg,
2436
- :tSTRING_CONTENT, "s2", :expr_beg,
2437
- :tSPACE, nil, :expr_beg,
2438
- :tSTRING_CONTENT, "s3", :expr_beg,
2439
- :tSPACE, nil, :expr_beg,
2440
- :tSTRING_END, nil, :expr_end)
2493
+ :tSYMBOLS_BEG, "%I[", EXPR_BEG,
2494
+ :tSTRING_CONTENT, "s1", EXPR_BEG,
2495
+ :tSPACE, nil, EXPR_BEG,
2496
+ :tSTRING_CONTENT, "s2", EXPR_BEG,
2497
+ :tSPACE, nil, EXPR_BEG,
2498
+ :tSTRING_CONTENT, "s3", EXPR_BEG,
2499
+ :tSPACE, nil, EXPR_BEG,
2500
+ :tSTRING_END, nil, EXPR_END)
2441
2501
  end
2442
2502
 
2443
2503
  def test_yylex_string_pct_i_extra_space
2444
2504
  assert_lex3("%i[ s1 s2\ns3 ]",
2445
2505
  nil,
2446
- :tQSYMBOLS_BEG, "%i[", :expr_beg,
2447
- :tSTRING_CONTENT, "s1", :expr_beg,
2448
- :tSPACE, nil, :expr_beg,
2449
- :tSTRING_CONTENT, "s2", :expr_beg,
2450
- :tSPACE, nil, :expr_beg,
2451
- :tSTRING_CONTENT, "s3", :expr_beg,
2452
- :tSPACE, nil, :expr_beg,
2453
- :tSTRING_END, nil, :expr_end)
2506
+ :tQSYMBOLS_BEG, "%i[", EXPR_BEG,
2507
+ :tSTRING_CONTENT, "s1", EXPR_BEG,
2508
+ :tSPACE, nil, EXPR_BEG,
2509
+ :tSTRING_CONTENT, "s2", EXPR_BEG,
2510
+ :tSPACE, nil, EXPR_BEG,
2511
+ :tSTRING_CONTENT, "s3", EXPR_BEG,
2512
+ :tSPACE, nil, EXPR_BEG,
2513
+ :tSTRING_END, nil, EXPR_END)
2454
2514
  end
2455
2515
 
2456
2516
  def test_yylex_string_pct_I_extra_space
2457
2517
  assert_lex3("%I[ s1 s2\ns3 ]",
2458
2518
  nil,
2459
- :tSYMBOLS_BEG, "%I[", :expr_beg,
2460
- :tSTRING_CONTENT, "s1", :expr_beg,
2461
- :tSPACE, nil, :expr_beg,
2462
- :tSTRING_CONTENT, "s2", :expr_beg,
2463
- :tSPACE, nil, :expr_beg,
2464
- :tSTRING_CONTENT, "s3", :expr_beg,
2465
- :tSPACE, nil, :expr_beg,
2466
- :tSTRING_END, nil, :expr_end)
2519
+ :tSYMBOLS_BEG, "%I[", EXPR_BEG,
2520
+ :tSTRING_CONTENT, "s1", EXPR_BEG,
2521
+ :tSPACE, nil, EXPR_BEG,
2522
+ :tSTRING_CONTENT, "s2", EXPR_BEG,
2523
+ :tSPACE, nil, EXPR_BEG,
2524
+ :tSTRING_CONTENT, "s3", EXPR_BEG,
2525
+ :tSPACE, nil, EXPR_BEG,
2526
+ :tSTRING_END, nil, EXPR_END)
2467
2527
  end
2468
2528
 
2469
2529
  def test_yylex_string_pct_q
2470
2530
  assert_lex3("%q[s1 s2]",
2471
2531
  nil,
2472
- :tSTRING_BEG, "%q[", :expr_beg,
2473
- :tSTRING_CONTENT, "s1 s2", :expr_beg,
2474
- :tSTRING_END, "]", :expr_end)
2532
+ :tSTRING_BEG, "%q[", EXPR_BEG,
2533
+ :tSTRING_CONTENT, "s1 s2", EXPR_BEG,
2534
+ :tSTRING_END, "]", EXPR_END)
2475
2535
  end
2476
2536
 
2477
2537
  def test_yylex_string_pct_Q
2478
2538
  assert_lex3("%Q[s1 s2]",
2479
2539
  nil,
2480
- :tSTRING_BEG, "%Q[", :expr_beg,
2481
- :tSTRING_CONTENT, "s1 s2", :expr_beg,
2482
- :tSTRING_END, "]", :expr_end)
2540
+ :tSTRING_BEG, "%Q[", EXPR_BEG,
2541
+ :tSTRING_CONTENT, "s1 s2", EXPR_BEG,
2542
+ :tSTRING_END, "]", EXPR_END)
2543
+ end
2544
+
2545
+ def test_yylex_string_pct_s
2546
+ assert_lex3("%s[s1 s2]",
2547
+ nil,
2548
+ :tSYMBEG, "%s[", EXPR_FNAME, # TODO: :tSYM_BEG ?
2549
+ :tSTRING_CONTENT, "s1 s2", EXPR_FNAME, # man... I don't like this
2550
+ :tSTRING_END, "]", EXPR_END)
2483
2551
  end
2484
2552
 
2485
2553
  def test_yylex_string_pct_W
2486
2554
  assert_lex3("%W[s1 s2\ns3]", # TODO: add interpolation to these
2487
2555
  nil,
2488
- :tWORDS_BEG, "%W[", :expr_beg,
2489
- :tSTRING_CONTENT, "s1", :expr_beg,
2490
- :tSPACE, nil, :expr_beg,
2491
- :tSTRING_CONTENT, "s2", :expr_beg,
2492
- :tSPACE, nil, :expr_beg,
2493
- :tSTRING_CONTENT, "s3", :expr_beg,
2494
- :tSPACE, nil, :expr_beg,
2495
- :tSTRING_END, nil, :expr_end)
2556
+ :tWORDS_BEG, "%W[", EXPR_BEG,
2557
+ :tSTRING_CONTENT, "s1", EXPR_BEG,
2558
+ :tSPACE, nil, EXPR_BEG,
2559
+ :tSTRING_CONTENT, "s2", EXPR_BEG,
2560
+ :tSPACE, nil, EXPR_BEG,
2561
+ :tSTRING_CONTENT, "s3", EXPR_BEG,
2562
+ :tSPACE, nil, EXPR_BEG,
2563
+ :tSTRING_END, nil, EXPR_END)
2496
2564
  end
2497
2565
 
2498
2566
  def test_yylex_string_pct_W_bs_nl
2499
2567
  assert_lex3("%W[s1 \\\ns2]", # TODO: add interpolation to these
2500
2568
  nil,
2501
- :tWORDS_BEG, "%W[", :expr_beg,
2502
- :tSTRING_CONTENT, "s1", :expr_beg,
2503
- :tSPACE, nil, :expr_beg,
2504
- :tSTRING_CONTENT, "\ns2", :expr_beg,
2505
- :tSPACE, nil, :expr_beg,
2506
- :tSTRING_END, nil, :expr_end)
2569
+ :tWORDS_BEG, "%W[", EXPR_BEG,
2570
+ :tSTRING_CONTENT, "s1", EXPR_BEG,
2571
+ :tSPACE, nil, EXPR_BEG,
2572
+ :tSTRING_CONTENT, "\ns2", EXPR_BEG,
2573
+ :tSPACE, nil, EXPR_BEG,
2574
+ :tSTRING_END, nil, EXPR_END)
2507
2575
  end
2508
2576
 
2509
2577
  def test_yylex_string_pct_angle
2510
2578
  assert_lex3("%<blah>",
2511
2579
  nil,
2512
- :tSTRING_BEG, "%>", :expr_beg,
2513
- :tSTRING_CONTENT, "blah", :expr_beg,
2514
- :tSTRING_END, ">", :expr_end)
2580
+ :tSTRING_BEG, "%>", EXPR_BEG,
2581
+ :tSTRING_CONTENT, "blah", EXPR_BEG,
2582
+ :tSTRING_END, ">", EXPR_END)
2515
2583
  end
2516
2584
 
2517
2585
  def test_yylex_string_pct_other
2518
2586
  assert_lex3("%%blah%",
2519
2587
  nil,
2520
- :tSTRING_BEG, "%%", :expr_beg,
2521
- :tSTRING_CONTENT, "blah", :expr_beg,
2522
- :tSTRING_END, "%", :expr_end)
2588
+ :tSTRING_BEG, "%%", EXPR_BEG,
2589
+ :tSTRING_CONTENT, "blah", EXPR_BEG,
2590
+ :tSTRING_END, "%", EXPR_END)
2523
2591
  end
2524
2592
 
2525
2593
  def test_yylex_string_pct_w
@@ -2534,130 +2602,130 @@ class TestRubyLexer < Minitest::Test
2534
2602
  def test_yylex_string_pct_w_bs_nl
2535
2603
  assert_lex3("%w[s1 \\\ns2]",
2536
2604
  nil,
2537
- :tQWORDS_BEG, "%w[", :expr_beg,
2538
- :tSTRING_CONTENT, "s1", :expr_beg,
2539
- :tSPACE, nil, :expr_beg,
2540
- :tSTRING_CONTENT, "\ns2", :expr_beg,
2541
- :tSPACE, nil, :expr_beg,
2542
- :tSTRING_END, nil, :expr_end)
2605
+ :tQWORDS_BEG, "%w[", EXPR_BEG,
2606
+ :tSTRING_CONTENT, "s1", EXPR_BEG,
2607
+ :tSPACE, nil, EXPR_BEG,
2608
+ :tSTRING_CONTENT, "\ns2", EXPR_BEG,
2609
+ :tSPACE, nil, EXPR_BEG,
2610
+ :tSTRING_END, nil, EXPR_END)
2543
2611
  end
2544
2612
 
2545
2613
  def test_yylex_string_pct_w_bs_sp
2546
2614
  assert_lex3("%w[s\\ 1 s\\ 2]",
2547
2615
  nil,
2548
- :tQWORDS_BEG, "%w[", :expr_beg,
2549
- :tSTRING_CONTENT, "s 1", :expr_beg,
2550
- :tSPACE, nil, :expr_beg,
2551
- :tSTRING_CONTENT, "s 2", :expr_beg,
2552
- :tSPACE, nil, :expr_beg,
2553
- :tSTRING_END, nil, :expr_end)
2616
+ :tQWORDS_BEG, "%w[", EXPR_BEG,
2617
+ :tSTRING_CONTENT, "s 1", EXPR_BEG,
2618
+ :tSPACE, nil, EXPR_BEG,
2619
+ :tSTRING_CONTENT, "s 2", EXPR_BEG,
2620
+ :tSPACE, nil, EXPR_BEG,
2621
+ :tSTRING_END, nil, EXPR_END)
2554
2622
  end
2555
2623
 
2556
2624
  def test_yylex_string_single
2557
- assert_lex3("'string'", nil, :tSTRING, "string", :expr_end)
2625
+ assert_lex3("'string'", nil, :tSTRING, "string", EXPR_END)
2558
2626
  end
2559
2627
 
2560
2628
  def test_yylex_string_single_escape_chars
2561
- assert_lex3("'s\\tri\\ng'", nil, :tSTRING, "s\\tri\\ng", :expr_end)
2629
+ assert_lex3("'s\\tri\\ng'", nil, :tSTRING, "s\\tri\\ng", EXPR_END)
2562
2630
  end
2563
2631
 
2564
2632
  def test_yylex_string_single_nl
2565
- assert_lex3("'blah\\\nblah'", nil, :tSTRING, "blah\\\nblah", :expr_end)
2633
+ assert_lex3("'blah\\\nblah'", nil, :tSTRING, "blah\\\nblah", EXPR_END)
2566
2634
  end
2567
2635
 
2568
2636
  def test_yylex_string_single_escaped_quote
2569
- assert_lex3("'foo\\'bar'", nil, :tSTRING, "foo'bar", :expr_end)
2637
+ assert_lex3("'foo\\'bar'", nil, :tSTRING, "foo'bar", EXPR_END)
2570
2638
  end
2571
2639
 
2572
2640
  def test_yylex_symbol
2573
- assert_lex3(":symbol", nil, :tSYMBOL, "symbol", :expr_end)
2641
+ assert_lex3(":symbol", nil, :tSYMBOL, "symbol", EXPR_END)
2574
2642
  end
2575
2643
 
2576
2644
  def test_yylex_symbol_zero_byte
2577
2645
  assert_lex(":\"symbol\0\"", nil,
2578
- :tSYMBOL, "symbol\0", :expr_end)
2646
+ :tSYMBOL, "symbol\0", EXPR_END)
2579
2647
  end
2580
2648
 
2581
2649
  def test_yylex_symbol_double
2582
2650
  assert_lex3(":\"symbol\"",
2583
2651
  nil,
2584
- :tSYMBOL, "symbol", :expr_end)
2652
+ :tSYMBOL, "symbol", EXPR_END)
2585
2653
  end
2586
2654
 
2587
2655
  def test_yylex_symbol_double_interp
2588
2656
  assert_lex3(':"symbol#{1+1}"',
2589
2657
  nil,
2590
- :tSYMBEG, ":", :expr_fname,
2591
- :tSTRING_CONTENT, "symbol", :expr_fname,
2592
- :tSTRING_DBEG, nil, :expr_fname,
2593
- :tSTRING_CONTENT, "1+1}", :expr_fname, # HUH? this is BS
2594
- :tSTRING_END, "\"", :expr_end)
2658
+ :tSYMBEG, ":", EXPR_FNAME,
2659
+ :tSTRING_CONTENT, "symbol", EXPR_FNAME,
2660
+ :tSTRING_DBEG, nil, EXPR_FNAME,
2661
+ :tSTRING_CONTENT, "1+1}", EXPR_FNAME, # HUH? this is BS
2662
+ :tSTRING_END, "\"", EXPR_END)
2595
2663
  end
2596
2664
 
2597
2665
  def test_yylex_symbol_single
2598
2666
  assert_lex3(":'symbol'",
2599
2667
  nil,
2600
- :tSYMBOL, "symbol", :expr_end)
2668
+ :tSYMBOL, "symbol", EXPR_END)
2601
2669
  end
2602
2670
 
2603
2671
  def test_yylex_symbol_single_noninterp
2604
2672
  assert_lex3(':\'symbol#{1+1}\'',
2605
2673
  nil,
2606
- :tSYMBOL, 'symbol#{1+1}', :expr_end)
2674
+ :tSYMBOL, 'symbol#{1+1}', EXPR_END)
2607
2675
  end
2608
2676
 
2609
2677
  def test_yylex_symbol_single_escape_chars
2610
2678
  assert_lex3(":'s\\tri\\ng'",
2611
2679
  nil,
2612
- :tSYMBOL, "s\\tri\\ng", :expr_end)
2680
+ :tSYMBOL, "s\\tri\\ng", EXPR_END)
2613
2681
  end
2614
2682
 
2615
2683
  def test_yylex_string_single_escape_quote_and_backslash
2616
- assert_lex3(":'foo\\'bar\\\\baz'", nil, :tSYMBOL, "foo'bar\\baz", :expr_end)
2684
+ assert_lex3(":'foo\\'bar\\\\baz'", nil, :tSYMBOL, "foo'bar\\baz", EXPR_END)
2617
2685
  end
2618
2686
 
2619
2687
  def test_yylex_ternary1
2620
2688
  assert_lex3("a ? b : c",
2621
2689
  nil,
2622
- :tIDENTIFIER, "a", :expr_cmdarg,
2623
- :tEH, "?", :expr_value,
2624
- :tIDENTIFIER, "b", :expr_arg,
2625
- :tCOLON, ":", :expr_beg,
2626
- :tIDENTIFIER, "c", :expr_arg)
2690
+ :tIDENTIFIER, "a", EXPR_CMDARG,
2691
+ :tEH, "?", EXPR_BEG,
2692
+ :tIDENTIFIER, "b", EXPR_ARG,
2693
+ :tCOLON, ":", EXPR_BEG,
2694
+ :tIDENTIFIER, "c", EXPR_ARG)
2627
2695
 
2628
2696
  assert_lex3("a ?bb : c", # GAH! MATZ!!!
2629
2697
  nil,
2630
- :tIDENTIFIER, "a", :expr_cmdarg,
2631
- :tEH, "?", :expr_beg,
2632
- :tIDENTIFIER, "bb", :expr_arg,
2633
- :tCOLON, ":", :expr_beg,
2634
- :tIDENTIFIER, "c", :expr_arg)
2698
+ :tIDENTIFIER, "a", EXPR_CMDARG,
2699
+ :tEH, "?", EXPR_BEG,
2700
+ :tIDENTIFIER, "bb", EXPR_ARG,
2701
+ :tCOLON, ":", EXPR_BEG,
2702
+ :tIDENTIFIER, "c", EXPR_ARG)
2635
2703
 
2636
2704
  assert_lex3("42 ?",
2637
2705
  nil,
2638
- :tINTEGER, 42, :expr_end,
2639
- :tEH, "?", :expr_value)
2706
+ :tINTEGER, 42, EXPR_NUM,
2707
+ :tEH, "?", EXPR_BEG)
2640
2708
  end
2641
2709
 
2642
2710
  def test_yylex_tilde
2643
- assert_lex3("~", nil, :tTILDE, "~", :expr_beg)
2711
+ assert_lex3("~", nil, :tTILDE, "~", EXPR_BEG)
2644
2712
  end
2645
2713
 
2646
2714
  def test_yylex_tilde_unary
2647
- self.lex_state = :expr_fname
2715
+ self.lex_state = EXPR_FNAME
2648
2716
 
2649
- assert_lex3("~@", nil, :tTILDE, "~", :expr_arg)
2717
+ assert_lex3("~@", nil, :tTILDE, "~", EXPR_ARG)
2650
2718
  end
2651
2719
 
2652
2720
  def test_yylex_uminus
2653
2721
  assert_lex3("-blah",
2654
2722
  nil,
2655
- :tUMINUS, "-", :expr_beg,
2656
- :tIDENTIFIER, "blah", :expr_arg)
2723
+ :tUMINUS, "-", EXPR_BEG,
2724
+ :tIDENTIFIER, "blah", EXPR_ARG)
2657
2725
  end
2658
2726
 
2659
2727
  def test_yylex_underscore
2660
- assert_lex3("_var", nil, :tIDENTIFIER, "_var", :expr_cmdarg)
2728
+ assert_lex3("_var", nil, :tIDENTIFIER, "_var", EXPR_CMDARG)
2661
2729
  end
2662
2730
 
2663
2731
  def test_yylex_underscore_end
@@ -2669,46 +2737,46 @@ class TestRubyLexer < Minitest::Test
2669
2737
  def test_yylex_uplus
2670
2738
  assert_lex3("+blah",
2671
2739
  nil,
2672
- :tUPLUS, "+", :expr_beg,
2673
- :tIDENTIFIER, "blah", :expr_arg)
2740
+ :tUPLUS, "+", EXPR_BEG,
2741
+ :tIDENTIFIER, "blah", EXPR_ARG)
2674
2742
  end
2675
2743
 
2676
2744
  def test_zbug_float_in_decl
2677
2745
  assert_lex3("def initialize(u = 0.0, s = 0.0",
2678
2746
  nil,
2679
- :kDEF, "def", :expr_fname,
2680
- :tIDENTIFIER, "initialize", :expr_endfn,
2681
- :tLPAREN2, "(", :expr_beg,
2682
- :tIDENTIFIER, "u", :expr_arg,
2683
- :tEQL, "=", :expr_beg,
2684
- :tFLOAT, 0.0, :expr_end,
2685
- :tCOMMA, ",", :expr_beg,
2686
- :tIDENTIFIER, "s", :expr_arg,
2687
- :tEQL, "=", :expr_beg,
2688
- :tFLOAT, 0.0, :expr_end)
2747
+ :kDEF, "def", EXPR_FNAME,
2748
+ :tIDENTIFIER, "initialize", EXPR_ENDFN,
2749
+ :tLPAREN2, "(", EXPR_PAR,
2750
+ :tIDENTIFIER, "u", EXPR_ARG,
2751
+ :tEQL, "=", EXPR_BEG,
2752
+ :tFLOAT, 0.0, EXPR_NUM,
2753
+ :tCOMMA, ",", EXPR_PAR,
2754
+ :tIDENTIFIER, "s", EXPR_ARG,
2755
+ :tEQL, "=", EXPR_BEG,
2756
+ :tFLOAT, 0.0, EXPR_NUM)
2689
2757
  end
2690
2758
 
2691
2759
  def test_zbug_id_equals
2692
2760
  assert_lex3("a = 0.0",
2693
2761
  nil,
2694
- :tIDENTIFIER, "a", :expr_cmdarg,
2695
- :tEQL, "=", :expr_beg,
2696
- :tFLOAT, 0.0, :expr_end)
2762
+ :tIDENTIFIER, "a", EXPR_CMDARG,
2763
+ :tEQL, "=", EXPR_BEG,
2764
+ :tFLOAT, 0.0, EXPR_NUM)
2697
2765
  end
2698
2766
 
2699
2767
  def test_zbug_no_spaces_in_decl
2700
2768
  assert_lex3("def initialize(u=0.0,s=0.0",
2701
2769
  nil,
2702
- :kDEF, "def", :expr_fname,
2703
- :tIDENTIFIER, "initialize", :expr_endfn,
2704
- :tLPAREN2, "(", :expr_beg,
2705
- :tIDENTIFIER, "u", :expr_arg,
2706
- :tEQL, "=", :expr_beg,
2707
- :tFLOAT, 0.0, :expr_end,
2708
- :tCOMMA, ",", :expr_beg,
2709
- :tIDENTIFIER, "s", :expr_arg,
2710
- :tEQL, "=", :expr_beg,
2711
- :tFLOAT, 0.0, :expr_end)
2770
+ :kDEF, "def", EXPR_FNAME,
2771
+ :tIDENTIFIER, "initialize", EXPR_ENDFN,
2772
+ :tLPAREN2, "(", EXPR_PAR,
2773
+ :tIDENTIFIER, "u", EXPR_ARG,
2774
+ :tEQL, "=", EXPR_BEG,
2775
+ :tFLOAT, 0.0, EXPR_NUM,
2776
+ :tCOMMA, ",", EXPR_PAR,
2777
+ :tIDENTIFIER, "s", EXPR_ARG,
2778
+ :tEQL, "=", EXPR_BEG,
2779
+ :tFLOAT, 0.0, EXPR_NUM)
2712
2780
  end
2713
2781
 
2714
2782
  def test_pct_w_backslashes
@@ -2718,12 +2786,12 @@ class TestRubyLexer < Minitest::Test
2718
2786
  assert_lex("%w[foo#{char}bar]",
2719
2787
  s(:array, s(:str, "foo"), s(:str, "bar")),
2720
2788
 
2721
- :tQWORDS_BEG, "%w[", :expr_beg, 0, 0,
2722
- :tSTRING_CONTENT, "foo", :expr_beg, 0, 0,
2723
- :tSPACE, nil, :expr_beg, 0, 0,
2724
- :tSTRING_CONTENT, "bar", :expr_beg, 0, 0,
2725
- :tSPACE, nil, :expr_beg, 0, 0,
2726
- :tSTRING_END, nil, :expr_end, 0, 0)
2789
+ :tQWORDS_BEG, "%w[", EXPR_BEG, 0, 0,
2790
+ :tSTRING_CONTENT, "foo", EXPR_BEG, 0, 0,
2791
+ :tSPACE, nil, EXPR_BEG, 0, 0,
2792
+ :tSTRING_CONTENT, "bar", EXPR_BEG, 0, 0,
2793
+ :tSPACE, nil, EXPR_BEG, 0, 0,
2794
+ :tSTRING_END, nil, EXPR_END, 0, 0)
2727
2795
  end
2728
2796
  end
2729
2797
 
@@ -2731,17 +2799,17 @@ class TestRubyLexer < Minitest::Test
2731
2799
  assert_lex(":'a'",
2732
2800
  s(:lit, :a),
2733
2801
 
2734
- :tSYMBOL, "a", :expr_end, 0, 0)
2802
+ :tSYMBOL, "a", EXPR_END, 0, 0)
2735
2803
  end
2736
2804
 
2737
2805
  def test_yylex_hash_colon
2738
2806
  assert_lex("{a:1}",
2739
2807
  s(:hash, s(:lit, :a), s(:lit, 1)),
2740
2808
 
2741
- :tLBRACE, "{", :expr_beg, 0, 1,
2742
- :tLABEL, "a", :expr_labeled, 0, 1,
2743
- :tINTEGER, 1, :expr_end, 0, 1,
2744
- :tRCURLY, "}", :expr_endarg, 0, 0)
2809
+ :tLBRACE, "{", EXPR_PAR, 0, 1,
2810
+ :tLABEL, "a", EXPR_LAB, 0, 1,
2811
+ :tINTEGER, 1, EXPR_NUM, 0, 1,
2812
+ :tRCURLY, "}", EXPR_ENDARG, 0, 0)
2745
2813
  end
2746
2814
 
2747
2815
  def test_yylex_hash_colon_quoted_22
@@ -2750,10 +2818,10 @@ class TestRubyLexer < Minitest::Test
2750
2818
  assert_lex("{'a':1}",
2751
2819
  s(:hash, s(:lit, :a), s(:lit, 1)),
2752
2820
 
2753
- :tLBRACE, "{", :expr_beg, 0, 1,
2754
- :tLABEL, "a", :expr_labeled, 0, 1,
2755
- :tINTEGER, 1, :expr_end, 0, 1,
2756
- :tRCURLY, "}", :expr_endarg, 0, 0)
2821
+ :tLBRACE, "{", EXPR_PAR, 0, 1,
2822
+ :tLABEL, "a", EXPR_LAB, 0, 1,
2823
+ :tINTEGER, 1, EXPR_NUM, 0, 1,
2824
+ :tRCURLY, "}", EXPR_ENDARG, 0, 0)
2757
2825
  end
2758
2826
 
2759
2827
  def test_yylex_hash_colon_quoted_symbol_22
@@ -2762,10 +2830,10 @@ class TestRubyLexer < Minitest::Test
2762
2830
  assert_lex("{'abc': :b}",
2763
2831
  s(:hash, s(:lit, :abc), s(:lit, :b)),
2764
2832
 
2765
- :tLBRACE, "{", :expr_beg, 0, 1,
2766
- :tLABEL, "abc", :expr_labeled, 0, 1,
2767
- :tSYMBOL, "b", :expr_end, 0, 1,
2768
- :tRCURLY, "}", :expr_endarg, 0, 0)
2833
+ :tLBRACE, "{", EXPR_PAR, 0, 1,
2834
+ :tLABEL, "abc", EXPR_LAB, 0, 1,
2835
+ :tSYMBOL, "b", EXPR_END, 0, 1,
2836
+ :tRCURLY, "}", EXPR_ENDARG, 0, 0)
2769
2837
  end
2770
2838
 
2771
2839
  def test_yylex_hash_colon_double_quoted_symbol_22
@@ -2774,10 +2842,10 @@ class TestRubyLexer < Minitest::Test
2774
2842
  assert_lex('{"abc": :b}',
2775
2843
  s(:hash, s(:lit, :abc), s(:lit, :b)),
2776
2844
 
2777
- :tLBRACE, "{", :expr_beg, 0, 1,
2778
- :tLABEL, "abc", :expr_labeled, 0, 1,
2779
- :tSYMBOL, "b", :expr_end, 0, 1,
2780
- :tRCURLY, "}", :expr_endarg, 0, 0)
2845
+ :tLBRACE, "{", EXPR_PAR, 0, 1,
2846
+ :tLABEL, "abc", EXPR_LAB, 0, 1,
2847
+ :tSYMBOL, "b", EXPR_END, 0, 1,
2848
+ :tRCURLY, "}", EXPR_ENDARG, 0, 0)
2781
2849
  end
2782
2850
 
2783
2851
  def test_yylex_required_kwarg_no_value_22
@@ -2785,12 +2853,12 @@ class TestRubyLexer < Minitest::Test
2785
2853
 
2786
2854
  assert_lex3("def foo a:, b:\nend",
2787
2855
  nil,
2788
- :kDEF, "def", :expr_fname,
2789
- :tIDENTIFIER, "foo", :expr_endfn,
2790
- :tLABEL, "a", :expr_labeled,
2791
- :tCOMMA, ",", :expr_beg,
2792
- :tLABEL, "b", :expr_labeled,
2793
- :kEND, "end", :expr_end)
2856
+ :kDEF, "def", EXPR_FNAME,
2857
+ :tIDENTIFIER, "foo", EXPR_ENDFN,
2858
+ :tLABEL, "a", EXPR_LAB,
2859
+ :tCOMMA, ",", EXPR_PAR,
2860
+ :tLABEL, "b", EXPR_LAB,
2861
+ :kEND, "end", EXPR_END)
2794
2862
  end
2795
2863
 
2796
2864
  def test_yylex_hash_colon_double_quoted_with_escapes
@@ -2799,10 +2867,10 @@ class TestRubyLexer < Minitest::Test
2799
2867
  assert_lex3("{\"s\\tr\\i\\ng\\\\foo\\'bar\":1}",
2800
2868
  nil,
2801
2869
 
2802
- :tLBRACE, "{", :expr_beg,
2803
- :tLABEL, "s\tr\i\ng\\foo'bar", :expr_labeled,
2804
- :tINTEGER, 1, :expr_end,
2805
- :tRCURLY, "}", :expr_endarg)
2870
+ :tLBRACE, "{", EXPR_PAR,
2871
+ :tLABEL, "s\tr\i\ng\\foo'bar", EXPR_LAB,
2872
+ :tINTEGER, 1, EXPR_NUM,
2873
+ :tRCURLY, "}", EXPR_ENDARG)
2806
2874
  end
2807
2875
 
2808
2876
  def test_yylex_hash_colon_quoted_with_escapes
@@ -2811,87 +2879,80 @@ class TestRubyLexer < Minitest::Test
2811
2879
  assert_lex3("{'s\\tr\\i\\ng\\\\foo\\'bar':1}",
2812
2880
  nil,
2813
2881
 
2814
- :tLBRACE, "{", :expr_beg,
2815
- :tLABEL, "s\\tr\\i\\ng\\foo'bar", :expr_labeled,
2816
- :tINTEGER, 1, :expr_end,
2817
- :tRCURLY, "}", :expr_endarg)
2882
+ :tLBRACE, "{", EXPR_PAR,
2883
+ :tLABEL, "s\\tr\\i\\ng\\foo'bar", EXPR_LAB,
2884
+ :tINTEGER, 1, EXPR_NUM,
2885
+ :tRCURLY, "}", EXPR_ENDARG)
2818
2886
  end
2819
2887
 
2820
2888
  def test_ruby21_rational_literal
2821
2889
  setup_lexer_class RubyParser::V21
2822
2890
 
2823
- assert_lex3("10r", nil, :tRATIONAL, Rational(10), :expr_end)
2824
- assert_lex3("0x10r", nil, :tRATIONAL, Rational(16), :expr_end)
2825
- assert_lex3("0o10r", nil, :tRATIONAL, Rational(8), :expr_end)
2826
- assert_lex3("0or", nil, :tRATIONAL, Rational(0), :expr_end)
2827
- assert_lex3("0b10r", nil, :tRATIONAL, Rational(2), :expr_end)
2828
- assert_lex3("1.5r", nil, :tRATIONAL, Rational(15, 10), :expr_end)
2829
- assert_lex3("15e3r", nil, :tRATIONAL, Rational(15000), :expr_end)
2830
- assert_lex3("15e-3r", nil, :tRATIONAL, Rational(15, 1000), :expr_end)
2831
- assert_lex3("1.5e3r", nil, :tRATIONAL, Rational(1500), :expr_end)
2832
- assert_lex3("1.5e-3r", nil, :tRATIONAL, Rational(15, 10000), :expr_end)
2891
+ assert_lex3("10r", nil, :tRATIONAL, Rational(10), EXPR_NUM)
2892
+ assert_lex3("0x10r", nil, :tRATIONAL, Rational(16), EXPR_NUM)
2893
+ assert_lex3("0o10r", nil, :tRATIONAL, Rational(8), EXPR_NUM)
2894
+ assert_lex3("0or", nil, :tRATIONAL, Rational(0), EXPR_NUM)
2895
+ assert_lex3("0b10r", nil, :tRATIONAL, Rational(2), EXPR_NUM)
2896
+ assert_lex3("1.5r", nil, :tRATIONAL, Rational(15, 10), EXPR_NUM)
2897
+ assert_lex3("15e3r", nil, :tRATIONAL, Rational(15000), EXPR_NUM)
2898
+ assert_lex3("15e-3r", nil, :tRATIONAL, Rational(15, 1000), EXPR_NUM)
2899
+ assert_lex3("1.5e3r", nil, :tRATIONAL, Rational(1500), EXPR_NUM)
2900
+ assert_lex3("1.5e-3r", nil, :tRATIONAL, Rational(15, 10000), EXPR_NUM)
2833
2901
 
2834
2902
  assert_lex3("-10r", nil,
2835
- :tUMINUS_NUM, "-", :expr_beg,
2836
- :tRATIONAL, Rational(10), :expr_end)
2903
+ :tUMINUS_NUM, "-", EXPR_BEG,
2904
+ :tRATIONAL, Rational(10), EXPR_NUM)
2837
2905
  end
2838
2906
 
2839
2907
  def test_ruby21_imaginary_literal
2840
2908
  setup_lexer_class RubyParser::V21
2841
2909
 
2842
- assert_lex3("1i", nil, :tIMAGINARY, Complex(0, 1), :expr_end)
2843
- assert_lex3("0x10i", nil, :tIMAGINARY, Complex(0, 16), :expr_end)
2844
- assert_lex3("0o10i", nil, :tIMAGINARY, Complex(0, 8), :expr_end)
2845
- assert_lex3("0oi", nil, :tIMAGINARY, Complex(0, 0), :expr_end)
2846
- assert_lex3("0b10i", nil, :tIMAGINARY, Complex(0, 2), :expr_end)
2847
- assert_lex3("1.5i", nil, :tIMAGINARY, Complex(0, 1.5), :expr_end)
2848
- assert_lex3("15e3i", nil, :tIMAGINARY, Complex(0, 15000), :expr_end)
2849
- assert_lex3("15e-3i", nil, :tIMAGINARY, Complex(0, 0.015), :expr_end)
2850
- assert_lex3("1.5e3i", nil, :tIMAGINARY, Complex(0, 1500), :expr_end)
2851
- assert_lex3("1.5e-3i", nil, :tIMAGINARY, Complex(0, 0.0015), :expr_end)
2910
+ assert_lex3("1i", nil, :tIMAGINARY, Complex(0, 1), EXPR_NUM)
2911
+ assert_lex3("0x10i", nil, :tIMAGINARY, Complex(0, 16), EXPR_NUM)
2912
+ assert_lex3("0o10i", nil, :tIMAGINARY, Complex(0, 8), EXPR_NUM)
2913
+ assert_lex3("0oi", nil, :tIMAGINARY, Complex(0, 0), EXPR_NUM)
2914
+ assert_lex3("0b10i", nil, :tIMAGINARY, Complex(0, 2), EXPR_NUM)
2915
+ assert_lex3("1.5i", nil, :tIMAGINARY, Complex(0, 1.5), EXPR_NUM)
2916
+ assert_lex3("15e3i", nil, :tIMAGINARY, Complex(0, 15000), EXPR_NUM)
2917
+ assert_lex3("15e-3i", nil, :tIMAGINARY, Complex(0, 0.015), EXPR_NUM)
2918
+ assert_lex3("1.5e3i", nil, :tIMAGINARY, Complex(0, 1500), EXPR_NUM)
2919
+ assert_lex3("1.5e-3i", nil, :tIMAGINARY, Complex(0, 0.0015), EXPR_NUM)
2852
2920
 
2853
2921
  assert_lex3("-10i", nil,
2854
- :tUMINUS_NUM, "-", :expr_beg,
2855
- :tIMAGINARY, Complex(0, 10), :expr_end)
2922
+ :tUMINUS_NUM, "-", EXPR_BEG,
2923
+ :tIMAGINARY, Complex(0, 10), EXPR_NUM)
2856
2924
  end
2857
2925
 
2858
2926
  def test_ruby21_rational_imaginary_literal
2859
2927
  setup_lexer_class RubyParser::V21
2860
2928
 
2861
- assert_lex3("1ri", nil, :tIMAGINARY, Complex(0, Rational(1)), :expr_end)
2862
- assert_lex3("0x10ri", nil, :tIMAGINARY, Complex(0, Rational(16)), :expr_end)
2863
- assert_lex3("0o10ri", nil, :tIMAGINARY, Complex(0, Rational(8)), :expr_end)
2864
- assert_lex3("0ori", nil, :tIMAGINARY, Complex(0, Rational(0)), :expr_end)
2865
- assert_lex3("0b10ri", nil, :tIMAGINARY, Complex(0, Rational(2)), :expr_end)
2866
- assert_lex3("1.5ri", nil, :tIMAGINARY, Complex(0, Rational("1.5")), :expr_end)
2867
- assert_lex3("15e3ri", nil, :tIMAGINARY, Complex(0, Rational("15e3")), :expr_end)
2868
- assert_lex3("15e-3ri", nil, :tIMAGINARY, Complex(0, Rational("15e-3")), :expr_end)
2869
- assert_lex3("1.5e3ri", nil, :tIMAGINARY, Complex(0, Rational("1.5e3")), :expr_end)
2870
- assert_lex3("1.5e-3ri", nil, :tIMAGINARY, Complex(0, Rational("1.5e-3")), :expr_end)
2929
+ assert_lex3 "1ri", nil, :tIMAGINARY, Complex(0, Rational(1)), EXPR_NUM
2930
+ assert_lex3 "0x10ri", nil, :tIMAGINARY, Complex(0, Rational(16)), EXPR_NUM
2931
+ assert_lex3 "0o10ri", nil, :tIMAGINARY, Complex(0, Rational(8)), EXPR_NUM
2932
+ assert_lex3 "0ori", nil, :tIMAGINARY, Complex(0, Rational(0)), EXPR_NUM
2933
+ assert_lex3 "0b10ri", nil, :tIMAGINARY, Complex(0, Rational(2)), EXPR_NUM
2934
+ assert_lex3 "1.5ri", nil, :tIMAGINARY, Complex(0, Rational("1.5")), EXPR_NUM
2935
+ assert_lex3 "15e3ri", nil, :tIMAGINARY, Complex(0, Rational("15e3")), EXPR_NUM
2936
+ assert_lex3 "15e-3ri", nil, :tIMAGINARY, Complex(0, Rational("15e-3")), EXPR_NUM
2937
+ assert_lex3 "1.5e3ri", nil, :tIMAGINARY, Complex(0, Rational("1.5e3")), EXPR_NUM
2938
+ assert_lex3 "1.5e-3ri", nil, :tIMAGINARY, Complex(0, Rational("1.5e-3")), EXPR_NUM
2871
2939
 
2872
2940
  assert_lex3("-10ri", nil,
2873
- :tUMINUS_NUM, "-", :expr_beg,
2874
- :tIMAGINARY, Complex(0, Rational(10)), :expr_end)
2941
+ :tUMINUS_NUM, "-", EXPR_BEG,
2942
+ :tIMAGINARY, Complex(0, Rational(10)), EXPR_NUM)
2875
2943
  end
2876
2944
 
2877
2945
  def test_ruby21_imaginary_literal_with_succeeding_keyword
2878
- skip "Currently does not tokenize correctly"
2879
-
2880
2946
  setup_lexer_class RubyParser::V21
2881
2947
 
2948
+ # 2/4 scenarios are syntax errors on all tested versions so I
2949
+ # deleted them.
2950
+
2882
2951
  assert_lex3("1if", nil,
2883
- :tINTEGER, 1, :expr_end,
2884
- :kIF_MOD, "if", :expr_beg)
2885
- assert_lex3("1rif", nil,
2886
- :tRATIONAL, Rational(1), :expr_end,
2887
- :kIF_MOD, "if", :expr_beg)
2952
+ :tINTEGER, 1, EXPR_NUM,
2953
+ :kIF_MOD, "if", EXPR_PAR)
2888
2954
  assert_lex3("1.0if", nil,
2889
- :tFLOAT, 1.0, :expr_end,
2890
- :kIF_MOD, "if", :expr_beg)
2891
- assert_lex3("1.0rif", nil,
2892
- :tRATIONAL, Rational("1.0"), :expr_end,
2893
- :kIF_MOD, "if", :expr_beg)
2894
-
2895
- flunk
2955
+ :tFLOAT, 1.0, EXPR_NUM,
2956
+ :kIF_MOD, "if", EXPR_PAR)
2896
2957
  end
2897
2958
  end