parser 2.7.0.4 → 2.7.0.5

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: 13d527f63ead893a2e151944c1bcdd8b42b7e62b59619c52c5173782d1121964
4
- data.tar.gz: 741979c7e6c252b0ddd18c69b79738cc01771d2bed73ec15c30cb3b2cccd9631
3
+ metadata.gz: 00a9bc5b2d70892e4743417168e53dc469c80328c3983e71b41f312becd116b0
4
+ data.tar.gz: 1abbc88751dc8d3b7c28d2df69b71a773533ed2d3726de50df8cfaaa79887aaa
5
5
  SHA512:
6
- metadata.gz: 53f345d27c23b86ef7fe55bcbfdbab9605f313e721c8ae75aebfa6d84073d3e738e42fbffeced65463ea1ad1233dc0297c55ad04187c36eb3c1878d36caac4dd
7
- data.tar.gz: 6035992372bdc46cfd086508cfecaf3d24f014317681e45c4190b18d5fbe126fad3bf399b98ae465ab46d1827d88b7c0241998c0d4723ae780e05250b8168ad7
6
+ metadata.gz: 32455424b4003ba1510d53b162aa8691bdaea5708b4d88d392d6c89cfa3b6479f1d47c9f42fedd40e663366192434aaf851dbe65cbd1a629c54b7681cfb37879
7
+ data.tar.gz: 0c464e9acd5cf95161e18552e4680230417a05e7ad14e805b8661e4bb2ee7a99f4ad2f4e0212c48b35bc9f3ed8549b6723925f0b194e0a57873a2eb472450dbb
@@ -1,9 +1,18 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
- Not released (2020-03-02)
4
+ Not released (2020-03-20)
5
5
  -------------------------
6
6
 
7
+ Features implemented:
8
+ * ruby27.y: fix array pattern with tail source map (#659) (Vladimir Dementyev)
9
+
10
+ Bugs fixed:
11
+ * builder.rb: fix constant_pattern source map (#660) (Vladimir Dementyev)
12
+
13
+ v2.7.0.4 (2020-03-02)
14
+ ---------------------
15
+
7
16
  Bugs fixed:
8
17
  * lexer.rl: allow spaces before comments-before-leading-dot. (#654) (Ilya Bylich)
9
18
 
data/README.md CHANGED
@@ -24,10 +24,11 @@ below for explanation of `emit_*` calls):
24
24
 
25
25
  require 'parser/current'
26
26
  # opt-in to most recent AST format:
27
- Parser::Builders::Default.emit_lambda = true
28
- Parser::Builders::Default.emit_procarg0 = true
29
- Parser::Builders::Default.emit_encoding = true
30
- Parser::Builders::Default.emit_index = true
27
+ Parser::Builders::Default.emit_lambda = true
28
+ Parser::Builders::Default.emit_procarg0 = true
29
+ Parser::Builders::Default.emit_encoding = true
30
+ Parser::Builders::Default.emit_index = true
31
+ Parser::Builders::Default.emit_arg_inside_procarg0 = true
31
32
 
32
33
  Parse a chunk of code:
33
34
 
@@ -2068,7 +2068,7 @@ so a single item match with comma gets interpreted as an array.
2068
2068
  (array-pattern-with-tail
2069
2069
  (match-var :foo))
2070
2070
  "in foo,"
2071
- ~~~ expression
2071
+ ~~~~ expression
2072
2072
  ~~~
2073
2073
 
2074
2074
  ### Matching using hash pattern
@@ -2139,7 +2139,7 @@ Format:
2139
2139
  "in X[^foo bar]"
2140
2140
  ~ begin (const-pattern)
2141
2141
  ~ end (const-pattern)
2142
- ~~~~~~~~~~~ expression (const-pattern)
2142
+ ~~~~~~~~~~~~ expression (const-pattern)
2143
2143
  ~ name (const-pattern.const)
2144
2144
  ~ expression (const-pattern.const)
2145
2145
  ~~~
@@ -2157,7 +2157,7 @@ Format:
2157
2157
  "in X[foo:, bar:]"
2158
2158
  ~ begin (const-pattern)
2159
2159
  ~ end (const-pattern)
2160
- ~~~~~~~~~~~~ expression (const-pattern)
2160
+ ~~~~~~~~~~~~~ expression (const-pattern)
2161
2161
  ~ name (const-pattern.const)
2162
2162
  ~ expression (const-pattern.const)
2163
2163
  ~~~
@@ -2173,7 +2173,7 @@ Format:
2173
2173
  "in X[]"
2174
2174
  ~ begin (const-pattern)
2175
2175
  ~ end (const-pattern)
2176
- ~~ expression (const-pattern)
2176
+ ~~~ expression (const-pattern)
2177
2177
  ~ name (const-pattern.const)
2178
2178
  ~ expression (const-pattern.const)
2179
2179
  ~~ expression (const-pattern.array_pattern)
@@ -1318,7 +1318,7 @@ module Parser
1318
1318
 
1319
1319
  trailing_comma = false
1320
1320
 
1321
- elements = elements.map do |element|
1321
+ node_elements = elements.map do |element|
1322
1322
  if element.type == :match_with_trailing_comma
1323
1323
  trailing_comma = true
1324
1324
  element.children.first
@@ -1329,17 +1329,22 @@ module Parser
1329
1329
  end
1330
1330
 
1331
1331
  node_type = trailing_comma ? :array_pattern_with_tail : :array_pattern
1332
- n(node_type, elements,
1332
+
1333
+ n(node_type, node_elements,
1333
1334
  collection_map(lbrack_t, elements, rbrack_t))
1334
1335
  end
1335
1336
 
1336
- def match_with_trailing_comma(match)
1337
- n(:match_with_trailing_comma, [ match ], nil)
1337
+ def match_with_trailing_comma(match, comma_t)
1338
+ n(:match_with_trailing_comma, [ match ], expr_map(match.loc.expression.join(loc(comma_t))))
1338
1339
  end
1339
1340
 
1340
1341
  def const_pattern(const, ldelim_t, pattern, rdelim_t)
1341
1342
  n(:const_pattern, [const, pattern],
1342
- collection_map(ldelim_t, [pattern], rdelim_t))
1343
+ Source::Map::Collection.new(
1344
+ loc(ldelim_t), loc(rdelim_t),
1345
+ const.loc.expression.join(loc(rdelim_t))
1346
+ )
1347
+ )
1343
1348
  end
1344
1349
 
1345
1350
  def pin(pin_t, var)
@@ -1784,7 +1784,7 @@ opt_block_args_tail:
1784
1784
  # array patterns that end with comma
1785
1785
  # like 1, 2,
1786
1786
  # must be emitted as `array_pattern_with_tail`
1787
- item = @builder.match_with_trailing_comma(val[0])
1787
+ item = @builder.match_with_trailing_comma(val[0], val[1])
1788
1788
  result = @builder.array_pattern(nil, [ item ], nil)
1789
1789
  }
1790
1790
  | p_expr tCOMMA p_args
@@ -1934,7 +1934,7 @@ opt_block_args_tail:
1934
1934
  # array patterns that end with comma
1935
1935
  # like [1, 2,]
1936
1936
  # must be emitted as `array_pattern_with_tail`
1937
- item = @builder.match_with_trailing_comma(val[0])
1937
+ item = @builder.match_with_trailing_comma(val[0], val[1])
1938
1938
  result = [ item ]
1939
1939
  }
1940
1940
  | p_args_head p_arg tCOMMA
@@ -1942,7 +1942,7 @@ opt_block_args_tail:
1942
1942
  # array patterns that end with comma
1943
1943
  # like [1, 2,]
1944
1944
  # must be emitted as `array_pattern_with_tail`
1945
- last_item = @builder.match_with_trailing_comma(val[1])
1945
+ last_item = @builder.match_with_trailing_comma(val[1], val[2])
1946
1946
  result = [ *val[0], last_item ]
1947
1947
  }
1948
1948
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parser
4
- VERSION = '2.7.0.4'
4
+ VERSION = '2.7.0.5'
5
5
  end
@@ -8422,7 +8422,7 @@ class TestParser < Minitest::Test
8422
8422
  nil,
8423
8423
  s(:nil)),
8424
8424
  %q{in x, then nil},
8425
- %q{ ~ expression (in_pattern.array_pattern_with_tail)}
8425
+ %q{ ~~ expression (in_pattern.array_pattern_with_tail)}
8426
8426
  )
8427
8427
 
8428
8428
  assert_parses_pattern_match(
@@ -8468,7 +8468,7 @@ class TestParser < Minitest::Test
8468
8468
  nil,
8469
8469
  s(:nil)),
8470
8470
  %q{in x, y, then nil},
8471
- %q{ ~~~~ expression (in_pattern.array_pattern_with_tail)}
8471
+ %q{ ~~~~~ expression (in_pattern.array_pattern_with_tail)}
8472
8472
  )
8473
8473
 
8474
8474
  assert_parses_pattern_match(
@@ -8993,7 +8993,7 @@ class TestParser < Minitest::Test
8993
8993
  nil,
8994
8994
  s(:true)),
8995
8995
  %q{in A(1, 2) then true},
8996
- %q{ ~~~~~~ expression (in_pattern.const_pattern)
8996
+ %q{ ~~~~~~~ expression (in_pattern.const_pattern)
8997
8997
  | ~ begin (in_pattern.const_pattern)
8998
8998
  | ~ end (in_pattern.const_pattern)
8999
8999
  | ~ expression (in_pattern.const_pattern.const)
@@ -9009,7 +9009,7 @@ class TestParser < Minitest::Test
9009
9009
  nil,
9010
9010
  s(:true)),
9011
9011
  %q{in A(x:) then true},
9012
- %q{ ~~~~ expression (in_pattern.const_pattern)
9012
+ %q{ ~~~~~ expression (in_pattern.const_pattern)
9013
9013
  | ~ begin (in_pattern.const_pattern)
9014
9014
  | ~ end (in_pattern.const_pattern)
9015
9015
  | ~ expression (in_pattern.const_pattern.const)
@@ -9024,7 +9024,7 @@ class TestParser < Minitest::Test
9024
9024
  nil,
9025
9025
  s(:true)),
9026
9026
  %q{in A() then true},
9027
- %q{ ~~ expression (in_pattern.const_pattern)
9027
+ %q{ ~~~ expression (in_pattern.const_pattern)
9028
9028
  | ~ begin (in_pattern.const_pattern)
9029
9029
  | ~ end (in_pattern.const_pattern)
9030
9030
  | ~ expression (in_pattern.const_pattern.const)
@@ -9041,7 +9041,7 @@ class TestParser < Minitest::Test
9041
9041
  nil,
9042
9042
  s(:true)),
9043
9043
  %q{in A[1, 2] then true},
9044
- %q{ ~~~~~~ expression (in_pattern.const_pattern)
9044
+ %q{ ~~~~~~~ expression (in_pattern.const_pattern)
9045
9045
  | ~ begin (in_pattern.const_pattern)
9046
9046
  | ~ end (in_pattern.const_pattern)
9047
9047
  | ~ expression (in_pattern.const_pattern.const)
@@ -9057,7 +9057,7 @@ class TestParser < Minitest::Test
9057
9057
  nil,
9058
9058
  s(:true)),
9059
9059
  %q{in A[x:] then true},
9060
- %q{ ~~~~ expression (in_pattern.const_pattern)
9060
+ %q{ ~~~~~ expression (in_pattern.const_pattern)
9061
9061
  | ~ begin (in_pattern.const_pattern)
9062
9062
  | ~ end (in_pattern.const_pattern)
9063
9063
  | ~ expression (in_pattern.const_pattern.const)
@@ -9072,7 +9072,7 @@ class TestParser < Minitest::Test
9072
9072
  nil,
9073
9073
  s(:true)),
9074
9074
  %q{in A[] then true},
9075
- %q{ ~~ expression (in_pattern.const_pattern)
9075
+ %q{ ~~~ expression (in_pattern.const_pattern)
9076
9076
  | ~ begin (in_pattern.const_pattern)
9077
9077
  | ~ end (in_pattern.const_pattern)
9078
9078
  | ~~ expression (in_pattern.const_pattern.array_pattern)}
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.7.0.4
4
+ version: 2.7.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - whitequark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-02 00:00:00.000000000 Z
11
+ date: 2020-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast
@@ -297,9 +297,9 @@ licenses:
297
297
  - MIT
298
298
  metadata:
299
299
  bug_tracker_uri: https://github.com/whitequark/parser/issues
300
- changelog_uri: https://github.com/whitequark/parser/blob/v2.7.0.4/CHANGELOG.md
301
- documentation_uri: https://www.rubydoc.info/gems/parser/2.7.0.4
302
- source_code_uri: https://github.com/whitequark/parser/tree/v2.7.0.4
300
+ changelog_uri: https://github.com/whitequark/parser/blob/v2.7.0.5/CHANGELOG.md
301
+ documentation_uri: https://www.rubydoc.info/gems/parser/2.7.0.5
302
+ source_code_uri: https://github.com/whitequark/parser/tree/v2.7.0.5
303
303
  post_install_message:
304
304
  rdoc_options: []
305
305
  require_paths: