parser 2.6.5.0 → 2.7.0.4

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: c12b17e36f142aa8aacc1aae95cd464ea9239cf526d973b7b1ed3f0825fc7698
4
- data.tar.gz: 49948dbdc512a19d0b02d5edea2e12ff4eed8c89a2827728e5f0f9a618109b44
3
+ metadata.gz: 13d527f63ead893a2e151944c1bcdd8b42b7e62b59619c52c5173782d1121964
4
+ data.tar.gz: 741979c7e6c252b0ddd18c69b79738cc01771d2bed73ec15c30cb3b2cccd9631
5
5
  SHA512:
6
- metadata.gz: 67bbf82221c9795d5a892f51ccb3c51835657448842a078bbcee88b8b1ef649643600d01d2c1c0b2e59982a774803a3a780538c433e8cc3a4fdfe8168838a697
7
- data.tar.gz: 9d7053f65800e04f8f2c0b1f344d9f83efd1282744aba49c02b384ea4242a3bcc5b65b7ac3eca4c4d0c34317ed70393a1eb26e146b34517ad75810b9498eb0a7
6
+ metadata.gz: 53f345d27c23b86ef7fe55bcbfdbab9605f313e721c8ae75aebfa6d84073d3e738e42fbffeced65463ea1ad1233dc0297c55ad04187c36eb3c1878d36caac4dd
7
+ data.tar.gz: 6035992372bdc46cfd086508cfecaf3d24f014317681e45c4190b18d5fbe126fad3bf399b98ae465ab46d1827d88b7c0241998c0d4723ae780e05250b8168ad7
@@ -20,6 +20,9 @@ matrix:
20
20
  - name: 2.6.5 / Parser tests
21
21
  rvm: 2.6.5
22
22
  script: bundle exec rake test_cov
23
+ - name: 2.7.0 / Parser tests
24
+ rvm: 2.7.0
25
+ script: bundle exec rake test_cov
23
26
  - name: ruby-head / Parser tests
24
27
  rvm: ruby-head
25
28
  script: bundle exec rake test_cov
@@ -35,6 +38,9 @@ matrix:
35
38
  - name: 2.6.5 / Rubocop tests
36
39
  rvm: 2.6.5
37
40
  script: ./ci/run_rubocop_specs
41
+ - name: 2.7.0 / Rubocop tests
42
+ rvm: 2.7.0
43
+ script: ./ci/run_rubocop_specs
38
44
  allow_failures:
39
45
  - rvm: ruby-head
40
46
  - rvm: rbx-2
@@ -1,6 +1,58 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ Not released (2020-03-02)
5
+ -------------------------
6
+
7
+ Bugs fixed:
8
+ * lexer.rl: allow spaces before comments-before-leading-dot. (#654) (Ilya Bylich)
9
+
10
+ v2.7.0.2 (2020-01-08)
11
+ ---------------------
12
+
13
+ Bugs fixed:
14
+ * lexer.rl: fix paren_nest for curly braces (#646) (Ilya Bylich)
15
+
16
+ v2.7.0.1 (2019-12-30)
17
+ ---------------------
18
+
19
+ Bugs fixed:
20
+ * dedenter.rb: prevent `ArgumentError` when processing binary en… (#642) (Koichi ITO)
21
+
22
+ v2.7.0.0 (2019-12-26)
23
+ ---------------------
24
+
25
+ API modifications:
26
+ * README.md: documented compatibility issue with EOF chars after… (#637) (Ilya Bylich)
27
+ * ruby27.y: refactor logic around 'circular argument reference'(#628) (Ilya Bylich)
28
+
29
+ Features implemented:
30
+ * ruby27.y: added pattern matching (#574) (Ilya Bylich)
31
+ * lexer.rl: parse embedded ivars/cvars starting with digit as str (#639) (Ilya Bylich)
32
+ * lexer.rl: warn on `...` at EOL. (#636) (Ilya Bylich)
33
+ * ruby27.y: removed opt_block_args_tail: tOROP rule. (#635) (Ilya Bylich)
34
+ * ruby27.y: reverted method reference operator (added in #634) (Ilya Bylich)
35
+ * ruby27.y: treat numparams as locals outside numblock. (#633) (Ilya Bylich)
36
+
37
+ Bugs fixed:
38
+ * dedenter.rb: fixed over-dedenting of squiggly heredocs (#641) (Ilya Bylich)
39
+ * ruby27.y: added "arguments forwarding" (#625) (Ilya Bylich)
40
+ * ruby27.y: reject circular argument reference. (#622) (Ilya Bylich)
41
+ * ruby27.y: changed prefix of numparams to "_" (#620) (Ilya Bylich)
42
+
43
+ v2.6.5.0 (2019-10-03)
44
+ ---------------------
45
+
46
+ API modifications:
47
+ * Bump ruby versions to 2.4.9, 2.5.7 and 2.6.5. (#619) (Ilya Bylich)
48
+
49
+ Features implemented:
50
+ * lexer.rl: changed max numparam to `@9` (#617) (Ilya Bylich)
51
+ * lexer.rl: support comments before leading dot in 27 mode. (#613) (Ilya Bylich)
52
+
53
+ Bugs fixed:
54
+ * lexer.rl: emit tMETHREF as tDOT+tCOLON for rubies \< 27. (#614) (Ilya Bylich)
55
+
4
56
  v2.6.4.1 (2019-09-12)
5
57
  ---------------------
6
58
 
data/README.md CHANGED
@@ -234,7 +234,7 @@ Parser implements the MacRuby 0.12 and RubyMotion mid-2015 parsers precisely. Ho
234
234
 
235
235
  ## Known issues
236
236
 
237
- Adding support for the following Ruby MRI features in Parser would needlessly complicate it, and as they all are very specific and rarely occuring corner cases, this is not done.
237
+ Adding support for the following Ruby MRI features in Parser would needlessly complicate it, and as they all are very specific and rarely occurring corner cases, this is not done.
238
238
 
239
239
  Parser has been extensively tested; in particular, it parses almost entire [Rubygems][rg] corpus. For every issue, a breakdown of affected gems is offered.
240
240
 
@@ -269,6 +269,13 @@ follows 2.1 behavior.
269
269
 
270
270
  No known code is affected by this issue.
271
271
 
272
+ ### EOF characters after embedded documents before 2.7
273
+
274
+ Code like `"=begin\n""=end\0"` is invalid for all versions of Ruby before 2.7. Ruby 2.7 and later parses it
275
+ normally. Parser follows 2.7 behavior.
276
+
277
+ It is unknown whether any gems are affected by this issue.
278
+
272
279
  ## Contributors
273
280
 
274
281
  * [whitequark][]
@@ -602,18 +602,6 @@ Format:
602
602
  ~~~~~~~~~~~~~ expression
603
603
  ~~~
604
604
 
605
- ### Method reference operator
606
-
607
- Format:
608
-
609
- ~~~
610
- (meth-ref (self) :foo)
611
- "self.:foo"
612
- ^^ dot
613
- ^^^ selector
614
- ^^^^^^^^^ expression
615
- ~~~
616
-
617
605
  ### Multiple assignment
618
606
 
619
607
  #### Multiple left hand side
@@ -1118,22 +1106,41 @@ Format:
1118
1106
  s(:numblock,
1119
1107
  s(:send, nil, :proc), 3,
1120
1108
  s(:send,
1121
- s(:numparam, 1), :+,
1122
- s(:numparam, 3)))
1123
- "proc { @1 + @3 }"
1109
+ s(:lvar, :_1), :+,
1110
+ s(:lvar, :_3)))
1111
+ "proc { _1 + _3 }"
1124
1112
  ~ begin ~ end
1125
1113
  ~~~~~~~~~~~~~~~~ expression
1126
1114
  ~~~
1127
1115
 
1128
- ### Numbered parameter
1116
+ ## Forward arguments
1117
+
1118
+ ### Method definition accepting forwarding arguments
1119
+
1120
+ Ruby 2.7 introduced a feature called "arguments forwarding".
1121
+ When a method takes any arguments for forwarding them in the future
1122
+ the whole `args` node gets replaced with `forward-args` node.
1129
1123
 
1130
1124
  Format:
1131
1125
 
1132
1126
  ~~~
1133
- (numparam 10)
1134
- "@10"
1135
- ~~~ name
1136
- ~~~ expression
1127
+ (def :foo
1128
+ (forward-args) nil)
1129
+ "def foo(...); end"
1130
+ ~ end
1131
+ ~ begin
1132
+ ~~~~~ expression
1133
+ ~~~
1134
+
1135
+ ### Method call taking arguments of the currently forwarding method
1136
+
1137
+ Format:
1138
+
1139
+ ~~~
1140
+ (send nil :foo
1141
+ (forwarded-args))
1142
+ "foo(...)"
1143
+ ~~~ expression
1137
1144
  ~~~
1138
1145
 
1139
1146
  ## Send
@@ -1814,3 +1821,360 @@ Format:
1814
1821
  "__ENCODING__"
1815
1822
  ~~~~~~~~~~~~ expression
1816
1823
  ~~~
1824
+
1825
+ ## Pattern matching
1826
+
1827
+ ### Using `in` modifier
1828
+
1829
+ Format:
1830
+
1831
+ ~~~
1832
+ (in-match
1833
+ (int 1)
1834
+ (match-var :a))
1835
+ "1 in a"
1836
+ ~~ operator
1837
+ ~~~~~~ expression
1838
+ ~~~
1839
+
1840
+ ### Case with pattern matching
1841
+
1842
+ #### Without else
1843
+
1844
+ Format:
1845
+
1846
+ ~~~
1847
+ (case-match
1848
+ (str "str")
1849
+ (in-pattern
1850
+ (match-var :foo)
1851
+ (lvar :bar)) nil)
1852
+ "case "str"; in foo; bar; end"
1853
+ ~~~~ keyword ~~~ end
1854
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ expression
1855
+ ~~~
1856
+
1857
+ #### With else
1858
+
1859
+ Format:
1860
+
1861
+ ~~~
1862
+ (case-match,
1863
+ (str "str")
1864
+ (in-pattern
1865
+ (match-var :foo)
1866
+ (lvar :bar))
1867
+ (lvar :baz))
1868
+ "case "str"; in foo; bar; else; baz; end"
1869
+ ~~~~ keyword ~~~~ else ~~~ end
1870
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ expression
1871
+ ~~~
1872
+
1873
+ #### With empty else
1874
+
1875
+ Empty `else` differs from the missing (or _implicit_) `else` for pattern matching, since
1876
+ the latter one raises a `NoMatchingPattern` exception. Thus, we need a way to distinguish this
1877
+ two cases in the resulting AST.
1878
+
1879
+ Format:
1880
+
1881
+ ~~~
1882
+ (case-match,
1883
+ (str "str")
1884
+ (in-pattern
1885
+ (match-var :foo)
1886
+ (lvar :bar))
1887
+ (empty-else))
1888
+ "case "str"; in foo; bar; else; end"
1889
+ ~~~~ keyword ~~~~ else
1890
+ ~~~ end
1891
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ expression
1892
+ ~~~
1893
+
1894
+ ### In clause
1895
+
1896
+ Format:
1897
+
1898
+ ~~~
1899
+ (in-pattern
1900
+ (match-var :foo)
1901
+ (lvar :bar))
1902
+ "in foo then bar"
1903
+ ~~ keyword
1904
+ ~~~~ begin
1905
+ ~~~~~~~~~~~~~~~ expression
1906
+ ~~~
1907
+
1908
+ ### If guard
1909
+
1910
+ This guard runs after matching, so it's not an `if` modifier.
1911
+
1912
+ Format:
1913
+
1914
+ ~~~
1915
+ (in-pattern
1916
+ (match-var :foo)
1917
+ (if-guard
1918
+ (lvar :bar)) nil)
1919
+ "in foo if bar"
1920
+ ~~ keyword
1921
+ ~~~~~~ expression
1922
+ ~~~
1923
+
1924
+ ### Unless guard
1925
+
1926
+ This guard runs after matching, so it's not an `unless` modifier.
1927
+
1928
+ Format:
1929
+
1930
+ ~~~
1931
+ (in-pattern
1932
+ (match-var :foo)
1933
+ (unless-guard
1934
+ (lvar :bar)) nil)
1935
+ "in foo unless bar"
1936
+ ~~~~~~ keyword
1937
+ ~~~~~~~~~~ expression
1938
+ ~~~
1939
+
1940
+ ### Match variable
1941
+
1942
+ Format:
1943
+
1944
+ ~~~
1945
+ (match-var :foo)
1946
+ "in foo"
1947
+ ~~~ name
1948
+ ~~~ expression
1949
+ ~~~
1950
+
1951
+ ### Match rest
1952
+
1953
+ #### With name
1954
+
1955
+ Format:
1956
+
1957
+ ~~~
1958
+ (match-rest
1959
+ (match-var :foo))
1960
+ "in *foo"
1961
+ ~ operator
1962
+ ~~~~ expression
1963
+ ~~~
1964
+
1965
+ #### Without name
1966
+
1967
+ Format:
1968
+
1969
+ ~~~
1970
+ (match-rest)
1971
+ "in *"
1972
+ ~ operator
1973
+ ~ expression
1974
+ ~~~
1975
+
1976
+ ### Pin operator
1977
+
1978
+ Format:
1979
+
1980
+ ~~~
1981
+ (pin
1982
+ (lvar :foo))
1983
+ "in ^foo"
1984
+ ~ selector
1985
+ ~~~~ expression
1986
+ ~~~
1987
+
1988
+ ### Match alternative
1989
+
1990
+ Format:
1991
+
1992
+ ~~~
1993
+ (match-alt
1994
+ (pin
1995
+ (lvar :foo))
1996
+ (int 1))
1997
+ "in ^foo | 1"
1998
+ ~ operator
1999
+ ~~~~~~~~ expression
2000
+ ~~~
2001
+
2002
+ ### Match with alias
2003
+
2004
+ Format:
2005
+
2006
+ ~~~
2007
+ (match-as
2008
+ (int 1)
2009
+ (match-var :foo))
2010
+ "in 1 => foo"
2011
+ ~~ operator
2012
+ ~~~~~~~~ expression
2013
+ ~~~
2014
+
2015
+ ### Match using array pattern
2016
+
2017
+ #### Explicit
2018
+
2019
+ Format:
2020
+
2021
+ ~~~
2022
+ (array-pattern
2023
+ (pin
2024
+ (lvar :foo))
2025
+ (match-var :bar))
2026
+ "in [^foo, bar]"
2027
+ ~ begin ~ end
2028
+ ~~~~~~~~~~~ expression
2029
+ ~~~
2030
+
2031
+ #### Explicit with tail
2032
+
2033
+ Adding a trailing comma in the end works as `, *`
2034
+
2035
+ Format:
2036
+
2037
+ ~~~
2038
+ (array-pattern-with-tail
2039
+ (pin
2040
+ (lvar :foo))
2041
+ (match-var :bar))
2042
+ "in [^foo, bar,]"
2043
+ ~ begin ~ end
2044
+ ~~~~~~~~~~~~ expression
2045
+ ~~~
2046
+
2047
+ #### Implicit
2048
+
2049
+ Format:
2050
+
2051
+ ~~~
2052
+ (array-pattern
2053
+ (pin
2054
+ (lvar :foo))
2055
+ (match-var :bar))
2056
+ "in ^foo, bar"
2057
+ ~~~~~~~~~ expression
2058
+ ~~~
2059
+
2060
+ #### Implicit with tail
2061
+
2062
+ Format:
2063
+
2064
+ Adding a trailing comma in the end works as `, *`,
2065
+ so a single item match with comma gets interpreted as an array.
2066
+
2067
+ ~~~
2068
+ (array-pattern-with-tail
2069
+ (match-var :foo))
2070
+ "in foo,"
2071
+ ~~~ expression
2072
+ ~~~
2073
+
2074
+ ### Matching using hash pattern
2075
+
2076
+ #### Explicit
2077
+
2078
+ Format:
2079
+
2080
+ ~~~
2081
+ (hash-pattern
2082
+ (pair
2083
+ (sym :a)
2084
+ (int 10)))
2085
+ "in { a: 10 }"
2086
+ ~ begin ~ end
2087
+ ~~~~~~~~~ expression
2088
+ ~~~
2089
+
2090
+ #### Implicit
2091
+
2092
+ Format:
2093
+
2094
+ ~~~
2095
+ (hash-pattern
2096
+ (pair
2097
+ (sym :a)
2098
+ (int 10)))
2099
+ "in a: 10"
2100
+ ~~~~~ expression
2101
+ ~~~
2102
+
2103
+ #### Assignment using hash pattern
2104
+
2105
+ Format:
2106
+
2107
+ ~~~
2108
+ (hash-pattern
2109
+ (match-var :a))
2110
+ "in a:"
2111
+ ~ name (match-var)
2112
+ ~~ expression (match-var)
2113
+ ~~~
2114
+
2115
+ #### Nil hash pattern
2116
+
2117
+ Format:
2118
+ ~~~
2119
+ (hash-pattern
2120
+ (match-nil-pattern))
2121
+ "in **nil"
2122
+ ~~~~~ expression (match-nil-pattern)
2123
+ ~~~ name (match-nil-pattern)
2124
+ ~~~
2125
+
2126
+ ### Matching using const pattern
2127
+
2128
+ #### With array pattern
2129
+
2130
+ Format:
2131
+
2132
+ ~~~
2133
+ (const-pattern
2134
+ (const nil :X)
2135
+ (array-pattern
2136
+ (pin
2137
+ (lvar :foo))
2138
+ (match-var :bar)))
2139
+ "in X[^foo bar]"
2140
+ ~ begin (const-pattern)
2141
+ ~ end (const-pattern)
2142
+ ~~~~~~~~~~~ expression (const-pattern)
2143
+ ~ name (const-pattern.const)
2144
+ ~ expression (const-pattern.const)
2145
+ ~~~
2146
+
2147
+ #### With hash pattern
2148
+
2149
+ Format:
2150
+
2151
+ ~~~
2152
+ (const-pattern
2153
+ (const nil :X)
2154
+ (hash-pattern
2155
+ (match-var :foo)
2156
+ (match-var :bar)))
2157
+ "in X[foo:, bar:]"
2158
+ ~ begin (const-pattern)
2159
+ ~ end (const-pattern)
2160
+ ~~~~~~~~~~~~ expression (const-pattern)
2161
+ ~ name (const-pattern.const)
2162
+ ~ expression (const-pattern.const)
2163
+ ~~~
2164
+
2165
+ #### With array pattern without elements
2166
+
2167
+ Format:
2168
+
2169
+ ~~~
2170
+ (const-pattern
2171
+ (const nil :X)
2172
+ (array-pattern))
2173
+ "in X[]"
2174
+ ~ begin (const-pattern)
2175
+ ~ end (const-pattern)
2176
+ ~~ expression (const-pattern)
2177
+ ~ name (const-pattern.const)
2178
+ ~ expression (const-pattern.const)
2179
+ ~~ expression (const-pattern.array_pattern)
2180
+ ~~~