parser 2.6.4.0 → 2.6.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e113f6f42c44591674f288ebda60f8c4f17f5b6aee601d1cc5c2e20c50ef2e6
4
- data.tar.gz: '08cf94385ef5cd8f211de395e1c272e5b7950e155463160e327cda2eb047dfad'
3
+ metadata.gz: 7d7b8b9f67b6aaacdb9a0d545465e924b4f648b111da6be699663c5c67c84e4f
4
+ data.tar.gz: 171070fa439abfe6279d7e0c713d46a28528669085cfc643ab808569d17357c1
5
5
  SHA512:
6
- metadata.gz: 25fd7715c94cf32eb097e8c0049d48f7b8185bef6ea4dafe21f0f7013c13892ff6d929e2e45f18480903f081ed9738aa8f0059287dd528cdb63feb94a47fd42e
7
- data.tar.gz: 8dfe6966704a8b5b662f99a2ee15d525f6d4cd3d74b62b0c3946f01933c86f50075572cf32a81de3bfe2fe96a07d8197a55a11906f870b80daa2d81e50987944
6
+ metadata.gz: ab3de4f196504df68763d5efaa347b4febf2e2feed3dc1f0b407565a6f93434d4b1709dbe7a1fa36f28e39b25d67434ad861818ca7d570e0b2b0d8b5b1e71ff9
7
+ data.tar.gz: 8634d57721f51fa9dd91c843960fb6c20a7bbb0331c6e62b3f29da3a770f5471f9adcaad14efb5a68904f2e93767e835022abcb9b739c113898822942085f112
@@ -1,88 +1,6 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
- v2.6.4.0 (2019-08-30)
5
- ---------------------
6
-
7
- API modifications:
8
- * Added specs for heredocs with mixed encoding. (#581) (Ilya Bylich)
9
-
10
- Features implemented:
11
- * ruby27.y: Revert "pipeline operator" (#601) (Koichi ITO)
12
- * ruby27.y: Fix parsing of mutiple assignment with rescue modifier (#600) (Koichi ITO)
13
- * ruby27.y: hoisted out f_rest_marg. (#594) (Ilya Bylich)
14
- * ruby27.y: added pipeline operator. (#592) (Ilya Bylich)
15
- * ruby27.y: reject safe navigator in LHS of mass-assignment. (#586) (Ilya Bylich)
16
- * lexer.rl: reject whitespaces in meta and control chars. (#585) (Ilya Bylich)
17
- * lexer.rl: Reject numparams as symbol literals. (#582) (Ilya Bylich)
18
- * ruby27.y: Added numbered parameters support. (#565) (Ilya Bylich)
19
- * lexer.rl: Reject \n and \r in heredoc identifiers starting from 2.7. (#575) (Ilya Bylich)
20
-
21
- Bugs fixed:
22
- * ruby-parse: print empty string when --emit-json and empty input are given. (#590) (Ilya Bylich)
23
- * AST_FORMAT: fixed documentation of the string with interpolation. (#589) (Ilya Bylich)
24
- * builder.rb, processor.rb: Changed format of the procarg0 node. (#587) (Ilya Bylich)
25
-
26
- v2.6.3.0 (2019-04-28)
27
- ---------------------
28
-
29
- Features implemented:
30
- * ruby27.y: Added beginless ranges support. (#570) (Ilya Bylich)
31
-
32
- v2.6.2.1 (2019-04-05)
33
- ---------------------
34
-
35
- API modifications:
36
- * Bump 2.4 branch to 2.4.6. (#569) (Ilya Bylich)
37
- * Lexer should know about current parsing context. (#566) (Ilya Bylich)
38
-
39
- v2.6.2.0 (2019-03-21)
40
- ---------------------
41
-
42
- API modifications:
43
- * Bump ruby versions to 2.5.5 and 2.6.2. (#563) (Ilya Bylich)
44
- * Bump Ruby version to 2.6.1. (#554) (Ilya Bylich)
45
-
46
- Features implemented:
47
- * ruby27.y: dsym should be treated as string. (#560) (Ilya Bylich)
48
- * ruby27.y: Refactored symbol rules. (#557) (Ilya Bylich)
49
- * ruby27.y: Added method reference operator. (#556) (Ilya Bylich)
50
- * ruby27.y: branch parser. (#546) (Ilya Bylich)
51
-
52
- v2.6.0.0 (2019-01-16)
53
- ---------------------
54
-
55
- API modifications:
56
- * 2.6.0 was released, unmark is as -dev. (#538) (Ilya Bylich)
57
-
58
- Bugs fixed:
59
- * Fix parsing of "\\\n" escaped sequences in various literals. (#539) (Ilya Bylich)
60
-
61
- v2.5.3.0 (2018-10-29)
62
- ---------------------
63
-
64
- Bugs fixed:
65
- * lexer.rl: Fix parsing of 'm :key => m do; m() do end; end'. (#526) (Ilya Bylich)
66
- * lexer.rl: Fix parsing of ambiguous 1re. (#523) (Ilya Bylich)
67
-
68
- v2.5.1.2 (2018-07-10)
69
- ---------------------
70
-
71
- Bugs fixed:
72
- * lexer.rl: Partially revert 5ba072d and properly handle 'm = -> *args do end'. (Ilya Bylich)
73
-
74
- v2.5.1.1 (2018-07-10)
75
- ---------------------
76
-
77
- Features implemented:
78
- * ruby26.y: Endless ranges support. (Ilya Bylich)
79
-
80
- Bugs fixed:
81
- * lexer.rl: Fix parsing of 'm = -> *args do end'. (Ilya Bylich)
82
- * AST::Processor: Properly recurse into "kwsplat" nodes (Nelson Elhage)
83
- * ruby24, ruby25, ruby26: Fix cmdargs after command_args followed by tLBRACE_ARG. This commit tracks upstream commit ruby/ruby@f168dbd. (Ilya Bylich)
84
- * lexer.rl: Fix parsing of `let (:a) { m do; end }`. (Ilya Bylich)
85
-
86
4
  v2.5.1.0 (2018-04-12)
87
5
  ---------------------
88
6
 
@@ -1032,6 +1032,17 @@ Format:
1032
1032
  ~~ expression
1033
1033
  ~~~
1034
1034
 
1035
+ ### Keyword nil argument
1036
+
1037
+ Format:
1038
+
1039
+ ~~~
1040
+ (kwnilarg)
1041
+ "**nil"
1042
+ ~~~ name
1043
+ ~~~~~ expression
1044
+ ~~~
1045
+
1035
1046
  ### Objective-C arguments
1036
1047
 
1037
1048
  MacRuby includes a few more syntactic "arguments" whose name becomes
@@ -730,6 +730,11 @@ module Parser
730
730
  end
731
731
  end
732
732
 
733
+ def kwnilarg(dstar_t, nil_t)
734
+ n0(:kwnilarg,
735
+ arg_prefix_map(dstar_t, nil_t))
736
+ end
737
+
733
738
  def shadowarg(name_t)
734
739
  n(:shadowarg, [ value(name_t).to_sym ],
735
740
  variable_map(name_t))
@@ -172,7 +172,7 @@ class Parser::Lexer
172
172
  # If the lexer is in `command state' (aka expr_value)
173
173
  # at the entry to #advance, it will transition to expr_cmdarg
174
174
  # instead of expr_arg at certain points.
175
- @command_state = false
175
+ @command_start = true
176
176
 
177
177
  # True at the end of "def foo a:"
178
178
  @in_kwarg = false
@@ -287,8 +287,8 @@ class Parser::Lexer
287
287
  pe = @source_pts.size + 2
288
288
  p, eof = @p, pe
289
289
 
290
- @command_state = (@cs == klass.lex_en_expr_value ||
291
- @cs == klass.lex_en_line_begin)
290
+ cmd_state = @command_start
291
+ @command_start = false
292
292
 
293
293
  %% write exec;
294
294
  # %
@@ -358,8 +358,8 @@ class Parser::Lexer
358
358
  end
359
359
  end
360
360
 
361
- def arg_or_cmdarg
362
- if @command_state
361
+ def arg_or_cmdarg(cmd_state)
362
+ if cmd_state
363
363
  self.class.lex_en_expr_cmdarg
364
364
  else
365
365
  self.class.lex_en_expr_arg
@@ -1089,6 +1089,7 @@ class Parser::Lexer
1089
1089
  end
1090
1090
 
1091
1091
  current_literal.start_interp_brace
1092
+ @command_start = true
1092
1093
  fnext expr_value;
1093
1094
  fbreak;
1094
1095
  }
@@ -1275,6 +1276,10 @@ class Parser::Lexer
1275
1276
  @cond.push(false); @cmdarg.push(false)
1276
1277
 
1277
1278
  @paren_nest += 1
1279
+
1280
+ if version?(18)
1281
+ @command_start = true
1282
+ end
1278
1283
  };
1279
1284
 
1280
1285
  e_rparen = ')' % {
@@ -1288,7 +1293,7 @@ class Parser::Lexer
1288
1293
  if !@static_env.nil? && @static_env.declared?(tok)
1289
1294
  fnext expr_endfn; fbreak;
1290
1295
  else
1291
- fnext *arg_or_cmdarg; fbreak;
1296
+ fnext *arg_or_cmdarg(cmd_state); fbreak;
1292
1297
  end
1293
1298
  }
1294
1299
 
@@ -1445,15 +1450,15 @@ class Parser::Lexer
1445
1450
  expr_dot := |*
1446
1451
  constant
1447
1452
  => { emit(:tCONSTANT)
1448
- fnext *arg_or_cmdarg; fbreak; };
1453
+ fnext *arg_or_cmdarg(cmd_state); fbreak; };
1449
1454
 
1450
1455
  call_or_var
1451
1456
  => { emit(:tIDENTIFIER)
1452
- fnext *arg_or_cmdarg; fbreak; };
1457
+ fnext *arg_or_cmdarg(cmd_state); fbreak; };
1453
1458
 
1454
1459
  bareword ambiguous_fid_suffix
1455
1460
  => { emit(:tFID, tok(@ts, tm), @ts, tm)
1456
- fnext *arg_or_cmdarg; p = tm - 1; fbreak; };
1461
+ fnext *arg_or_cmdarg(cmd_state); p = tm - 1; fbreak; };
1457
1462
 
1458
1463
  # See the comment in `expr_fname`.
1459
1464
  operator_fname |
@@ -1513,6 +1518,7 @@ class Parser::Lexer
1513
1518
  else
1514
1519
  emit(:tLCURLY, '{'.freeze, @te - 1, @te)
1515
1520
  end
1521
+ @command_start = true
1516
1522
  fnext expr_value; fbreak;
1517
1523
  };
1518
1524
 
@@ -1673,6 +1679,7 @@ class Parser::Lexer
1673
1679
  else
1674
1680
  emit(:tLBRACE_ARG, '{'.freeze)
1675
1681
  end
1682
+ @command_start = true
1676
1683
  fnext expr_value; fbreak;
1677
1684
  };
1678
1685
 
@@ -1929,6 +1936,7 @@ class Parser::Lexer
1929
1936
  => {
1930
1937
  if @lambda_stack.last == @paren_nest
1931
1938
  @lambda_stack.pop
1939
+ @command_start = true
1932
1940
  emit(:tLAMBEG, '{'.freeze)
1933
1941
  else
1934
1942
  emit(:tLBRACE, '{'.freeze)
@@ -1961,6 +1969,7 @@ class Parser::Lexer
1961
1969
  # if a: Statement if.
1962
1970
  keyword_modifier
1963
1971
  => { emit_table(KEYWORDS_BEGIN)
1972
+ @command_start = true
1964
1973
  fnext expr_value; fbreak; };
1965
1974
 
1966
1975
  #
@@ -1981,7 +1990,7 @@ class Parser::Lexer
1981
1990
  if !@static_env.nil? && @static_env.declared?(ident)
1982
1991
  fnext expr_end;
1983
1992
  else
1984
- fnext *arg_or_cmdarg;
1993
+ fnext *arg_or_cmdarg(cmd_state);
1985
1994
  end
1986
1995
  else
1987
1996
  emit(:tLABEL, tok(@ts, @te - 2), @ts, @te - 1)
@@ -2150,6 +2159,7 @@ class Parser::Lexer
2150
2159
  emit_do
2151
2160
  end
2152
2161
  end
2162
+ @command_start = true
2153
2163
 
2154
2164
  fnext expr_value; fbreak;
2155
2165
  };
@@ -2175,6 +2185,7 @@ class Parser::Lexer
2175
2185
  # elsif b:c: elsif b(:c)
2176
2186
  keyword_with_value
2177
2187
  => { emit_table(KEYWORDS)
2188
+ @command_start = true
2178
2189
  fnext expr_value; fbreak; };
2179
2190
 
2180
2191
  keyword_with_mid
@@ -2198,7 +2209,7 @@ class Parser::Lexer
2198
2209
  emit(:tIDENTIFIER)
2199
2210
 
2200
2211
  unless !@static_env.nil? && @static_env.declared?(tok)
2201
- fnext *arg_or_cmdarg;
2212
+ fnext *arg_or_cmdarg(cmd_state);
2202
2213
  end
2203
2214
  else
2204
2215
  emit(:k__ENCODING__, '__ENCODING__'.freeze)
@@ -2309,7 +2320,7 @@ class Parser::Lexer
2309
2320
 
2310
2321
  constant
2311
2322
  => { emit(:tCONSTANT)
2312
- fnext *arg_or_cmdarg; fbreak; };
2323
+ fnext *arg_or_cmdarg(cmd_state); fbreak; };
2313
2324
 
2314
2325
  constant ambiguous_const_suffix
2315
2326
  => { emit(:tCONSTANT, tok(@ts, tm), @ts, tm)
@@ -2423,6 +2434,7 @@ class Parser::Lexer
2423
2434
 
2424
2435
  ';'
2425
2436
  => { emit(:tSEMI, ';'.freeze)
2437
+ @command_start = true
2426
2438
  fnext expr_value; fbreak; };
2427
2439
 
2428
2440
  '\\' c_line {
@@ -2481,7 +2493,7 @@ class Parser::Lexer
2481
2493
  => { p = pe - 3 };
2482
2494
 
2483
2495
  c_any
2484
- => { fhold; fgoto expr_value; };
2496
+ => { cmd_state = true; fhold; fgoto expr_value; };
2485
2497
 
2486
2498
  c_eof => do_eof;
2487
2499
  *|;
@@ -18,7 +18,7 @@ module Parser
18
18
  match_with_lvasgn match_current_line
19
19
  module class sclass def defs undef alias args
20
20
  cbase arg optarg restarg blockarg block_pass kwarg kwoptarg
21
- kwrestarg send csend super zsuper yield block
21
+ kwrestarg kwnilarg send csend super zsuper yield block
22
22
  and not or if when case while until while_post
23
23
  until_post for break next redo return resbody
24
24
  kwbegin begin retry preexe postexe iflipflop eflipflop
@@ -1352,6 +1352,10 @@ rule
1352
1352
  {
1353
1353
  result = val[0].concat(val[1])
1354
1354
  }
1355
+ | f_no_kwarg opt_f_block_arg
1356
+ {
1357
+ result = val[0].concat(val[1])
1358
+ }
1355
1359
  | f_block_arg
1356
1360
  {
1357
1361
  result = [ val[0] ]
@@ -2092,6 +2096,10 @@ keyword_variable: kNIL
2092
2096
  {
2093
2097
  result = val[0].concat(val[1])
2094
2098
  }
2099
+ | f_no_kwarg opt_f_block_arg
2100
+ {
2101
+ result = val[0].concat(val[1])
2102
+ }
2095
2103
  | f_block_arg
2096
2104
  {
2097
2105
  result = [ val[0] ]
@@ -2295,6 +2303,11 @@ keyword_variable: kNIL
2295
2303
 
2296
2304
  kwrest_mark: tPOW | tDSTAR
2297
2305
 
2306
+ f_no_kwarg: kwrest_mark kNIL
2307
+ {
2308
+ result = [ @builder.kwnilarg(val[0], val[1]) ]
2309
+ }
2310
+
2298
2311
  f_kwrest: kwrest_mark tIDENTIFIER
2299
2312
  {
2300
2313
  @static_env.declare val[1][0]
@@ -281,7 +281,7 @@ module Parser
281
281
  def enforce_policy(event)
282
282
  return if @policy[event] == :accept
283
283
  return unless (values = yield)
284
- trigger_policy(event, values)
284
+ trigger_policy(event, **values)
285
285
  end
286
286
 
287
287
  POLICY_TO_LEVEL = {warn: :warning, raise: :error}.freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parser
4
- VERSION = '2.6.4.0'
4
+ VERSION = '2.6.4.1'
5
5
  end
@@ -2095,6 +2095,37 @@ class TestParser < Minitest::Test
2095
2095
  SINCE_2_0)
2096
2096
  end
2097
2097
 
2098
+ def test_kwnilarg
2099
+ assert_parses(
2100
+ s(:def, :f,
2101
+ s(:args, s(:kwnilarg)),
2102
+ nil),
2103
+ %q{def f(**nil); end},
2104
+ %q{ ~~~~~ expression (args.kwnilarg)
2105
+ | ~~~ name (args.kwnilarg)},
2106
+ SINCE_2_7)
2107
+
2108
+ assert_parses(
2109
+ s(:block,
2110
+ s(:send, nil, :m),
2111
+ s(:args,
2112
+ s(:kwnilarg)), nil),
2113
+ %q{m { |**nil| }},
2114
+ %q{ ~~~~~ expression (args.kwnilarg)
2115
+ | ~~~ name (args.kwnilarg)},
2116
+ SINCE_2_7)
2117
+
2118
+ assert_parses(
2119
+ s(:block,
2120
+ s(:lambda),
2121
+ s(:args,
2122
+ s(:kwnilarg)), nil),
2123
+ %q{->(**nil) {}},
2124
+ %q{ ~~~~~ expression (args.kwnilarg)
2125
+ | ~~~ name (args.kwnilarg)},
2126
+ SINCE_2_7)
2127
+ end
2128
+
2098
2129
  def test_blockarg
2099
2130
  assert_parses(
2100
2131
  s(:def, :f,
@@ -7532,4 +7563,17 @@ class TestParser < Minitest::Test
7532
7563
  %q{ ^^ location},
7533
7564
  SINCE_2_7)
7534
7565
  end
7566
+
7567
+ def test_parser_bug_604
7568
+ assert_parses(
7569
+ s(:block,
7570
+ s(:send, nil, :m,
7571
+ s(:send,
7572
+ s(:send, nil, :a), :+,
7573
+ s(:send, nil, :b))),
7574
+ s(:args), nil),
7575
+ %q{m a + b do end},
7576
+ %q{},
7577
+ ALL_VERSIONS)
7578
+ end
7535
7579
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.4.0
4
+ version: 2.6.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - whitequark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-30 00:00:00.000000000 Z
11
+ date: 2019-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast
@@ -309,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
309
309
  - !ruby/object:Gem::Version
310
310
  version: '0'
311
311
  requirements: []
312
- rubygems_version: 3.0.1
312
+ rubygems_version: 3.0.6
313
313
  signing_key:
314
314
  specification_version: 4
315
315
  summary: A Ruby parser written in pure Ruby.