ruby_parser 3.20.0 → 3.20.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1179,12 +1182,14 @@ rule
1179
1182
  {
1180
1183
  result = wrap :colon3, val[1]
1181
1184
  }
1182
- | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1185
+ | tLBRACK { result = lexer.lineno } aref_args rbracket
1183
1186
  {
1184
- _, line, args, _ = val
1187
+ _, line, args, (_, line_max) = val
1188
+
1185
1189
  result = args || s(:array)
1186
1190
  result.sexp_type = :array # aref_args is :args
1187
1191
  result.line line
1192
+ result.line_max = line_max
1188
1193
  }
1189
1194
  | tLBRACE
1190
1195
  {
@@ -1772,13 +1777,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1772
1777
  {
1773
1778
  call, args = val
1774
1779
 
1775
- 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
1776
1786
  }
1777
1787
  | primary_value call_op operation2 opt_paren_args
1778
1788
  {
1779
- recv, call_op, (op, _line), args = val
1789
+ recv, call_op, (op, op_line), args = val
1780
1790
 
1781
1791
  result = new_call recv, op.to_sym, args, call_op
1792
+ result.line_max = op_line unless args
1782
1793
  }
1783
1794
  | primary_value tCOLON2 operation2 paren_args
1784
1795
  {
@@ -1992,15 +2003,17 @@ opt_block_args_tail: tCOMMA block_args_tail
1992
2003
 
1993
2004
  words: tWORDS_BEG tSPACE tSTRING_END
1994
2005
  {
1995
- (_, line), _, _ = val
2006
+ (_, line), _, (_, line_max) = val
1996
2007
 
1997
2008
  result = s(:array).line line
2009
+ result.line_max = line_max
1998
2010
  }
1999
2011
  | tWORDS_BEG word_list tSTRING_END
2000
2012
  {
2001
- (_, line), list, _ = val
2013
+ (_, line), list, (_, line_max) = val
2002
2014
 
2003
2015
  result = list.line line
2016
+ result.line_max = line_max
2004
2017
  }
2005
2018
 
2006
2019
  word_list: none
@@ -2020,15 +2033,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2020
2033
 
2021
2034
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2022
2035
  {
2023
- (_, line), _, _ = val
2036
+ (_, line), _, (_, line_max) = val
2024
2037
 
2025
2038
  result = s(:array).line line
2039
+ result.line_max = line_max
2026
2040
  }
2027
2041
  | tSYMBOLS_BEG symbol_list tSTRING_END
2028
2042
  {
2029
- (_, line), list, _, = val
2030
- list.line line
2031
- result = list
2043
+ (_, line), list, (_, line_max), = val
2044
+
2045
+ result = list.line line
2046
+ result.line_max = line_max
2032
2047
  }
2033
2048
 
2034
2049
  symbol_list: none
@@ -2043,28 +2058,32 @@ opt_block_args_tail: tCOMMA block_args_tail
2043
2058
 
2044
2059
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2045
2060
  {
2046
- (_, line), _, _ = val
2061
+ (_, line), _, (_, line_max) = val
2047
2062
 
2048
2063
  result = s(:array).line line
2064
+ result.line_max = line_max
2049
2065
  }
2050
2066
  | tQWORDS_BEG qword_list tSTRING_END
2051
2067
  {
2052
- (_, line), list, _ = val
2068
+ (_, line), list, (_, line_max) = val
2053
2069
 
2054
2070
  result = list.line line
2071
+ result.line_max = line_max
2055
2072
  }
2056
2073
 
2057
2074
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2058
2075
  {
2059
- (_, line), _, _ = val
2076
+ (_, line), _, (_, line_max) = val
2060
2077
 
2061
2078
  result = s(:array).line line
2079
+ result.line_max = line_max
2062
2080
  }
2063
2081
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2064
2082
  {
2065
- (_, line), list, _ = val
2083
+ (_, line), list, (_, line_max) = val
2066
2084
 
2067
2085
  result = list.line line
2086
+ result.line_max = line_max
2068
2087
  }
2069
2088
 
2070
2089
  qword_list: none
@@ -2466,7 +2485,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2466
2485
  result = s(:args, list).line list.line
2467
2486
  end
2468
2487
 
2469
- result << (Sexp === item ? item : item.first)
2488
+ if Sexp === item then
2489
+ line_max = item.line_max
2490
+ else
2491
+ item, line_max = item
2492
+ end
2493
+
2494
+ result << item
2495
+ result.line_max = line_max
2470
2496
  }
2471
2497
 
2472
2498
  f_label: tLABEL
@@ -2675,7 +2701,15 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2675
2701
  opt_terms: | terms
2676
2702
  opt_nl: | tNL
2677
2703
  rparen: opt_nl tRPAREN
2704
+ {
2705
+ _, close = val
2706
+ result = [close, lexer.lineno]
2707
+ }
2678
2708
  rbracket: opt_nl tRBRACK
2709
+ {
2710
+ _, close = val
2711
+ result = [close, lexer.lineno]
2712
+ }
2679
2713
  trailer: | tNL | tCOMMA
2680
2714
 
2681
2715
  term: tSEMI { yyerrok }