parser 2.6.4.1 → 2.7.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +16 -10
- data/CHANGELOG.md +134 -0
- data/README.md +8 -1
- data/doc/AST_FORMAT.md +384 -20
- data/lib/parser.rb +3 -1
- data/lib/parser/ast/processor.rb +19 -0
- data/lib/parser/base.rb +19 -0
- data/lib/parser/builders/default.rb +250 -12
- data/lib/parser/context.rb +4 -0
- data/lib/parser/current.rb +7 -7
- data/lib/parser/current_arg_stack.rb +43 -0
- data/lib/parser/lexer.rl +116 -83
- data/lib/parser/lexer/dedenter.rb +52 -49
- data/lib/parser/macruby.y +1 -1
- data/lib/parser/{lexer/max_numparam_stack.rb → max_numparam_stack.rb} +10 -4
- data/lib/parser/messages.rb +35 -29
- data/lib/parser/meta.rb +7 -2
- data/lib/parser/ruby18.y +1 -1
- data/lib/parser/ruby19.y +1 -1
- data/lib/parser/ruby20.y +1 -1
- data/lib/parser/ruby21.y +1 -1
- data/lib/parser/ruby22.y +1 -1
- data/lib/parser/ruby23.y +1 -1
- data/lib/parser/ruby24.y +1 -1
- data/lib/parser/ruby25.y +1 -1
- data/lib/parser/ruby26.y +1 -1
- data/lib/parser/ruby27.y +496 -36
- data/lib/parser/rubymotion.y +1 -1
- data/lib/parser/source/tree_rewriter.rb +1 -1
- data/lib/parser/source/tree_rewriter/action.rb +2 -2
- data/lib/parser/static_environment.rb +10 -0
- data/lib/parser/variables_stack.rb +32 -0
- data/lib/parser/version.rb +1 -1
- data/parser.gemspec +7 -0
- data/test/helper.rb +1 -0
- data/test/parse_helper.rb +3 -0
- data/test/test_lexer.rb +18 -69
- data/test/test_parser.rb +1875 -111
- data/test/test_source_comment_associator.rb +20 -20
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2801cd6adbcd161d1a3b643dca79b9a9f7ff13210439bf632fcc22072837dffa
|
4
|
+
data.tar.gz: 20a0402b20903555a7cc29507205f7bf7176b26dfe039df79bf17fd503ed951e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b254886d186ac704cb8a6dcc6bfdce7d2f9f079ce83edb456646a0ec04336a2893c140f1b525e8cea89f34c52bf01c1e6849dc8ce80d9f4f3fdb0af072e15ac2
|
7
|
+
data.tar.gz: 627b678f07bf6ad130235f3ab1440d563905cf671e0618f2cb3b549e0f34dc341e70f5659580d731259d8caa97fd3d221868b966b5df5188c5c985db836ecc2a
|
data/.travis.yml
CHANGED
@@ -11,14 +11,17 @@ matrix:
|
|
11
11
|
- name: 2.3.8 / Parser tests
|
12
12
|
rvm: 2.3.8
|
13
13
|
script: bundle exec rake test_cov
|
14
|
-
- name: 2.4.
|
15
|
-
rvm: 2.4.
|
14
|
+
- name: 2.4.9 / Parser tests
|
15
|
+
rvm: 2.4.9
|
16
16
|
script: bundle exec rake test_cov
|
17
|
-
- name: 2.5.
|
18
|
-
rvm: 2.5.
|
17
|
+
- name: 2.5.7 / Parser tests
|
18
|
+
rvm: 2.5.7
|
19
19
|
script: bundle exec rake test_cov
|
20
|
-
- name: 2.6.
|
21
|
-
rvm: 2.6.
|
20
|
+
- name: 2.6.5 / Parser tests
|
21
|
+
rvm: 2.6.5
|
22
|
+
script: bundle exec rake test_cov
|
23
|
+
- name: 2.7.0 / Parser tests
|
24
|
+
rvm: 2.7.0
|
22
25
|
script: bundle exec rake test_cov
|
23
26
|
- name: ruby-head / Parser tests
|
24
27
|
rvm: ruby-head
|
@@ -29,11 +32,14 @@ matrix:
|
|
29
32
|
- name: rbx-2 / Parser tests
|
30
33
|
rvm: rbx-2
|
31
34
|
script: bundle exec rake test_cov
|
32
|
-
- name: 2.5.
|
33
|
-
rvm: 2.5.
|
35
|
+
- name: 2.5.7 / Rubocop tests
|
36
|
+
rvm: 2.5.7
|
37
|
+
script: ./ci/run_rubocop_specs
|
38
|
+
- name: 2.6.5 / Rubocop tests
|
39
|
+
rvm: 2.6.5
|
34
40
|
script: ./ci/run_rubocop_specs
|
35
|
-
- name: 2.
|
36
|
-
rvm: 2.
|
41
|
+
- name: 2.7.0 / Rubocop tests
|
42
|
+
rvm: 2.7.0
|
37
43
|
script: ./ci/run_rubocop_specs
|
38
44
|
allow_failures:
|
39
45
|
- rvm: ruby-head
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,140 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
v2.7.0.2 (2020-01-08)
|
5
|
+
---------------------
|
6
|
+
|
7
|
+
Bugs fixed:
|
8
|
+
* lexer.rl: fix paren_nest for curly braces (#646) (Ilya Bylich)
|
9
|
+
|
10
|
+
v2.7.0.1 (2019-12-30)
|
11
|
+
---------------------
|
12
|
+
|
13
|
+
Bugs fixed:
|
14
|
+
* dedenter.rb: prevent `ArgumentError` when processing binary en… (#642) (Koichi ITO)
|
15
|
+
|
16
|
+
v2.7.0.0 (2019-12-26)
|
17
|
+
---------------------
|
18
|
+
|
19
|
+
API modifications:
|
20
|
+
* README.md: documented compatibility issue with EOF chars after… (#637) (Ilya Bylich)
|
21
|
+
* ruby27.y: refactor logic around 'circular argument reference'(#628) (Ilya Bylich)
|
22
|
+
|
23
|
+
Features implemented:
|
24
|
+
* ruby27.y: added pattern matching (#574) (Ilya Bylich)
|
25
|
+
* lexer.rl: parse embedded ivars/cvars starting with digit as str (#639) (Ilya Bylich)
|
26
|
+
* lexer.rl: warn on `...` at EOL. (#636) (Ilya Bylich)
|
27
|
+
* ruby27.y: removed opt_block_args_tail: tOROP rule. (#635) (Ilya Bylich)
|
28
|
+
* ruby27.y: reverted method reference operator (added in #634) (Ilya Bylich)
|
29
|
+
* ruby27.y: treat numparams as locals outside numblock. (#633) (Ilya Bylich)
|
30
|
+
|
31
|
+
Bugs fixed:
|
32
|
+
* dedenter.rb: fixed over-dedenting of squiggly heredocs (#641) (Ilya Bylich)
|
33
|
+
* ruby27.y: added "arguments forwarding" (#625) (Ilya Bylich)
|
34
|
+
* ruby27.y: reject circular argument reference. (#622) (Ilya Bylich)
|
35
|
+
* ruby27.y: changed prefix of numparams to "_" (#620) (Ilya Bylich)
|
36
|
+
|
37
|
+
v2.6.5.0 (2019-10-03)
|
38
|
+
---------------------
|
39
|
+
|
40
|
+
API modifications:
|
41
|
+
* Bump ruby versions to 2.4.9, 2.5.7 and 2.6.5. (#619) (Ilya Bylich)
|
42
|
+
|
43
|
+
Features implemented:
|
44
|
+
* lexer.rl: changed max numparam to `@9` (#617) (Ilya Bylich)
|
45
|
+
* lexer.rl: support comments before leading dot in 27 mode. (#613) (Ilya Bylich)
|
46
|
+
|
47
|
+
Bugs fixed:
|
48
|
+
* lexer.rl: emit tMETHREF as tDOT+tCOLON for rubies \< 27. (#614) (Ilya Bylich)
|
49
|
+
|
50
|
+
v2.6.4.1 (2019-09-12)
|
51
|
+
---------------------
|
52
|
+
|
53
|
+
Bugs fixed:
|
54
|
+
* lexer.rl: fix parsing of 'm a + b do end' (#605) (Ilya Bylich)
|
55
|
+
|
56
|
+
v2.6.4.0 (2019-08-30)
|
57
|
+
---------------------
|
58
|
+
|
59
|
+
API modifications:
|
60
|
+
* Added specs for heredocs with mixed encoding. (#581) (Ilya Bylich)
|
61
|
+
|
62
|
+
Features implemented:
|
63
|
+
* ruby27.y: Revert "pipeline operator" (#601) (Koichi ITO)
|
64
|
+
* ruby27.y: Fix parsing of mutiple assignment with rescue modifier (#600) (Koichi ITO)
|
65
|
+
* ruby27.y: hoisted out f_rest_marg. (#594) (Ilya Bylich)
|
66
|
+
* ruby27.y: added pipeline operator. (#592) (Ilya Bylich)
|
67
|
+
* ruby27.y: reject safe navigator in LHS of mass-assignment. (#586) (Ilya Bylich)
|
68
|
+
* lexer.rl: reject whitespaces in meta and control chars. (#585) (Ilya Bylich)
|
69
|
+
* lexer.rl: Reject numparams as symbol literals. (#582) (Ilya Bylich)
|
70
|
+
* ruby27.y: Added numbered parameters support. (#565) (Ilya Bylich)
|
71
|
+
* lexer.rl: Reject \n and \r in heredoc identifiers starting from 2.7. (#575) (Ilya Bylich)
|
72
|
+
|
73
|
+
Bugs fixed:
|
74
|
+
* ruby-parse: print empty string when --emit-json and empty input are given. (#590) (Ilya Bylich)
|
75
|
+
* AST_FORMAT: fixed documentation of the string with interpolation. (#589) (Ilya Bylich)
|
76
|
+
* builder.rb, processor.rb: Changed format of the procarg0 node. (#587) (Ilya Bylich)
|
77
|
+
|
78
|
+
v2.6.3.0 (2019-04-28)
|
79
|
+
---------------------
|
80
|
+
|
81
|
+
Features implemented:
|
82
|
+
* ruby27.y: Added beginless ranges support. (#570) (Ilya Bylich)
|
83
|
+
|
84
|
+
v2.6.2.1 (2019-04-05)
|
85
|
+
---------------------
|
86
|
+
|
87
|
+
API modifications:
|
88
|
+
* Bump 2.4 branch to 2.4.6. (#569) (Ilya Bylich)
|
89
|
+
* Lexer should know about current parsing context. (#566) (Ilya Bylich)
|
90
|
+
|
91
|
+
v2.6.2.0 (2019-03-21)
|
92
|
+
---------------------
|
93
|
+
|
94
|
+
API modifications:
|
95
|
+
* Bump ruby versions to 2.5.5 and 2.6.2. (#563) (Ilya Bylich)
|
96
|
+
* Bump Ruby version to 2.6.1. (#554) (Ilya Bylich)
|
97
|
+
|
98
|
+
Features implemented:
|
99
|
+
* ruby27.y: dsym should be treated as string. (#560) (Ilya Bylich)
|
100
|
+
* ruby27.y: Refactored symbol rules. (#557) (Ilya Bylich)
|
101
|
+
* ruby27.y: Added method reference operator. (#556) (Ilya Bylich)
|
102
|
+
* ruby27.y: branch parser. (#546) (Ilya Bylich)
|
103
|
+
|
104
|
+
v2.6.0.0 (2019-01-16)
|
105
|
+
---------------------
|
106
|
+
|
107
|
+
API modifications:
|
108
|
+
* 2.6.0 was released, unmark is as -dev. (#538) (Ilya Bylich)
|
109
|
+
|
110
|
+
Bugs fixed:
|
111
|
+
* Fix parsing of "\\\n" escaped sequences in various literals. (#539) (Ilya Bylich)
|
112
|
+
|
113
|
+
v2.5.3.0 (2018-10-29)
|
114
|
+
---------------------
|
115
|
+
|
116
|
+
Bugs fixed:
|
117
|
+
* lexer.rl: Fix parsing of 'm :key => m do; m() do end; end'. (#526) (Ilya Bylich)
|
118
|
+
* lexer.rl: Fix parsing of ambiguous 1re. (#523) (Ilya Bylich)
|
119
|
+
|
120
|
+
v2.5.1.2 (2018-07-10)
|
121
|
+
---------------------
|
122
|
+
|
123
|
+
Bugs fixed:
|
124
|
+
* lexer.rl: Partially revert 5ba072d and properly handle 'm = -> *args do end'. (Ilya Bylich)
|
125
|
+
|
126
|
+
v2.5.1.1 (2018-07-10)
|
127
|
+
---------------------
|
128
|
+
|
129
|
+
Features implemented:
|
130
|
+
* ruby26.y: Endless ranges support. (Ilya Bylich)
|
131
|
+
|
132
|
+
Bugs fixed:
|
133
|
+
* lexer.rl: Fix parsing of 'm = -> *args do end'. (Ilya Bylich)
|
134
|
+
* AST::Processor: Properly recurse into "kwsplat" nodes (Nelson Elhage)
|
135
|
+
* ruby24, ruby25, ruby26: Fix cmdargs after command_args followed by tLBRACE_ARG. This commit tracks upstream commit ruby/ruby@f168dbd. (Ilya Bylich)
|
136
|
+
* lexer.rl: Fix parsing of `let (:a) { m do; end }`. (Ilya Bylich)
|
137
|
+
|
4
138
|
v2.5.1.0 (2018-04-12)
|
5
139
|
---------------------
|
6
140
|
|
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
|
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][]
|
data/doc/AST_FORMAT.md
CHANGED
@@ -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(:
|
1122
|
-
s(:
|
1123
|
-
"proc {
|
1109
|
+
s(:lvar, :_1), :+,
|
1110
|
+
s(:lvar, :_3)))
|
1111
|
+
"proc { _1 + _3 }"
|
1124
1112
|
~ begin ~ end
|
1125
1113
|
~~~~~~~~~~~~~~~~ expression
|
1126
1114
|
~~~
|
1127
1115
|
|
1128
|
-
|
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
|
-
(
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
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
|
+
~~~
|