ruby_parser 3.0.0.a8 → 3.0.0.a9

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.

Potentially problematic release.


This version of ruby_parser might be problematic. Click here for more details.

data/lib/ruby19_parser.y CHANGED
@@ -239,7 +239,7 @@ rule
239
239
  | block_command
240
240
 
241
241
  block_command: block_call
242
- | block_call tDOT operation2 command_args
242
+ | block_call tDOT operation2 command_args # TODO: dot_or_colon
243
243
  {
244
244
  result = new_call val[0], val[2], val[3]
245
245
  }
@@ -271,9 +271,8 @@ rule
271
271
  {
272
272
  result = new_call nil, val[0].to_sym, val[1]
273
273
  if val[2] then
274
- if result[0] == :block_pass then
275
- raise "both block arg and actual block given"
276
- end
274
+ block_dup_check result, val[2]
275
+
277
276
  result, operation = val[2], result
278
277
  result.insert 1, operation
279
278
  end
@@ -284,7 +283,13 @@ rule
284
283
  }
285
284
  | primary_value tDOT operation2 command_args cmd_brace_block
286
285
  {
287
- result = new_call val[0], val[2].to_sym, val[3]
286
+ recv, _, msg, args, block = val
287
+ call = new_call recv, msg.to_sym, args
288
+
289
+ block_dup_check call, block
290
+
291
+ block.insert 1, call
292
+ result = block
288
293
  }
289
294
  | primary_value tCOLON2 operation2 command_args =tLOWEST
290
295
  {
@@ -292,14 +297,13 @@ rule
292
297
  }
293
298
  | primary_value tCOLON2 operation2 command_args cmd_brace_block
294
299
  {
295
- result = new_call val[0], val[2].to_sym, val[3]
296
- if val[4] then
297
- if result[0] == :block_pass then # REFACTOR
298
- raise "both block arg and actual block given"
299
- end
300
- val[2] << result
301
- result = val[2]
302
- end
300
+ recv, _, msg, args, block = val
301
+ call = new_call recv, msg.to_sym, args
302
+
303
+ block_dup_check call, block
304
+
305
+ block.insert 1, call
306
+ result = block
303
307
  }
304
308
  | kSUPER command_args
305
309
  {
@@ -838,7 +842,7 @@ rule
838
842
  | block_arg
839
843
 
840
844
  command_args: {
841
- result = lexer.cmdarg.stack.dup
845
+ result = lexer.cmdarg.stack.dup # TODO: smell?
842
846
  lexer.cmdarg.push true
843
847
  }
844
848
  call_args
@@ -970,7 +974,7 @@ rule
970
974
  }
971
975
  | kNOT tLPAREN2 rparen
972
976
  {
973
- raise "no3: #{val.inspect}"
977
+ raise "no3\non#{val.inspect}"
974
978
  }
975
979
  | operation brace_block
976
980
  {
@@ -984,7 +988,8 @@ rule
984
988
  | method_call brace_block
985
989
  {
986
990
  call, iter = val[0], val[1]
987
- iter.insert 1, call
991
+ block_dup_check call, iter
992
+ iter.insert 1, call # FIX
988
993
  result = iter
989
994
  }
990
995
  | tLAMBDA lambda
@@ -1212,35 +1217,35 @@ rule
1212
1217
  }
1213
1218
  | f_marg_list tCOMMA tSTAR f_norm_arg
1214
1219
  {
1215
- raise "no9: #{val.inspect}"
1220
+ result = block_var val[0], val[3], nil
1216
1221
  }
1217
1222
  | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
1218
1223
  {
1219
- raise "no10: #{val.inspect}"
1224
+ raise "no10\non: #{val.inspect}"
1220
1225
  }
1221
1226
  | f_marg_list tCOMMA tSTAR
1222
1227
  {
1223
- raise "no11: #{val.inspect}"
1228
+ raise "no11\non: #{val.inspect}"
1224
1229
  }
1225
1230
  | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
1226
1231
  {
1227
- raise "no12: #{val.inspect}"
1232
+ raise "no12\non: #{val.inspect}"
1228
1233
  }
1229
1234
  | tSTAR f_norm_arg
1230
1235
  {
1231
- raise "no13: #{val.inspect}"
1236
+ raise "no13\non: #{val.inspect}"
1232
1237
  }
1233
1238
  | tSTAR f_norm_arg tCOMMA f_marg_list
1234
1239
  {
1235
- raise "no14: #{val.inspect}"
1240
+ raise "no14\non: #{val.inspect}"
1236
1241
  }
1237
1242
  | tSTAR
1238
1243
  {
1239
- raise "no15: #{val.inspect}"
1244
+ raise "no15\non: #{val.inspect}"
1240
1245
  }
1241
1246
  | tSTAR tCOMMA f_marg_list
1242
1247
  {
1243
- raise "no16: #{val.inspect}"
1248
+ raise "no16\non: #{val.inspect}"
1244
1249
  }
1245
1250
 
1246
1251
  block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_f_block_arg
@@ -1253,7 +1258,12 @@ rule
1253
1258
  }
1254
1259
  | f_arg tCOMMA f_block_optarg opt_f_block_arg
1255
1260
  {
1256
- result = block_args19 val, "3"
1261
+ arg, _, opt, block = val
1262
+
1263
+ result = arg
1264
+ result.concat opt[1..-1].map { |s| s[1] }
1265
+ result << "&#{block.last}".to_sym if block
1266
+ result << opt
1257
1267
  }
1258
1268
  | f_arg tCOMMA f_block_optarg tCOMMA f_arg opt_f_block_arg
1259
1269
  {
@@ -1285,7 +1295,12 @@ rule
1285
1295
  }
1286
1296
  | f_block_optarg opt_f_block_arg
1287
1297
  {
1288
- result = block_args19 val, "11"
1298
+ opt, block = val
1299
+
1300
+ result = s(:args)
1301
+ result.concat opt[1..-1].map { |s| s[1] }
1302
+ result << "&#{block.last}".to_sym if block
1303
+ result << opt
1289
1304
  }
1290
1305
  | f_block_optarg tCOMMA f_arg opt_f_block_arg
1291
1306
  {
@@ -1297,7 +1312,11 @@ rule
1297
1312
  }
1298
1313
  | f_rest_arg tCOMMA f_arg opt_f_block_arg
1299
1314
  {
1300
- result = block_args19 val, "14"
1315
+ rest, _, args, block = val
1316
+
1317
+ result = args
1318
+ result[1,0] = rest
1319
+ result << "&#{block.last}".to_sym if block
1301
1320
  }
1302
1321
  | f_block_arg
1303
1322
  {
@@ -1329,10 +1348,13 @@ rule
1329
1348
  }
1330
1349
 
1331
1350
  bv_decls: bvar
1351
+ {
1352
+ result = [val[0]]
1353
+ }
1332
1354
  | bv_decls tCOMMA bvar
1333
1355
  {
1334
- result = val[0] << val[2]
1335
- raise "no18: #{val.inspect}"
1356
+ result = val[0].concat val[2]
1357
+ raise "no18\non: #{val.inspect}"
1336
1358
  }
1337
1359
 
1338
1360
  bvar: tIDENTIFIER
@@ -1393,8 +1415,12 @@ rule
1393
1415
 
1394
1416
  block_call: command do_block
1395
1417
  {
1396
- raise SyntaxError, "Both block arg and actual block given." if
1397
- val[0] && val[0][0] == :blockpass
1418
+ # TODO:
1419
+ # if (nd_type($1) == NODE_YIELD) {
1420
+ # compile_error(PARSER_ARG "block given to yield");
1421
+
1422
+ syntax_error "Both block arg and actual block given." if
1423
+ val[0].block_pass?
1398
1424
 
1399
1425
  result = val[1]
1400
1426
  result.insert 1, val[0]
@@ -1924,9 +1950,13 @@ keyword_variable: kNIL { result = s(:nil) }
1924
1950
  }
1925
1951
 
1926
1952
  f_block_optarg: f_block_opt
1953
+ {
1954
+ result = s(:block, val[0])
1955
+ }
1927
1956
  | f_block_optarg tCOMMA f_block_opt
1928
1957
  {
1929
- raise "no22: #{val.inspect}"
1958
+ result = val[0]
1959
+ result << val[2]
1930
1960
  }
1931
1961
 
1932
1962
  f_optarg: f_opt
data/lib/ruby_lexer.rb CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  class RubyLexer
4
4
 
5
+ RUBY19 = "".respond_to? :encoding
6
+
5
7
  IDENT_CHAR_RE = case RUBY_VERSION
6
8
  when /^1\.8/ then
7
9
  /[\w\x80-\xFF]/
@@ -115,7 +117,7 @@ class RubyLexer
115
117
  end
116
118
 
117
119
  def fix_arg_lex_state
118
- self.lex_state = if lex_state == :expr_fname || lex_state == :expr_dot
120
+ self.lex_state = if in_lex_state? :expr_fname, :expr_dot then
119
121
  :expr_arg
120
122
  else
121
123
  :expr_beg
@@ -235,6 +237,10 @@ class RubyLexer
235
237
  end
236
238
  end
237
239
 
240
+ def in_lex_state?(*states)
241
+ states.include? lex_state
242
+ end
243
+
238
244
  def initialize v = 18
239
245
  self.version = v
240
246
  self.cond = RubyParserStuff::StackState.new(:cond)
@@ -273,13 +279,13 @@ class RubyLexer
273
279
  self.lex_state = :expr_end
274
280
 
275
281
  case
276
- when src.scan(/[+-]?0[xbd]\b/) then
282
+ when src.scan(/[+-]?0[xXbBdD]\b/) then
277
283
  rb_compile_error "Invalid numeric format"
278
284
  when src.scan(/[+-]?0x[a-f0-9_]+/i) then
279
285
  int_with_base(16)
280
- when src.scan(/[+-]?0b[01_]+/) then
286
+ when src.scan(/[+-]?0[Bb][01_]+/) then
281
287
  int_with_base(2)
282
- when src.scan(/[+-]?0d[0-9_]+/) then
288
+ when src.scan(/[+-]?0[Dd][0-9_]+/) then
283
289
  int_with_base(10)
284
290
  when src.scan(/[+-]?0[Oo]?[0-7_]*[89]/) then
285
291
  rb_compile_error "Illegal octal digit."
@@ -344,7 +350,7 @@ class RubyLexer
344
350
  [:tSYMBEG, STR_SSYM]
345
351
  end
346
352
 
347
- rb_compile_error "Bad %string type. Expected [Qqwxr\W], found '#{c}'." if
353
+ rb_compile_error "Bad %string type. Expected [Qq\Wwxrs], found '#{c}'." if
348
354
  token_type.nil?
349
355
 
350
356
  self.lex_strterm = [:strterm, string_type, nnd, beg]
@@ -414,7 +420,7 @@ class RubyLexer
414
420
 
415
421
  def rb_compile_error msg
416
422
  msg += ". near line #{self.lineno}: #{src.rest[/^.*/].inspect}"
417
- raise SyntaxError, msg
423
+ raise RubyParser::SyntaxError, msg
418
424
  end
419
425
 
420
426
  def read_escape # 51 lines
@@ -614,23 +620,24 @@ class RubyLexer
614
620
  return c
615
621
  end
616
622
 
617
- def unescape s
623
+ ESCAPES = {
624
+ "a" => "\007",
625
+ "b" => "\010",
626
+ "e" => "\033",
627
+ "f" => "\f",
628
+ "n" => "\n",
629
+ "r" => "\r",
630
+ "s" => " ",
631
+ "t" => "\t",
632
+ "v" => "\13",
633
+ "\\" => '\\',
634
+ "\n" => "",
635
+ "C-\?" => 127.chr,
636
+ "c\?" => 127.chr,
637
+ }
618
638
 
619
- r = {
620
- "a" => "\007",
621
- "b" => "\010",
622
- "e" => "\033",
623
- "f" => "\f",
624
- "n" => "\n",
625
- "r" => "\r",
626
- "s" => " ",
627
- "t" => "\t",
628
- "v" => "\13",
629
- "\\" => '\\',
630
- "\n" => "",
631
- "C-\?" => 127.chr,
632
- "c\?" => 127.chr,
633
- }[s]
639
+ def unescape s
640
+ r = ESCAPES[s]
634
641
 
635
642
  return r if r
636
643
 
@@ -684,25 +691,26 @@ class RubyLexer
684
691
  self.lineno = nil
685
692
  c = src.matched
686
693
  if c == '#' then
687
- # TODO: add magic comment handling?
688
-
689
694
  src.pos -= 1
690
695
 
691
696
  while src.scan(/\s*#.*(\n+|\z)/) do
692
697
  @comments << src.matched.gsub(/^ +#/, '#').gsub(/^ +$/, '')
693
698
  end
694
699
 
695
- if src.eos? then
696
- return RubyLexer::EOF
697
- end
700
+ return RubyLexer::EOF if src.eos?
698
701
  end
699
702
 
700
703
  # Replace a string of newlines with a single one
701
704
  src.scan(/\n+/)
702
705
 
703
- if [:expr_beg, :expr_fname,
704
- :expr_dot, :expr_class, :expr_value].include? lex_state then
705
- next
706
+ next if in_lex_state?(:expr_beg, :expr_fname, :expr_dot, :expr_class,
707
+ :expr_value)
708
+
709
+ if src.scan(/([\ \t\r\f\v]*)\./) then
710
+ self.space_seen = true unless src[1].empty?
711
+
712
+ src.pos -= 1
713
+ next unless src.check(/\.\./)
706
714
  end
707
715
 
708
716
  self.command_start = true
@@ -778,7 +786,7 @@ class RubyLexer
778
786
 
779
787
  return process_token(command_state)
780
788
  elsif src.scan(/\:\:/) then
781
- if is_beg? || lex_state == :expr_class || is_space_arg? then
789
+ if is_beg? || in_lex_state?(:expr_class) || is_space_arg? then
782
790
  self.lex_state = :expr_beg
783
791
  self.yacc_value = "::"
784
792
  return :tCOLON3
@@ -787,7 +795,7 @@ class RubyLexer
787
795
  self.lex_state = :expr_dot
788
796
  self.yacc_value = "::"
789
797
  return :tCOLON2
790
- elsif ! is_end? && src.scan(/:([a-zA-Z_]#{IDENT_CHAR_RE}*(?:[?!]|=(?!>))?)/) then
798
+ elsif ! is_end? && src.scan(/:([a-zA-Z_]#{IDENT_CHAR_RE}*(?:[?!]|=(?==>)|=(?![=>]))?)/) then
791
799
  # scanning shortcut to symbols
792
800
  self.yacc_value = src[1]
793
801
  self.lex_state = :expr_end
@@ -816,7 +824,7 @@ class RubyLexer
816
824
  elsif src.scan(/\[/) then
817
825
  result = src.matched
818
826
 
819
- if lex_state == :expr_fname || lex_state == :expr_dot then
827
+ if in_lex_state? :expr_fname, :expr_dot then
820
828
  self.lex_state = :expr_arg
821
829
  case
822
830
  when src.scan(/\]\=/) then
@@ -831,7 +839,7 @@ class RubyLexer
831
839
  elsif is_beg? then
832
840
  self.tern.push false
833
841
  result = :tLBRACK
834
- elsif lex_state.is_argument && space_seen then
842
+ elsif is_arg? && space_seen then
835
843
  self.tern.push false
836
844
  result = :tLBRACK
837
845
  else
@@ -870,9 +878,9 @@ class RubyLexer
870
878
  return :tLAMBEG
871
879
  end
872
880
 
873
- result = if lex_state.is_argument || lex_state == :expr_end then
881
+ result = if is_arg? || in_lex_state?(:expr_end) then
874
882
  :tLCURLY # block (primary)
875
- elsif lex_state == :expr_endarg then
883
+ elsif in_lex_state?(:expr_endarg) then
876
884
  :tLBRACE_ARG # block (expr)
877
885
  else
878
886
  self.tern.push false
@@ -895,7 +903,7 @@ class RubyLexer
895
903
  [:tUMINUS, :tMINUS]
896
904
  end
897
905
 
898
- if lex_state == :expr_fname || lex_state == :expr_dot then
906
+ if in_lex_state? :expr_fname, :expr_dot then
899
907
  self.lex_state = :expr_arg
900
908
  if src.scan(/@/) then
901
909
  self.yacc_value = "#{sign}@"
@@ -913,8 +921,8 @@ class RubyLexer
913
921
  end
914
922
 
915
923
  if (is_beg? ||
916
- (lex_state.is_argument && space_seen && !src.check(/\s/))) then
917
- if lex_state.is_argument then
924
+ (is_arg? && space_seen && !src.check(/\s/))) then
925
+ if is_arg? then
918
926
  arg_ambiguous
919
927
  end
920
928
 
@@ -949,7 +957,7 @@ class RubyLexer
949
957
  self.yacc_value = "*"
950
958
  return :tOP_ASGN
951
959
  elsif src.scan(/\*/) then
952
- result = if lex_state.is_argument && space_seen && src.check(/\S/) then
960
+ result = if is_arg? && space_seen && src.check(/\S/) then
953
961
  warning("`*' interpreted as argument prefix")
954
962
  :tSTAR
955
963
  elsif is_beg? then
@@ -977,9 +985,9 @@ class RubyLexer
977
985
  self.yacc_value = "\<\<"
978
986
  return :tOP_ASGN
979
987
  elsif src.scan(/\<\</) then
980
- if (! [:expr_end, :expr_dot,
981
- :expr_endarg, :expr_class].include?(lex_state) &&
982
- (!lex_state.is_argument || space_seen)) then
988
+ if (! in_lex_state?(:expr_end, :expr_dot,
989
+ :expr_endarg, :expr_class) &&
990
+ (!is_arg? || space_seen)) then
983
991
  tok = self.heredoc_identifier
984
992
  if tok then
985
993
  return tok
@@ -1030,8 +1038,9 @@ class RubyLexer
1030
1038
  self.lex_strterm = [:strterm, STR_XQUOTE, '`', "\0"]
1031
1039
  return :tXSTRING_BEG
1032
1040
  elsif src.scan(/\?/) then
1033
- if lex_state == :expr_end || lex_state == :expr_endarg then
1034
- self.lex_state = :expr_beg
1041
+
1042
+ if is_end? then
1043
+ self.lex_state = ruby18 ? :expr_beg : :expr_value # HACK?
1035
1044
  self.tern.push true
1036
1045
  self.yacc_value = "?"
1037
1046
  return :tEH
@@ -1042,7 +1051,7 @@ class RubyLexer
1042
1051
  end
1043
1052
 
1044
1053
  if src.check(/\s|\v/) then
1045
- unless lex_state.is_argument then
1054
+ unless is_arg? then
1046
1055
  c2 = { " " => 's',
1047
1056
  "\n" => 'n',
1048
1057
  "\t" => 't',
@@ -1056,7 +1065,7 @@ class RubyLexer
1056
1065
  end
1057
1066
 
1058
1067
  # ternary
1059
- self.lex_state = :expr_beg
1068
+ self.lex_state = ruby18 ? :expr_beg : :expr_value # HACK?
1060
1069
  self.tern.push true
1061
1070
  self.yacc_value = "?"
1062
1071
  return :tEH
@@ -1095,11 +1104,11 @@ class RubyLexer
1095
1104
  self.lex_state = :expr_beg
1096
1105
  return :tOP_ASGN
1097
1106
  elsif src.scan(/&/) then
1098
- result = if lex_state.is_argument && space_seen &&
1107
+ result = if is_arg? && space_seen &&
1099
1108
  !src.check(/\s/) then
1100
1109
  warning("`&' interpreted as argument prefix")
1101
1110
  :tAMPER
1102
- elsif lex_state == :expr_beg || lex_state == :expr_mid then
1111
+ elsif in_lex_state? :expr_beg, :expr_mid then
1103
1112
  :tAMPER
1104
1113
  else
1105
1114
  :tAMPER2
@@ -1122,7 +1131,7 @@ class RubyLexer
1122
1131
  return :tOP_ASGN
1123
1132
  end
1124
1133
 
1125
- if lex_state.is_argument && space_seen then
1134
+ if is_arg? && space_seen then
1126
1135
  unless src.scan(/\s/) then
1127
1136
  arg_ambiguous
1128
1137
  self.lex_strterm = [:strterm, STR_REGEXP, '/', "\0"]
@@ -1149,7 +1158,7 @@ class RubyLexer
1149
1158
  self.yacc_value = ";"
1150
1159
  return :tSEMI
1151
1160
  elsif src.scan(/\~/) then
1152
- if lex_state == :expr_fname || lex_state == :expr_dot then
1161
+ if in_lex_state? :expr_fname, :expr_dot then
1153
1162
  src.scan(/@/)
1154
1163
  end
1155
1164
 
@@ -1175,9 +1184,7 @@ class RubyLexer
1175
1184
  return :tOP_ASGN
1176
1185
  end
1177
1186
 
1178
- if lex_state.is_argument && space_seen && ! src.check(/\s/) then
1179
- return parse_quote
1180
- end
1187
+ return parse_quote if is_arg? && space_seen && ! src.check(/\s/)
1181
1188
 
1182
1189
  self.fix_arg_lex_state
1183
1190
  self.yacc_value = "%"
@@ -1258,12 +1265,12 @@ class RubyLexer
1258
1265
  self.command_start = true
1259
1266
  result = :tLPAREN2
1260
1267
 
1261
- if lex_state == :expr_beg || lex_state == :expr_mid then
1268
+ if in_lex_state? :expr_beg, :expr_mid then
1262
1269
  result = :tLPAREN
1263
1270
  elsif space_seen then
1264
- if lex_state == :expr_cmdarg then
1271
+ if in_lex_state? :expr_cmdarg then
1265
1272
  result = :tLPAREN_ARG
1266
- elsif lex_state == :expr_arg then
1273
+ elsif in_lex_state? :expr_arg then
1267
1274
  self.tern.push false
1268
1275
  warning "don't put space before argument parentheses"
1269
1276
  end
@@ -1275,20 +1282,15 @@ class RubyLexer
1275
1282
  end
1276
1283
 
1277
1284
  def is_end?
1278
- (lex_state == :expr_end ||
1279
- lex_state == :expr_endarg ||
1280
- lex_state == :expr_endfn)
1285
+ in_lex_state? :expr_end, :expr_endarg, :expr_endfn
1281
1286
  end
1282
1287
 
1283
1288
  def is_arg?
1284
- lex_state == :expr_arg || lex_state == :expr_cmdarg
1289
+ in_lex_state? :expr_arg, :expr_cmdarg
1285
1290
  end
1286
1291
 
1287
1292
  def is_beg?
1288
- (lex_state == :expr_beg ||
1289
- lex_state == :expr_mid ||
1290
- lex_state == :expr_value ||
1291
- lex_state == :expr_class)
1293
+ in_lex_state? :expr_beg, :expr_mid, :expr_value, :expr_class
1292
1294
  end
1293
1295
 
1294
1296
  def is_space_arg? c = "x"
@@ -1296,34 +1298,21 @@ class RubyLexer
1296
1298
  end
1297
1299
 
1298
1300
  def is_label_possible? command_state
1299
- (lex_state == :expr_beg && !command_state) || is_arg?
1301
+ (in_lex_state?(:expr_beg) && !command_state) || is_arg?
1300
1302
  end
1301
1303
 
1302
- def yylex_paren19
1303
- if is_beg? then
1304
- result = :tLPAREN
1305
- elsif is_space_arg? then
1306
- result = :tLPAREN_ARG
1307
- else
1308
- self.tern.push false
1309
- result = :tLPAREN2
1310
- end
1311
-
1312
- # p :wtf_paren => [lex_state, space_seen, result]
1304
+ def yylex_paren19 # TODO: move or remove
1305
+ result =
1306
+ if is_beg? then
1307
+ :tLPAREN
1308
+ elsif is_space_arg? then
1309
+ :tLPAREN_ARG
1310
+ else
1311
+ :tLPAREN2 # plain '(' in parse.y
1312
+ end
1313
1313
 
1314
- # HACK paren_nest++;
1314
+ # paren_nest++; # TODO
1315
1315
 
1316
- # HACK: this is a mess, but it makes the tests pass, so suck it
1317
- # (stolen from the 1.8 side)
1318
- if lex_state == :expr_beg || lex_state == :expr_mid then
1319
- # do nothing
1320
- elsif space_seen then
1321
- if lex_state == :expr_arg then
1322
- self.tern.push false
1323
- end
1324
- else
1325
- self.tern.push false
1326
- end
1327
1316
  result
1328
1317
  end
1329
1318
 
@@ -1345,7 +1334,7 @@ class RubyLexer
1345
1334
  if token =~ /[!?]$/ then
1346
1335
  result = :tFID
1347
1336
  else
1348
- if lex_state == :expr_fname then
1337
+ if in_lex_state? :expr_fname then
1349
1338
  # ident=, not =~ => == or followed by =>
1350
1339
  # TODO test lexing of a=>b vs a==>b
1351
1340
  if src.scan(/=(?:(?![~>=])|(?==>))/) then
@@ -1361,7 +1350,7 @@ class RubyLexer
1361
1350
  end
1362
1351
  end
1363
1352
 
1364
- unless self.tern.is_in_state
1353
+ unless ruby18
1365
1354
  if is_label_possible? command_state then
1366
1355
  colon = src.scan(/:/)
1367
1356
 
@@ -1373,9 +1362,9 @@ class RubyLexer
1373
1362
 
1374
1363
  src.unscan if colon
1375
1364
  end
1376
- end unless ruby18
1365
+ end
1377
1366
 
1378
- unless lex_state == :expr_dot then
1367
+ unless in_lex_state? :expr_dot then
1379
1368
  # See if it is a reserved word.
1380
1369
  keyword = if ruby18 then # REFACTOR need 18/19 lexer subclasses
1381
1370
  RubyParserStuff::Keyword.keyword18 token
@@ -1417,13 +1406,13 @@ class RubyLexer
1417
1406
  # if (mb == ENC_CODERANGE_7BIT && lex_state != EXPR_DOT) {
1418
1407
 
1419
1408
  self.lex_state =
1420
- if is_beg? || lex_state == :expr_dot || is_arg? then
1409
+ if is_beg? || in_lex_state?(:expr_dot) || is_arg? then
1421
1410
  if command_state then
1422
1411
  :expr_cmdarg
1423
1412
  else
1424
1413
  :expr_arg
1425
1414
  end
1426
- elsif ruby19 && lex_state == :expr_fname then
1415
+ elsif ruby19 && in_lex_state?(:expr_fname) then
1427
1416
  :expr_endfn
1428
1417
  else
1429
1418
  :expr_end