ruby_parser 3.8.4 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,97 +1,13 @@
1
1
  # encoding: ASCII-8BIT
2
2
 
3
- require 'stringio'
4
- require 'racc/parser'
5
- require 'sexp'
6
- require 'strscan'
7
- require 'ruby_lexer'
3
+ require "sexp"
4
+ require "ruby_lexer"
8
5
  require "timeout"
9
-
10
- # :stopdoc:
11
- # WHY do I have to do this?!?
12
- class Regexp
13
- ONCE = 0 unless defined? ONCE # FIX: remove this - it makes no sense
14
-
15
- unless defined? ENC_NONE then
16
- ENC_NONE = /x/n.options
17
- ENC_EUC = /x/e.options
18
- ENC_SJIS = /x/s.options
19
- ENC_UTF8 = /x/u.options
20
- end
21
- end
22
-
23
- # I hate ruby 1.9 string changes
24
- class Fixnum
25
- def ord
26
- self
27
- end
28
- end unless "a"[0] == "a"
29
- # :startdoc:
30
-
31
- class RPStringScanner < StringScanner
32
- # if ENV['TALLY'] then
33
- # alias :old_getch :getch
34
- # def getch
35
- # warn({:getch => caller[0]}.inspect)
36
- # old_getch
37
- # end
38
- # end
39
-
40
- if "".respond_to? :encoding then
41
- if "".respond_to? :byteslice then
42
- def string_to_pos
43
- string.byteslice(0, pos)
44
- end
45
- else
46
- def string_to_pos
47
- string.bytes.first(pos).pack("c*").force_encoding(string.encoding)
48
- end
49
- end
50
-
51
- def charpos
52
- string_to_pos.length
53
- end
54
- else
55
- alias :charpos :pos
56
-
57
- def string_to_pos
58
- string[0..pos]
59
- end
60
- end
61
-
62
- def unread_many str # TODO: remove this entirely - we should not need it
63
- warn({:unread_many => caller[0]}.inspect) if ENV['TALLY']
64
- begin
65
- string[charpos, 0] = str
66
- rescue IndexError
67
- # HACK -- this is a bandaid on a dirty rag on an open festering wound
68
- end
69
- end
70
-
71
- if ENV['DEBUG'] then
72
- alias :old_getch :getch
73
- def getch
74
- c = self.old_getch
75
- p :getch => [c, caller.first]
76
- c
77
- end
78
-
79
- alias :old_scan :scan
80
- def scan re
81
- s = old_scan re
82
- where = caller[1].split(/:/).first(2).join(":")
83
- d :scan => [s, where] if s
84
- s
85
- end
86
- end
87
-
88
- def d o
89
- $stderr.puts o.inspect
90
- end
91
- end
6
+ require "rp_extensions"
7
+ require "rp_stringscanner"
92
8
 
93
9
  module RubyParserStuff
94
- VERSION = "3.8.4" unless constants.include? "VERSION" # SIGH
10
+ VERSION = "3.9.0"
95
11
 
96
12
  attr_accessor :lexer, :in_def, :in_single, :file
97
13
  attr_reader :env, :comments
@@ -107,7 +23,14 @@ module RubyParserStuff
107
23
  raise "not yet #{n} #{v.inspect} => #{r.inspect}" unless $good20[n]
108
24
  end
109
25
 
110
- ruby19 = "".respond_to? :encoding
26
+ def self.deprecate old, new
27
+ define_method old do |*args|
28
+ warn "DEPRECATED: #{old} -> #{new} from #{caller.first}"
29
+ send new, *args
30
+ end
31
+ end
32
+
33
+ has_enc = "".respond_to? :encoding
111
34
 
112
35
  # This is in sorted order of occurrence according to
113
36
  # charlock_holmes against 500k files, with UTF_8 forced
@@ -122,7 +45,7 @@ module RubyParserStuff
122
45
  Encoding::SHIFT_JIS,
123
46
  Encoding::WINDOWS_1252,
124
47
  Encoding::EUC_JP
125
- ] if ruby19
48
+ ] if has_enc
126
49
 
127
50
  def syntax_error msg
128
51
  raise RubyParser::SyntaxError, msg
@@ -341,7 +264,7 @@ module RubyParserStuff
341
264
  _racc_do_parse_rb(_racc_setup, false)
342
265
  end if ENV['PURE_RUBY']
343
266
 
344
- def get_match_node lhs, rhs # TODO: rename to new_match
267
+ def new_match lhs, rhs
345
268
  if lhs then
346
269
  case lhs[0]
347
270
  when :dregx, :dregx_once then
@@ -363,6 +286,9 @@ module RubyParserStuff
363
286
  return new_call(lhs, :"=~", argl(rhs)).line(lhs.line)
364
287
  end
365
288
 
289
+ # TODO: remove in 4.0 or 2018-01, whichever is first
290
+ deprecate :get_match_node, :new_match
291
+
366
292
  def gettable(id)
367
293
  lineno = id.lineno if id.respond_to? :lineno
368
294
  id = id.to_sym if String === id
@@ -477,7 +403,7 @@ module RubyParserStuff
477
403
  return head
478
404
  end
479
405
 
480
- def logop(type, left, right) # TODO: rename logical_op
406
+ def logical_op type, left, right
481
407
  left = value_expr left
482
408
 
483
409
  if left and left[0] == type and not left.paren then
@@ -495,6 +421,9 @@ module RubyParserStuff
495
421
  return s(type, left, right)
496
422
  end
497
423
 
424
+ # TODO: remove in 4.0 or 2018-01, whichever is first
425
+ deprecate :logop, :logical_op
426
+
498
427
  def new_aref val
499
428
  val[2] ||= s(:arglist)
500
429
  val[2][0] = :arglist if val[2][0] == :array # REFACTOR
@@ -691,6 +620,10 @@ module RubyParserStuff
691
620
  result
692
621
  end
693
622
 
623
+ def new_hash val
624
+ s(:hash, *val[2].values).line(val[1])
625
+ end
626
+
694
627
  def new_if c, t, f
695
628
  l = [c.line, t && t.line, f && f.line].compact.min
696
629
  c = cond c
@@ -1028,7 +961,7 @@ module RubyParserStuff
1028
961
  end
1029
962
  end
1030
963
 
1031
- def node_assign(lhs, rhs) # TODO: rename new_assign
964
+ def new_assign lhs, rhs
1032
965
  return nil unless lhs
1033
966
 
1034
967
  rhs = value_expr rhs
@@ -1046,6 +979,9 @@ module RubyParserStuff
1046
979
  lhs
1047
980
  end
1048
981
 
982
+ # TODO: remove in 4.0 or 2018-01, whichever is first
983
+ deprecate :node_assign, :new_assign
984
+
1049
985
  ##
1050
986
  # Returns a UTF-8 encoded string after processing BOMs and magic
1051
987
  # encoding comments.
@@ -1066,11 +1002,11 @@ module RubyParserStuff
1066
1002
 
1067
1003
  def handle_encoding str
1068
1004
  str = str.dup
1069
- ruby19 = str.respond_to? :encoding
1005
+ has_enc = str.respond_to? :encoding
1070
1006
  encoding = nil
1071
1007
 
1072
1008
  header = str.lines.first(2)
1073
- header.map! { |s| s.force_encoding "ASCII-8BIT" } if ruby19
1009
+ header.map! { |s| s.force_encoding "ASCII-8BIT" } if has_enc
1074
1010
 
1075
1011
  first = header.first || ""
1076
1012
  encoding, str = "utf-8", str[3..-1] if first =~ /\A\xEF\xBB\xBF/
@@ -1081,7 +1017,7 @@ module RubyParserStuff
1081
1017
  }
1082
1018
 
1083
1019
  if encoding then
1084
- if ruby19 then
1020
+ if has_enc then
1085
1021
  encoding.sub!(/utf-8-.+$/, 'utf-8') # HACK for stupid emacs formats
1086
1022
  hack_encoding str, encoding
1087
1023
  else
@@ -1089,7 +1025,7 @@ module RubyParserStuff
1089
1025
  end
1090
1026
  else
1091
1027
  # nothing specified... ugh. try to encode as utf-8
1092
- hack_encoding str if ruby19
1028
+ hack_encoding str if has_enc
1093
1029
  end
1094
1030
 
1095
1031
  str
@@ -1421,142 +1357,3 @@ module RubyParserStuff
1421
1357
  end
1422
1358
  end
1423
1359
  end
1424
-
1425
- class Ruby23Parser < Racc::Parser
1426
- include RubyParserStuff
1427
- end
1428
-
1429
- class Ruby22Parser < Racc::Parser
1430
- include RubyParserStuff
1431
- end
1432
-
1433
- class Ruby21Parser < Racc::Parser
1434
- include RubyParserStuff
1435
- end
1436
-
1437
- class Ruby20Parser < Racc::Parser
1438
- include RubyParserStuff
1439
- end
1440
-
1441
- class Ruby19Parser < Racc::Parser
1442
- include RubyParserStuff
1443
- end
1444
-
1445
- class Ruby18Parser < Racc::Parser
1446
- include RubyParserStuff
1447
- end
1448
-
1449
- ##
1450
- # RubyParser is a compound parser that first attempts to parse using
1451
- # the 1.9 syntax parser and falls back to the 1.8 syntax parser on a
1452
- # parse error.
1453
-
1454
- class RubyParser
1455
- class SyntaxError < RuntimeError; end
1456
-
1457
- def initialize
1458
- @p18 = Ruby18Parser.new
1459
- @p19 = Ruby19Parser.new
1460
- @p20 = Ruby20Parser.new
1461
- @p21 = Ruby21Parser.new
1462
- @p22 = Ruby22Parser.new
1463
- @p23 = Ruby23Parser.new
1464
- end
1465
-
1466
- def process s, f = "(string)", t = 10
1467
- e = nil
1468
- [@p23, @p22, @p21, @p20, @p19, @p18].each do |parser|
1469
- begin
1470
- return parser.process s, f, t
1471
- rescue Racc::ParseError, RubyParser::SyntaxError => exc
1472
- e = exc
1473
- end
1474
- end
1475
- raise e
1476
- end
1477
-
1478
- alias :parse :process
1479
-
1480
- def reset
1481
- @p18.reset
1482
- @p19.reset
1483
- @p20.reset
1484
- @p21.reset
1485
- @p22.reset
1486
- @p23.reset
1487
- end
1488
-
1489
- def self.for_current_ruby
1490
- case RUBY_VERSION
1491
- when /^1\.8/ then
1492
- Ruby18Parser.new
1493
- when /^1\.9/ then
1494
- Ruby19Parser.new
1495
- when /^2.0/ then
1496
- Ruby20Parser.new
1497
- when /^2.1/ then
1498
- Ruby21Parser.new
1499
- when /^2.2/ then
1500
- Ruby22Parser.new
1501
- when /^2.3/ then
1502
- Ruby23Parser.new
1503
- else
1504
- raise "unrecognized RUBY_VERSION #{RUBY_VERSION}"
1505
- end
1506
- end
1507
- end
1508
-
1509
- ############################################################
1510
- # HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
1511
-
1512
- unless "".respond_to?(:grep) then
1513
- class String
1514
- def grep re
1515
- lines.grep re
1516
- end
1517
- end
1518
- end
1519
-
1520
- class String
1521
- ##
1522
- # This is a hack used by the lexer to sneak in line numbers at the
1523
- # identifier level. This should be MUCH smaller than making
1524
- # process_token return [value, lineno] and modifying EVERYTHING that
1525
- # reduces tIDENTIFIER.
1526
-
1527
- attr_accessor :lineno
1528
- end
1529
-
1530
- class Sexp
1531
- attr_writer :paren
1532
-
1533
- def paren
1534
- @paren ||= false
1535
- end
1536
-
1537
- def value
1538
- raise "multi item sexp" if size > 2
1539
- last
1540
- end
1541
-
1542
- def to_sym
1543
- raise "no: #{self.inspect}.to_sym is a bug"
1544
- self.value.to_sym
1545
- end
1546
-
1547
- alias :add :<<
1548
-
1549
- def add_all x
1550
- self.concat x.sexp_body
1551
- end
1552
-
1553
- def block_pass?
1554
- any? { |s| Sexp === s && s[0] == :block_pass }
1555
- end
1556
-
1557
- alias :node_type :sexp_type
1558
- alias :values :sexp_body # TODO: retire
1559
- end
1560
-
1561
- # END HACK
1562
- ############################################################
@@ -1,10 +1,8 @@
1
1
  # encoding: US-ASCII
2
2
 
3
- require 'rubygems'
4
- require 'minitest/autorun'
5
- require 'ruby_lexer'
6
- require 'ruby18_parser'
7
- require 'ruby20_parser'
3
+ require "minitest/autorun"
4
+ require "ruby_lexer"
5
+ require "ruby_parser"
8
6
 
9
7
  class TestRubyLexer < Minitest::Test
10
8
  attr_accessor :processor, :lex, :parser_class, :lex_state
@@ -14,7 +12,7 @@ class TestRubyLexer < Minitest::Test
14
12
 
15
13
  def setup
16
14
  self.lex_state = :expr_beg
17
- setup_lexer_class Ruby20Parser
15
+ setup_lexer_class RubyParser.latest.class
18
16
  end
19
17
 
20
18
  def setup_lexer input, exp_sexp = nil
@@ -53,6 +51,10 @@ class TestRubyLexer < Minitest::Test
53
51
  assert_lex(input, exp_sexp, *args, &block)
54
52
  end
55
53
 
54
+ def ruby18
55
+ RubyParser::V18 === lexer.parser
56
+ end
57
+
56
58
  def refute_lex input, *args # TODO: re-sort
57
59
  args = args.each_slice(2).map { |a, b| [a, b, nil, nil, nil] }.flatten
58
60
 
@@ -248,13 +250,13 @@ class TestRubyLexer < Minitest::Test
248
250
  end
249
251
 
250
252
  def test_yylex_and_dot
251
- setup_lexer_class Ruby23Parser
253
+ setup_lexer_class RubyParser::V23
252
254
 
253
255
  assert_lex3("&.", nil, :tLONELY, "&.", :expr_dot)
254
256
  end
255
257
 
256
258
  def test_yylex_and_dot_call
257
- setup_lexer_class Ruby23Parser
259
+ setup_lexer_class RubyParser::V23
258
260
 
259
261
  assert_lex3("x&.y", nil,
260
262
  :tIDENTIFIER, "x", :expr_cmdarg,
@@ -262,6 +264,15 @@ class TestRubyLexer < Minitest::Test
262
264
  :tIDENTIFIER, "y")
263
265
  end
264
266
 
267
+ def test_yylex_and_dot_call_newline
268
+ setup_lexer_class Ruby23Parser
269
+
270
+ assert_lex3("x\n&.y", nil,
271
+ :tIDENTIFIER, "x", :expr_cmdarg,
272
+ :tLONELY, "&.", :expr_dot,
273
+ :tIDENTIFIER, "y")
274
+ end
275
+
265
276
  def test_yylex_and_arg
266
277
  self.lex_state = :expr_arg
267
278
 
@@ -294,7 +305,7 @@ class TestRubyLexer < Minitest::Test
294
305
  end
295
306
 
296
307
  def test_yylex_label__18
297
- setup_lexer_class Ruby18Parser
308
+ setup_lexer_class RubyParser::V18
298
309
 
299
310
  assert_lex3("{a:",
300
311
  nil,
@@ -304,7 +315,7 @@ class TestRubyLexer < Minitest::Test
304
315
  end
305
316
 
306
317
  def test_yylex_label_in_params__18
307
- setup_lexer_class Ruby18Parser
318
+ setup_lexer_class RubyParser::V18
308
319
 
309
320
  assert_lex3("foo(a:",
310
321
  nil,
@@ -315,7 +326,7 @@ class TestRubyLexer < Minitest::Test
315
326
  end
316
327
 
317
328
  def test_yylex_label__19
318
- setup_lexer_class Ruby19Parser
329
+ setup_lexer_class RubyParser::V19
319
330
 
320
331
  assert_lex3("{a:",
321
332
  nil,
@@ -324,7 +335,7 @@ class TestRubyLexer < Minitest::Test
324
335
  end
325
336
 
326
337
  def test_yylex_label_in_params__19
327
- setup_lexer_class Ruby19Parser
338
+ setup_lexer_class RubyParser::V19
328
339
 
329
340
  assert_lex3("foo(a:",
330
341
  nil,
@@ -383,7 +394,9 @@ class TestRubyLexer < Minitest::Test
383
394
  refute_lexeme
384
395
  end
385
396
 
386
- def test_yylex_not_at_defn
397
+ def test_yylex_not_at_defn__20
398
+ setup_lexer_class RubyParser::V20
399
+
387
400
  assert_lex("def +@; end",
388
401
  s(:defn, :+@, s(:args), s(:nil)),
389
402
 
@@ -467,7 +480,7 @@ class TestRubyLexer < Minitest::Test
467
480
  end
468
481
 
469
482
  def test_yylex_lambda_args__20
470
- setup_lexer_class Ruby20Parser
483
+ setup_lexer_class RubyParser::V20
471
484
 
472
485
  assert_lex("-> (a) { }",
473
486
  s(:iter, s(:call, nil, :lambda),
@@ -482,7 +495,7 @@ class TestRubyLexer < Minitest::Test
482
495
  end
483
496
 
484
497
  def test_yylex_lambda_args_opt__20
485
- setup_lexer_class Ruby20Parser
498
+ setup_lexer_class RubyParser::V20
486
499
 
487
500
  assert_lex("-> (a=nil) { }",
488
501
  s(:iter, s(:call, nil, :lambda),
@@ -499,7 +512,7 @@ class TestRubyLexer < Minitest::Test
499
512
  end
500
513
 
501
514
  def test_yylex_lambda_hash__20
502
- setup_lexer_class Ruby20Parser
515
+ setup_lexer_class RubyParser::V20
503
516
 
504
517
  assert_lex("-> (a={}) { }",
505
518
  s(:iter, s(:call, nil, :lambda),
@@ -1277,13 +1290,13 @@ class TestRubyLexer < Minitest::Test
1277
1290
  end
1278
1291
 
1279
1292
  def test_yylex_identifier_def__18
1280
- setup_lexer_class Ruby18Parser
1293
+ setup_lexer_class RubyParser::V18
1281
1294
 
1282
1295
  assert_lex_fname "identifier", :tIDENTIFIER, :expr_end
1283
1296
  end
1284
1297
 
1285
1298
  def test_yylex_identifier_def__1920
1286
- setup_lexer_class Ruby19Parser
1299
+ setup_lexer_class RubyParser::V19
1287
1300
 
1288
1301
  assert_lex_fname "identifier", :tIDENTIFIER, :expr_endfn
1289
1302
  end
@@ -1320,13 +1333,13 @@ class TestRubyLexer < Minitest::Test
1320
1333
  end
1321
1334
 
1322
1335
  def test_yylex_identifier_equals_def__18
1323
- setup_lexer_class Ruby18Parser
1336
+ setup_lexer_class RubyParser::V18
1324
1337
 
1325
1338
  assert_lex_fname "identifier=", :tIDENTIFIER, :expr_end
1326
1339
  end
1327
1340
 
1328
1341
  def test_yylex_identifier_equals_def__1920
1329
- setup_lexer_class Ruby19Parser
1342
+ setup_lexer_class RubyParser::V19
1330
1343
 
1331
1344
  assert_lex_fname "identifier=", :tIDENTIFIER, :expr_endfn
1332
1345
  end
@@ -1429,25 +1442,25 @@ class TestRubyLexer < Minitest::Test
1429
1442
  end
1430
1443
 
1431
1444
  def test_yylex_question_eh_a__18
1432
- setup_lexer_class Ruby18Parser
1445
+ setup_lexer_class RubyParser::V18
1433
1446
 
1434
1447
  assert_lex3("?a", nil, :tINTEGER, 97, :expr_end)
1435
1448
  end
1436
1449
 
1437
1450
  def test_yylex_question_eh_a__19
1438
- setup_lexer_class Ruby19Parser
1451
+ setup_lexer_class RubyParser::V19
1439
1452
 
1440
1453
  assert_lex3("?a", nil, :tSTRING, "a", :expr_end)
1441
1454
  end
1442
1455
 
1443
1456
  def test_yylex_question_eh_escape_M_escape_C__18
1444
- setup_lexer_class Ruby18Parser
1457
+ setup_lexer_class RubyParser::V18
1445
1458
 
1446
1459
  assert_lex3("?\\M-\\C-a", nil, :tINTEGER, 129, :expr_end)
1447
1460
  end
1448
1461
 
1449
1462
  def test_yylex_question_eh_escape_M_escape_C__19
1450
- setup_lexer_class Ruby19Parser
1463
+ setup_lexer_class RubyParser::V19
1451
1464
 
1452
1465
  assert_lex3("?\\M-\\C-a", nil, :tSTRING, "\M-\C-a", :expr_end)
1453
1466
  end
@@ -1632,14 +1645,14 @@ class TestRubyLexer < Minitest::Test
1632
1645
  end
1633
1646
 
1634
1647
  def test_yylex_open_bracket_exprarg__18
1635
- setup_lexer_class Ruby18Parser
1648
+ setup_lexer_class RubyParser::V18
1636
1649
  self.lex_state = :expr_arg
1637
1650
 
1638
1651
  assert_lex3(" (", nil, :tLPAREN2, "(", :expr_beg)
1639
1652
  end
1640
1653
 
1641
1654
  def test_yylex_open_bracket_exprarg__19
1642
- setup_lexer_class Ruby19Parser
1655
+ setup_lexer_class RubyParser::V19
1643
1656
  self.lex_state = :expr_arg
1644
1657
 
1645
1658
  assert_lex3(" (", nil, :tLPAREN_ARG, "(", :expr_beg)
@@ -1804,13 +1817,13 @@ class TestRubyLexer < Minitest::Test
1804
1817
  end
1805
1818
 
1806
1819
  def test_yylex_question__18
1807
- setup_lexer_class Ruby18Parser
1820
+ setup_lexer_class RubyParser::V18
1808
1821
 
1809
1822
  assert_lex3("?*", nil, :tINTEGER, 42, :expr_end)
1810
1823
  end
1811
1824
 
1812
1825
  def test_yylex_question__19
1813
- setup_lexer_class Ruby19Parser
1826
+ setup_lexer_class RubyParser::V19
1814
1827
 
1815
1828
  assert_lex3("?*", nil, :tSTRING, "*", :expr_end)
1816
1829
  end
@@ -1829,7 +1842,7 @@ class TestRubyLexer < Minitest::Test
1829
1842
  end
1830
1843
 
1831
1844
  def test_yylex_question_ws_backslashed__18
1832
- setup_lexer_class Ruby18Parser
1845
+ setup_lexer_class RubyParser::V18
1833
1846
 
1834
1847
  assert_lex3("?\\ ", nil, :tINTEGER, 32, :expr_end)
1835
1848
  assert_lex3("?\\n", nil, :tINTEGER, 10, :expr_end)
@@ -1840,7 +1853,7 @@ class TestRubyLexer < Minitest::Test
1840
1853
  end
1841
1854
 
1842
1855
  def test_yylex_question_ws_backslashed__19
1843
- setup_lexer_class Ruby19Parser
1856
+ setup_lexer_class RubyParser::V19
1844
1857
 
1845
1858
  assert_lex3("?\\ ", nil, :tSTRING, " ", :expr_end)
1846
1859
  assert_lex3("?\\n", nil, :tSTRING, "\n", :expr_end)
@@ -2243,7 +2256,7 @@ class TestRubyLexer < Minitest::Test
2243
2256
 
2244
2257
  def test_yylex_string_double_escape_M
2245
2258
  chr = "\341"
2246
- chr.force_encoding("UTF-8") if RubyLexer::RUBY19
2259
+ chr.force_encoding("UTF-8") if RubyLexer::HAS_ENC
2247
2260
 
2248
2261
  assert_lex3("\"\\M-a\"", nil, :tSTRING, chr, :expr_end)
2249
2262
  end
@@ -2333,7 +2346,7 @@ class TestRubyLexer < Minitest::Test
2333
2346
  end
2334
2347
 
2335
2348
  def test_yylex_string_double_pound_dollar_bad
2336
- skip if Ruby18Parser === lexer.parser
2349
+ skip if ruby18
2337
2350
 
2338
2351
  assert_lex3('"#$%"', nil,
2339
2352
 
@@ -2515,7 +2528,7 @@ class TestRubyLexer < Minitest::Test
2515
2528
  end
2516
2529
 
2517
2530
  def test_yylex_symbol_zero_byte__18
2518
- setup_lexer_class Ruby18Parser
2531
+ setup_lexer_class RubyParser::V18
2519
2532
 
2520
2533
  refute_lex(":\"symbol\0\"", :tSYMBEG, ":")
2521
2534
  end
@@ -2650,7 +2663,7 @@ class TestRubyLexer < Minitest::Test
2650
2663
 
2651
2664
  def test_pct_w_backslashes
2652
2665
  ["\t", "\n", "\r", "\v", "\f"].each do |char|
2653
- next if !RubyLexer::RUBY19 and char == "\v"
2666
+ next if !RubyLexer::HAS_ENC and char == "\v"
2654
2667
 
2655
2668
  assert_lex("%w[foo#{char}bar]",
2656
2669
  s(:array, s(:str, "foo"), s(:str, "bar")),
@@ -2682,7 +2695,7 @@ class TestRubyLexer < Minitest::Test
2682
2695
  end
2683
2696
 
2684
2697
  def test_yylex_hash_colon_quoted_22
2685
- setup_lexer_class Ruby22Parser
2698
+ setup_lexer_class RubyParser::V22
2686
2699
 
2687
2700
  assert_lex("{'a':1}",
2688
2701
  s(:hash, s(:lit, :a), s(:lit, 1)),
@@ -2694,7 +2707,7 @@ class TestRubyLexer < Minitest::Test
2694
2707
  end
2695
2708
 
2696
2709
  def test_yylex_hash_colon_quoted_symbol_22
2697
- setup_lexer_class Ruby22Parser
2710
+ setup_lexer_class RubyParser::V22
2698
2711
 
2699
2712
  assert_lex("{'abc': :b}",
2700
2713
  s(:hash, s(:lit, :abc), s(:lit, :b)),
@@ -2706,7 +2719,7 @@ class TestRubyLexer < Minitest::Test
2706
2719
  end
2707
2720
 
2708
2721
  def test_yylex_hash_colon_double_quoted_symbol_22
2709
- setup_lexer_class Ruby22Parser
2722
+ setup_lexer_class RubyParser::V22
2710
2723
 
2711
2724
  assert_lex('{"abc": :b}',
2712
2725
  s(:hash, s(:lit, :abc), s(:lit, :b)),
@@ -2718,7 +2731,7 @@ class TestRubyLexer < Minitest::Test
2718
2731
  end
2719
2732
 
2720
2733
  def test_ruby21_rational_literal
2721
- setup_lexer_class Ruby21Parser
2734
+ setup_lexer_class RubyParser::V21
2722
2735
 
2723
2736
  assert_lex3("10r", nil, :tRATIONAL, Rational(10), :expr_end)
2724
2737
  assert_lex3("0x10r", nil, :tRATIONAL, Rational(16), :expr_end)
@@ -2737,7 +2750,7 @@ class TestRubyLexer < Minitest::Test
2737
2750
  end
2738
2751
 
2739
2752
  def test_ruby21_imaginary_literal
2740
- setup_lexer_class Ruby21Parser
2753
+ setup_lexer_class RubyParser::V21
2741
2754
 
2742
2755
  assert_lex3("1i", nil, :tIMAGINARY, Complex(0, 1), :expr_end)
2743
2756
  assert_lex3("0x10i", nil, :tIMAGINARY, Complex(0, 16), :expr_end)
@@ -2756,7 +2769,7 @@ class TestRubyLexer < Minitest::Test
2756
2769
  end
2757
2770
 
2758
2771
  def test_ruby21_rational_imaginary_literal
2759
- setup_lexer_class Ruby21Parser
2772
+ setup_lexer_class RubyParser::V21
2760
2773
 
2761
2774
  assert_lex3("1ri", nil, :tIMAGINARY, Complex(0, Rational(1)), :expr_end)
2762
2775
  assert_lex3("0x10ri", nil, :tIMAGINARY, Complex(0, Rational(16)), :expr_end)
@@ -2777,7 +2790,7 @@ class TestRubyLexer < Minitest::Test
2777
2790
  def test_ruby21_imaginary_literal_with_succeeding_keyword
2778
2791
  skip "Currently does not tokenize correctly"
2779
2792
 
2780
- setup_lexer_class Ruby21Parser
2793
+ setup_lexer_class RubyParser::V21
2781
2794
 
2782
2795
  assert_lex3("1if", nil,
2783
2796
  :tINTEGER, 1, :expr_end,