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