ruby_parser 3.19.2 → 3.20.1

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