Skip to content

Commit 6207daf

Browse files
committed
Recreated clean version of @leonerd:package-name-version
@leonerd and @rabbiveesh deleted this branch, but these changes are really quite welcome (node tree was too flat with a package declaration --i.e. namespace-- not wrapping the statements that follow) so I've re-created just the relevant changes. ganezdragon#12
1 parent d4200ec commit 6207daf

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

grammar.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ module.exports = grammar({
219219
package_statement: $ => seq(
220220
'package',
221221
$.package_name,
222-
$.semi_colon
222+
optional(field('version', $.version)),
223+
choice(
224+
$.semi_colon,
225+
field('body', $.block)
226+
)
223227
),
224228

225229
ellipsis_statement: $ => seq(

test/corpus/package.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
=================================================
2+
Unit package statement
3+
=================================================
4+
5+
package The::Package;
6+
7+
---
8+
9+
(source_file
10+
(package_statement (package_name (identifier) (identifier)) (semi_colon))
11+
)
12+
13+
=================================================
14+
Unit package statement with version
15+
=================================================
16+
17+
package The::Package v1.23;
18+
19+
---
20+
21+
(source_file
22+
(package_statement (package_name (identifier) (identifier)) (version) (semi_colon))
23+
)
24+
25+
=================================================
26+
package block
27+
=================================================
28+
29+
package The::Package {
30+
...
31+
}
32+
33+
---
34+
35+
(source_file
36+
(package_statement (package_name (identifier) (identifier))
37+
(block (ellipsis_statement))
38+
)
39+
)
40+
41+
=================================================
42+
package block with version
43+
=================================================
44+
45+
package The::Package v4.56 {
46+
...
47+
}
48+
49+
---
50+
51+
(source_file
52+
(package_statement (package_name (identifier) (identifier)) (version)
53+
(block (ellipsis_statement))
54+
)
55+
)

0 commit comments

Comments
 (0)