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