ruby_parser 3.20.0 → 3.20.3

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.
data/lib/ruby23_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
@@ -975,8 +976,10 @@ rule
975
976
 
976
977
  paren_args: tLPAREN2 opt_call_args rparen
977
978
  {
978
- _, args, _ = val
979
+ _, args, (_, line_max) = val
980
+
979
981
  result = args
982
+ result.line_max = line_max if args
980
983
  }
981
984
 
982
985
  opt_paren_args: none
@@ -1136,7 +1139,6 @@ rule
1136
1139
  | k_begin
1137
1140
  {
1138
1141
  lexer.cmdarg.push false
1139
- result = self.lexer.lineno
1140
1142
  }
1141
1143
  bodystmt k_end
1142
1144
  {
@@ -1181,12 +1183,14 @@ rule
1181
1183
  {
1182
1184
  result = wrap :colon3, val[1]
1183
1185
  }
1184
- | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1186
+ | tLBRACK { result = lexer.lineno } aref_args rbracket
1185
1187
  {
1186
- _, line, args, _ = val
1188
+ _, line, args, (_, line_max) = val
1189
+
1187
1190
  result = args || s(:array)
1188
1191
  result.sexp_type = :array # aref_args is :args
1189
1192
  result.line line
1193
+ result.line_max = line_max
1190
1194
  }
1191
1195
  | tLBRACE
1192
1196
  {
@@ -1291,9 +1295,6 @@ rule
1291
1295
  result = new_for iter, var, body
1292
1296
  }
1293
1297
  | k_class
1294
- {
1295
- result = self.lexer.lineno
1296
- }
1297
1298
  cpath superclass
1298
1299
  {
1299
1300
  if (self.in_def || self.in_single > 0) then
@@ -1308,9 +1309,6 @@ rule
1308
1309
  self.lexer.ignore_body_comments
1309
1310
  }
1310
1311
  | k_class tLSHFT
1311
- {
1312
- result = self.lexer.lineno
1313
- }
1314
1312
  expr
1315
1313
  {
1316
1314
  result = self.in_def
@@ -1329,9 +1327,6 @@ rule
1329
1327
  self.lexer.ignore_body_comments
1330
1328
  }
1331
1329
  | k_module
1332
- {
1333
- result = self.lexer.lineno
1334
- }
1335
1330
  cpath
1336
1331
  {
1337
1332
  yyerror "module definition in method body" if
@@ -1774,13 +1769,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1774
1769
  {
1775
1770
  call, args = val
1776
1771
 
1777
- result = call.concat args.sexp_body if args
1772
+ result = call
1773
+
1774
+ if args then
1775
+ call.concat args.sexp_body
1776
+ result.line_max = args.line_max
1777
+ end
1778
1778
  }
1779
1779
  | primary_value call_op operation2 opt_paren_args
1780
1780
  {
1781
- recv, call_op, (op, _line), args = val
1781
+ recv, call_op, (op, op_line), args = val
1782
1782
 
1783
1783
  result = new_call recv, op.to_sym, args, call_op
1784
+ result.line_max = op_line unless args
1784
1785
  }
1785
1786
  | primary_value tCOLON2 operation2 paren_args
1786
1787
  {
@@ -1994,15 +1995,17 @@ opt_block_args_tail: tCOMMA block_args_tail
1994
1995
 
1995
1996
  words: tWORDS_BEG tSPACE tSTRING_END
1996
1997
  {
1997
- (_, line), _, _ = val
1998
+ (_, line), _, (_, line_max) = val
1998
1999
 
1999
2000
  result = s(:array).line line
2001
+ result.line_max = line_max
2000
2002
  }
2001
2003
  | tWORDS_BEG word_list tSTRING_END
2002
2004
  {
2003
- (_, line), list, _ = val
2005
+ (_, line), list, (_, line_max) = val
2004
2006
 
2005
2007
  result = list.line line
2008
+ result.line_max = line_max
2006
2009
  }
2007
2010
 
2008
2011
  word_list: none
@@ -2022,15 +2025,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2022
2025
 
2023
2026
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2024
2027
  {
2025
- (_, line), _, _ = val
2028
+ (_, line), _, (_, line_max) = val
2026
2029
 
2027
2030
  result = s(:array).line line
2031
+ result.line_max = line_max
2028
2032
  }
2029
2033
  | tSYMBOLS_BEG symbol_list tSTRING_END
2030
2034
  {
2031
- (_, line), list, _, = val
2032
- list.line line
2033
- result = list
2035
+ (_, line), list, (_, line_max), = val
2036
+
2037
+ result = list.line line
2038
+ result.line_max = line_max
2034
2039
  }
2035
2040
 
2036
2041
  symbol_list: none
@@ -2045,28 +2050,32 @@ opt_block_args_tail: tCOMMA block_args_tail
2045
2050
 
2046
2051
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2047
2052
  {
2048
- (_, line), _, _ = val
2053
+ (_, line), _, (_, line_max) = val
2049
2054
 
2050
2055
  result = s(:array).line line
2056
+ result.line_max = line_max
2051
2057
  }
2052
2058
  | tQWORDS_BEG qword_list tSTRING_END
2053
2059
  {
2054
- (_, line), list, _ = val
2060
+ (_, line), list, (_, line_max) = val
2055
2061
 
2056
2062
  result = list.line line
2063
+ result.line_max = line_max
2057
2064
  }
2058
2065
 
2059
2066
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2060
2067
  {
2061
- (_, line), _, _ = val
2068
+ (_, line), _, (_, line_max) = val
2062
2069
 
2063
2070
  result = s(:array).line line
2071
+ result.line_max = line_max
2064
2072
  }
2065
2073
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2066
2074
  {
2067
- (_, line), list, _ = val
2075
+ (_, line), list, (_, line_max) = val
2068
2076
 
2069
2077
  result = list.line line
2078
+ result.line_max = line_max
2070
2079
  }
2071
2080
 
2072
2081
  qword_list: none
@@ -2470,7 +2479,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2470
2479
  result = s(:args, list).line list.line
2471
2480
  end
2472
2481
 
2473
- result << (Sexp === item ? item : item.first)
2482
+ if Sexp === item then
2483
+ line_max = item.line_max
2484
+ else
2485
+ item, line_max = item
2486
+ end
2487
+
2488
+ result << item
2489
+ result.line_max = line_max
2474
2490
  }
2475
2491
 
2476
2492
  f_label: tLABEL
@@ -2688,7 +2704,15 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2688
2704
  opt_terms: | terms
2689
2705
  opt_nl: | tNL
2690
2706
  rparen: opt_nl tRPAREN
2707
+ {
2708
+ _, close = val
2709
+ result = [close, lexer.lineno]
2710
+ }
2691
2711
  rbracket: opt_nl tRBRACK
2712
+ {
2713
+ _, close = val
2714
+ result = [close, lexer.lineno]
2715
+ }
2692
2716
  trailer: | tNL | tCOMMA
2693
2717
 
2694
2718
  term: tSEMI { yyerrok }