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/ruby26_parser.y CHANGED
@@ -223,6 +223,7 @@ rule
223
223
  | lhs tEQL mrhs
224
224
  {
225
225
  lhs, _, rhs = val
226
+
226
227
  result = new_assign lhs, s(:svalue, rhs).line(rhs.line)
227
228
  }
228
229
  | mlhs tEQL mrhs_arg
@@ -998,8 +999,10 @@ rule
998
999
 
999
1000
  paren_args: tLPAREN2 opt_call_args rparen
1000
1001
  {
1001
- _, args, _ = val
1002
+ _, args, (_, line_max) = val
1003
+
1002
1004
  result = args
1005
+ result.line_max = line_max if args
1003
1006
  }
1004
1007
 
1005
1008
  opt_paren_args: none
@@ -1159,7 +1162,6 @@ rule
1159
1162
  | k_begin
1160
1163
  {
1161
1164
  lexer.cmdarg.push false
1162
- result = self.lexer.lineno
1163
1165
  }
1164
1166
  bodystmt k_end
1165
1167
  {
@@ -1204,12 +1206,14 @@ rule
1204
1206
  {
1205
1207
  result = wrap :colon3, val[1]
1206
1208
  }
1207
- | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1209
+ | tLBRACK { result = lexer.lineno } aref_args rbracket
1208
1210
  {
1209
- _, line, args, _ = val
1211
+ _, line, args, (_, line_max) = val
1212
+
1210
1213
  result = args || s(:array)
1211
1214
  result.sexp_type = :array # aref_args is :args
1212
1215
  result.line line
1216
+ result.line_max = line_max
1213
1217
  }
1214
1218
  | tLBRACE
1215
1219
  {
@@ -1314,9 +1318,6 @@ rule
1314
1318
  result = new_for iter, var, body
1315
1319
  }
1316
1320
  | k_class
1317
- {
1318
- result = self.lexer.lineno
1319
- }
1320
1321
  cpath superclass
1321
1322
  {
1322
1323
  if (self.in_def || self.in_single > 0) then
@@ -1331,9 +1332,6 @@ rule
1331
1332
  self.lexer.ignore_body_comments
1332
1333
  }
1333
1334
  | k_class tLSHFT
1334
- {
1335
- result = self.lexer.lineno
1336
- }
1337
1335
  expr
1338
1336
  {
1339
1337
  result = self.in_def
@@ -1352,9 +1350,6 @@ rule
1352
1350
  self.lexer.ignore_body_comments
1353
1351
  }
1354
1352
  | k_module
1355
- {
1356
- result = self.lexer.lineno
1357
- }
1358
1353
  cpath
1359
1354
  {
1360
1355
  yyerror "module definition in method body" if
@@ -1797,13 +1792,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1797
1792
  {
1798
1793
  call, args = val
1799
1794
 
1800
- result = call.concat args.sexp_body if args
1795
+ result = call
1796
+
1797
+ if args then
1798
+ call.concat args.sexp_body
1799
+ result.line_max = args.line_max
1800
+ end
1801
1801
  }
1802
1802
  | primary_value call_op operation2 opt_paren_args
1803
1803
  {
1804
- recv, call_op, (op, _line), args = val
1804
+ recv, call_op, (op, op_line), args = val
1805
1805
 
1806
1806
  result = new_call recv, op.to_sym, args, call_op
1807
+ result.line_max = op_line unless args
1807
1808
  }
1808
1809
  | primary_value tCOLON2 operation2 paren_args
1809
1810
  {
@@ -2017,15 +2018,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2017
2018
 
2018
2019
  words: tWORDS_BEG tSPACE tSTRING_END
2019
2020
  {
2020
- (_, line), _, _ = val
2021
+ (_, line), _, (_, line_max) = val
2021
2022
 
2022
2023
  result = s(:array).line line
2024
+ result.line_max = line_max
2023
2025
  }
2024
2026
  | tWORDS_BEG word_list tSTRING_END
2025
2027
  {
2026
- (_, line), list, _ = val
2028
+ (_, line), list, (_, line_max) = val
2027
2029
 
2028
2030
  result = list.line line
2031
+ result.line_max = line_max
2029
2032
  }
2030
2033
 
2031
2034
  word_list: none
@@ -2045,15 +2048,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2045
2048
 
2046
2049
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2047
2050
  {
2048
- (_, line), _, _ = val
2051
+ (_, line), _, (_, line_max) = val
2049
2052
 
2050
2053
  result = s(:array).line line
2054
+ result.line_max = line_max
2051
2055
  }
2052
2056
  | tSYMBOLS_BEG symbol_list tSTRING_END
2053
2057
  {
2054
- (_, line), list, _, = val
2055
- list.line line
2056
- result = list
2058
+ (_, line), list, (_, line_max), = val
2059
+
2060
+ result = list.line line
2061
+ result.line_max = line_max
2057
2062
  }
2058
2063
 
2059
2064
  symbol_list: none
@@ -2068,28 +2073,32 @@ opt_block_args_tail: tCOMMA block_args_tail
2068
2073
 
2069
2074
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2070
2075
  {
2071
- (_, line), _, _ = val
2076
+ (_, line), _, (_, line_max) = val
2072
2077
 
2073
2078
  result = s(:array).line line
2079
+ result.line_max = line_max
2074
2080
  }
2075
2081
  | tQWORDS_BEG qword_list tSTRING_END
2076
2082
  {
2077
- (_, line), list, _ = val
2083
+ (_, line), list, (_, line_max) = val
2078
2084
 
2079
2085
  result = list.line line
2086
+ result.line_max = line_max
2080
2087
  }
2081
2088
 
2082
2089
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2083
2090
  {
2084
- (_, line), _, _ = val
2091
+ (_, line), _, (_, line_max) = val
2085
2092
 
2086
2093
  result = s(:array).line line
2094
+ result.line_max = line_max
2087
2095
  }
2088
2096
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2089
2097
  {
2090
- (_, line), list, _ = val
2098
+ (_, line), list, (_, line_max) = val
2091
2099
 
2092
2100
  result = list.line line
2101
+ result.line_max = line_max
2093
2102
  }
2094
2103
 
2095
2104
  qword_list: none
@@ -2493,7 +2502,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2493
2502
  result = s(:args, list).line list.line
2494
2503
  end
2495
2504
 
2496
- result << (Sexp === item ? item : item.first)
2505
+ if Sexp === item then
2506
+ line_max = item.line_max
2507
+ else
2508
+ item, line_max = item
2509
+ end
2510
+
2511
+ result << item
2512
+ result.line_max = line_max
2497
2513
  }
2498
2514
 
2499
2515
  f_label: tLABEL
@@ -2711,7 +2727,15 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2711
2727
  opt_terms: | terms
2712
2728
  opt_nl: | tNL
2713
2729
  rparen: opt_nl tRPAREN
2730
+ {
2731
+ _, close = val
2732
+ result = [close, lexer.lineno]
2733
+ }
2714
2734
  rbracket: opt_nl tRBRACK
2735
+ {
2736
+ _, close = val
2737
+ result = [close, lexer.lineno]
2738
+ }
2715
2739
  trailer: | tNL | tCOMMA
2716
2740
 
2717
2741
  term: tSEMI { yyerrok }