parser 2.6.2.1 → 2.6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/CHANGELOG.md +7 -1
- data/doc/AST_FORMAT.md +16 -0
- data/lib/parser/builders/default.rb +4 -2
- data/lib/parser/current.rb +1 -1
- data/lib/parser/lexer.rl +25 -0
- data/lib/parser/ruby26.y +1 -1
- data/lib/parser/ruby27.y +10 -2
- data/lib/parser/version.rb +1 -1
- data/test/test_parser.rb +36 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bceee2aee10ca7b86d7fb0e29f985b0b1848425b3d256af84e5dd324046ab2f7
|
4
|
+
data.tar.gz: 9ea970432bb2dc6dc68320baf39d7f24d928c45fc8ca236c14ed4c7c8db4d29e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 577db299468896bb4dec4ca23dc14d78e58dd41dd323219de110e70ad2c691d6a9d3563339c1c4dcded9e7aaa69df5227f80ed1565f910d562928cf64c0936b4
|
7
|
+
data.tar.gz: 28c3a2a9e40727a71ac9255f1ad076ff86d2b60652eb4ac81719645c2542c3be0c818862003eae32b13c983397b86e023d9c0177f495dd45299845f1902871d5
|
data/.travis.yml
CHANGED
@@ -17,8 +17,8 @@ matrix:
|
|
17
17
|
- name: 2.5.5 / Parser tests
|
18
18
|
rvm: 2.5.5
|
19
19
|
script: bundle exec rake test_cov
|
20
|
-
- name: 2.6.
|
21
|
-
rvm: 2.6.
|
20
|
+
- name: 2.6.3 / Parser tests
|
21
|
+
rvm: 2.6.3
|
22
22
|
script: bundle exec rake test_cov
|
23
23
|
- name: ruby-head / Parser tests
|
24
24
|
rvm: ruby-head
|
@@ -32,8 +32,8 @@ matrix:
|
|
32
32
|
- name: 2.5.5 / Rubocop tests
|
33
33
|
rvm: 2.5.5
|
34
34
|
script: ./ci/run_rubocop_specs
|
35
|
-
- name: 2.6.
|
36
|
-
rvm: 2.6.
|
35
|
+
- name: 2.6.3 / Rubocop tests
|
36
|
+
rvm: 2.6.3
|
37
37
|
script: ./ci/run_rubocop_specs
|
38
38
|
allow_failures:
|
39
39
|
- rvm: ruby-head
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
-
Not released (2019-04-
|
4
|
+
Not released (2019-04-28)
|
5
5
|
-------------------------
|
6
6
|
|
7
|
+
Features implemented:
|
8
|
+
* ruby27.y: Added beginless ranges support. (#570) (Ilya Bylich)
|
9
|
+
|
10
|
+
v2.6.2.1 (2019-04-05)
|
11
|
+
---------------------
|
12
|
+
|
7
13
|
API modifications:
|
8
14
|
* Bump 2.4 branch to 2.4.6. (#569) (Ilya Bylich)
|
9
15
|
* Lexer should know about current parsing context. (#566) (Ilya Bylich)
|
data/doc/AST_FORMAT.md
CHANGED
@@ -339,6 +339,22 @@ Format:
|
|
339
339
|
~~~~ expression
|
340
340
|
~~~
|
341
341
|
|
342
|
+
### Beginless (2.7)
|
343
|
+
|
344
|
+
Format:
|
345
|
+
|
346
|
+
~~~
|
347
|
+
(irange nil (int 1))
|
348
|
+
"..1"
|
349
|
+
~~ operator
|
350
|
+
~~~ expression
|
351
|
+
|
352
|
+
(erange nil (int 1))
|
353
|
+
"...1"
|
354
|
+
~~~ operator
|
355
|
+
~~~~ expression
|
356
|
+
~~~
|
357
|
+
|
342
358
|
## Access
|
343
359
|
|
344
360
|
### Self
|
@@ -1394,10 +1394,12 @@ module Parser
|
|
1394
1394
|
end
|
1395
1395
|
|
1396
1396
|
def range_map(start_e, op_t, end_e)
|
1397
|
-
if end_e
|
1397
|
+
if start_e && end_e
|
1398
1398
|
expr_l = join_exprs(start_e, end_e)
|
1399
|
-
|
1399
|
+
elsif start_e
|
1400
1400
|
expr_l = start_e.loc.expression.join(loc(op_t))
|
1401
|
+
elsif end_e
|
1402
|
+
expr_l = loc(op_t).join(end_e.loc.expression)
|
1401
1403
|
end
|
1402
1404
|
|
1403
1405
|
Source::Map::Operator.new(loc(op_t), expr_l)
|
data/lib/parser/current.rb
CHANGED
data/lib/parser/lexer.rl
CHANGED
@@ -1910,6 +1910,31 @@ class Parser::Lexer
|
|
1910
1910
|
fbreak;
|
1911
1911
|
};
|
1912
1912
|
|
1913
|
+
#
|
1914
|
+
# RUBY 2.7 BEGINLESS RANGE
|
1915
|
+
|
1916
|
+
'..'
|
1917
|
+
=> {
|
1918
|
+
if @version >= 27
|
1919
|
+
emit(:tBDOT2)
|
1920
|
+
else
|
1921
|
+
emit(:tDOT2)
|
1922
|
+
end
|
1923
|
+
|
1924
|
+
fnext expr_beg; fbreak;
|
1925
|
+
};
|
1926
|
+
|
1927
|
+
'...'
|
1928
|
+
=> {
|
1929
|
+
if @version >= 27
|
1930
|
+
emit(:tBDOT3)
|
1931
|
+
else
|
1932
|
+
emit(:tDOT3)
|
1933
|
+
end
|
1934
|
+
|
1935
|
+
fnext expr_beg; fbreak;
|
1936
|
+
};
|
1937
|
+
|
1913
1938
|
#
|
1914
1939
|
# CONTEXT-DEPENDENT VARIABLE LOOKUP OR COMMAND INVOCATION
|
1915
1940
|
#
|
data/lib/parser/ruby26.y
CHANGED
@@ -1893,7 +1893,7 @@ regexp_contents: # nothing
|
|
1893
1893
|
result = @builder.symbol(val[0])
|
1894
1894
|
}
|
1895
1895
|
|
1896
|
-
dsym: tSYMBEG
|
1896
|
+
dsym: tSYMBEG string_contents tSTRING_END
|
1897
1897
|
{
|
1898
1898
|
@lexer.state = :expr_end
|
1899
1899
|
result = @builder.symbol_compose(val[0], val[1], val[2])
|
data/lib/parser/ruby27.y
CHANGED
@@ -17,7 +17,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
|
|
17
17
|
tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DBEG
|
18
18
|
tSTRING_DVAR tSTRING_END tSTRING_DEND tSTRING tSYMBOL
|
19
19
|
tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA tLAMBEG tCHARACTER
|
20
|
-
tRATIONAL tIMAGINARY tLABEL_END tANDDOT tMETHREF
|
20
|
+
tRATIONAL tIMAGINARY tLABEL_END tANDDOT tMETHREF tBDOT2 tBDOT3
|
21
21
|
|
22
22
|
prechigh
|
23
23
|
right tBANG tTILDE tUPLUS
|
@@ -32,7 +32,7 @@ prechigh
|
|
32
32
|
nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
|
33
33
|
left tANDOP
|
34
34
|
left tOROP
|
35
|
-
nonassoc tDOT2 tDOT3
|
35
|
+
nonassoc tDOT2 tDOT3 tBDOT2 tBDOT3
|
36
36
|
right tEH tCOLON
|
37
37
|
left kRESCUE_MOD
|
38
38
|
right tEQL tOP_ASGN
|
@@ -670,6 +670,14 @@ rule
|
|
670
670
|
{
|
671
671
|
result = @builder.range_exclusive(val[0], val[1], nil)
|
672
672
|
}
|
673
|
+
| tBDOT2 arg
|
674
|
+
{
|
675
|
+
result = @builder.range_inclusive(nil, val[0], val[1])
|
676
|
+
}
|
677
|
+
| tBDOT3 arg
|
678
|
+
{
|
679
|
+
result = @builder.range_exclusive(nil, val[0], val[1])
|
680
|
+
}
|
673
681
|
| arg tPLUS arg
|
674
682
|
{
|
675
683
|
result = @builder.binary_op(val[0], val[1], val[2])
|
data/lib/parser/version.rb
CHANGED
data/test/test_parser.rb
CHANGED
@@ -852,6 +852,42 @@ class TestParser < Minitest::Test
|
|
852
852
|
SINCE_2_6)
|
853
853
|
end
|
854
854
|
|
855
|
+
def test_beginless_range_before_27
|
856
|
+
assert_diagnoses(
|
857
|
+
[:error, :unexpected_token, { :token => 'tDOT2' }],
|
858
|
+
%q{..42},
|
859
|
+
%q{^^ location},
|
860
|
+
ALL_VERSIONS - SINCE_2_7
|
861
|
+
)
|
862
|
+
|
863
|
+
assert_diagnoses(
|
864
|
+
[:error, :unexpected_token, { :token => 'tDOT3' }],
|
865
|
+
%q{...42},
|
866
|
+
%q{^^^ location},
|
867
|
+
ALL_VERSIONS - SINCE_2_7
|
868
|
+
)
|
869
|
+
end
|
870
|
+
|
871
|
+
def test_beginless_range
|
872
|
+
assert_parses(
|
873
|
+
s(:irange, nil,
|
874
|
+
s(:int, 100)),
|
875
|
+
%q{..100},
|
876
|
+
%q{~~~~~ expression
|
877
|
+
|~~ operator},
|
878
|
+
SINCE_2_7
|
879
|
+
)
|
880
|
+
|
881
|
+
assert_parses(
|
882
|
+
s(:erange, nil,
|
883
|
+
s(:int, 100)),
|
884
|
+
%q{...100},
|
885
|
+
%q{~~~~~~ expression
|
886
|
+
|~~~ operator},
|
887
|
+
SINCE_2_7
|
888
|
+
)
|
889
|
+
end
|
890
|
+
|
855
891
|
#
|
856
892
|
# Access
|
857
893
|
#
|
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
|
+
version: 2.6.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- whitequark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|