ruby_parser 3.20.0 → 3.20.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ruby25_parser.y CHANGED
@@ -222,6 +222,7 @@ rule
222
222
  | lhs tEQL mrhs
223
223
  {
224
224
  lhs, _, rhs = val
225
+
225
226
  result = new_assign lhs, s(:svalue, rhs).line(rhs.line)
226
227
  }
227
228
  | mlhs tEQL mrhs_arg
@@ -983,8 +984,10 @@ rule
983
984
 
984
985
  paren_args: tLPAREN2 opt_call_args rparen
985
986
  {
986
- _, args, _ = val
987
+ _, args, (_, line_max) = val
988
+
987
989
  result = args
990
+ result.line_max = line_max if args
988
991
  }
989
992
 
990
993
  opt_paren_args: none
@@ -1144,7 +1147,6 @@ rule
1144
1147
  | k_begin
1145
1148
  {
1146
1149
  lexer.cmdarg.push false
1147
- result = self.lexer.lineno
1148
1150
  }
1149
1151
  bodystmt k_end
1150
1152
  {
@@ -1189,12 +1191,14 @@ rule
1189
1191
  {
1190
1192
  result = wrap :colon3, val[1]
1191
1193
  }
1192
- | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1194
+ | tLBRACK { result = lexer.lineno } aref_args rbracket
1193
1195
  {
1194
- _, line, args, _ = val
1196
+ _, line, args, (_, line_max) = val
1197
+
1195
1198
  result = args || s(:array)
1196
1199
  result.sexp_type = :array # aref_args is :args
1197
1200
  result.line line
1201
+ result.line_max = line_max
1198
1202
  }
1199
1203
  | tLBRACE
1200
1204
  {
@@ -1299,9 +1303,6 @@ rule
1299
1303
  result = new_for iter, var, body
1300
1304
  }
1301
1305
  | k_class
1302
- {
1303
- result = self.lexer.lineno
1304
- }
1305
1306
  cpath superclass
1306
1307
  {
1307
1308
  if (self.in_def || self.in_single > 0) then
@@ -1316,9 +1317,6 @@ rule
1316
1317
  self.lexer.ignore_body_comments
1317
1318
  }
1318
1319
  | k_class tLSHFT
1319
- {
1320
- result = self.lexer.lineno
1321
- }
1322
1320
  expr
1323
1321
  {
1324
1322
  result = self.in_def
@@ -1337,9 +1335,6 @@ rule
1337
1335
  self.lexer.ignore_body_comments
1338
1336
  }
1339
1337
  | k_module
1340
- {
1341
- result = self.lexer.lineno
1342
- }
1343
1338
  cpath
1344
1339
  {
1345
1340
  yyerror "module definition in method body" if
@@ -1782,13 +1777,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1782
1777
  {
1783
1778
  call, args = val
1784
1779
 
1785
- result = call.concat args.sexp_body if args
1780
+ result = call
1781
+
1782
+ if args then
1783
+ call.concat args.sexp_body
1784
+ result.line_max = args.line_max
1785
+ end
1786
1786
  }
1787
1787
  | primary_value call_op operation2 opt_paren_args
1788
1788
  {
1789
- recv, call_op, (op, _line), args = val
1789
+ recv, call_op, (op, op_line), args = val
1790
1790
 
1791
1791
  result = new_call recv, op.to_sym, args, call_op
1792
+ result.line_max = op_line unless args
1792
1793
  }
1793
1794
  | primary_value tCOLON2 operation2 paren_args
1794
1795
  {
@@ -2002,15 +2003,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2002
2003
 
2003
2004
  words: tWORDS_BEG tSPACE tSTRING_END
2004
2005
  {
2005
- (_, line), _, _ = val
2006
+ (_, line), _, (_, line_max) = val
2006
2007
 
2007
2008
  result = s(:array).line line
2009
+ result.line_max = line_max
2008
2010
  }
2009
2011
  | tWORDS_BEG word_list tSTRING_END
2010
2012
  {
2011
- (_, line), list, _ = val
2013
+ (_, line), list, (_, line_max) = val
2012
2014
 
2013
2015
  result = list.line line
2016
+ result.line_max = line_max
2014
2017
  }
2015
2018
 
2016
2019
  word_list: none
@@ -2030,15 +2033,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2030
2033
 
2031
2034
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2032
2035
  {
2033
- (_, line), _, _ = val
2036
+ (_, line), _, (_, line_max) = val
2034
2037
 
2035
2038
  result = s(:array).line line
2039
+ result.line_max = line_max
2036
2040
  }
2037
2041
  | tSYMBOLS_BEG symbol_list tSTRING_END
2038
2042
  {
2039
- (_, line), list, _, = val
2040
- list.line line
2041
- result = list
2043
+ (_, line), list, (_, line_max), = val
2044
+
2045
+ result = list.line line
2046
+ result.line_max = line_max
2042
2047
  }
2043
2048
 
2044
2049
  symbol_list: none
@@ -2053,28 +2058,32 @@ opt_block_args_tail: tCOMMA block_args_tail
2053
2058
 
2054
2059
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2055
2060
  {
2056
- (_, line), _, _ = val
2061
+ (_, line), _, (_, line_max) = val
2057
2062
 
2058
2063
  result = s(:array).line line
2064
+ result.line_max = line_max
2059
2065
  }
2060
2066
  | tQWORDS_BEG qword_list tSTRING_END
2061
2067
  {
2062
- (_, line), list, _ = val
2068
+ (_, line), list, (_, line_max) = val
2063
2069
 
2064
2070
  result = list.line line
2071
+ result.line_max = line_max
2065
2072
  }
2066
2073
 
2067
2074
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2068
2075
  {
2069
- (_, line), _, _ = val
2076
+ (_, line), _, (_, line_max) = val
2070
2077
 
2071
2078
  result = s(:array).line line
2079
+ result.line_max = line_max
2072
2080
  }
2073
2081
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2074
2082
  {
2075
- (_, line), list, _ = val
2083
+ (_, line), list, (_, line_max) = val
2076
2084
 
2077
2085
  result = list.line line
2086
+ result.line_max = line_max
2078
2087
  }
2079
2088
 
2080
2089
  qword_list: none
@@ -2478,7 +2487,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2478
2487
  result = s(:args, list).line list.line
2479
2488
  end
2480
2489
 
2481
- result << (Sexp === item ? item : item.first)
2490
+ if Sexp === item then
2491
+ line_max = item.line_max
2492
+ else
2493
+ item, line_max = item
2494
+ end
2495
+
2496
+ result << item
2497
+ result.line_max = line_max
2482
2498
  }
2483
2499
 
2484
2500
  f_label: tLABEL
@@ -2696,7 +2712,15 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2696
2712
  opt_terms: | terms
2697
2713
  opt_nl: | tNL
2698
2714
  rparen: opt_nl tRPAREN
2715
+ {
2716
+ _, close = val
2717
+ result = [close, lexer.lineno]
2718
+ }
2699
2719
  rbracket: opt_nl tRBRACK
2720
+ {
2721
+ _, close = val
2722
+ result = [close, lexer.lineno]
2723
+ }
2700
2724
  trailer: | tNL | tCOMMA
2701
2725
 
2702
2726
  term: tSEMI { yyerrok }