Skip to content

Commit 5b731f2

Browse files
committed
fix: new #pragma & $ in function names
1 parent 9a9f5ba commit 5b731f2

File tree

8 files changed

+4582
-4349
lines changed

8 files changed

+4582
-4349
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
4+
## [Unreleased]
5+
6+
### Fixed
7+
- new types of #pragma
8+
- $ in the middle of function names
9+
310
## [1.1.3] - 2023-03-21
411
### Fixed
512
- $ in function and identifier names

grammar/func/grammar.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ module.exports = grammar({
3131
pragma_directive: $ => seq(
3232
'#pragma',
3333
repeat1(' '),
34-
field('key', choice('version', 'not-version')),
35-
repeat1(' '),
36-
field('value', $.version_identifier)
34+
choice(
35+
seq(
36+
field('key', choice('version', 'not-version')),
37+
repeat1(' '),
38+
field('value', $.version_identifier)
39+
),
40+
field('key', choice('allow-post-modification', 'compute-asm-ltr')),
41+
),
3742
),
3843

3944
global_var_declarations: $ => seq(

grammar/func/grammar/functions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
)
1515
),
1616

17-
function_name: $ => /(`.*`)|((\.|~)?(([$a-zA-Z_](\w|['?:])+)|([a-zA-Z])))/,
17+
function_name: $ => /(`.*`)|((\.|~)?(([$a-zA-Z_](\w|['?:$])+)|([a-zA-Z$])))/,
1818

1919
impure: $ => "impure",
2020
inline: $ => choice("inline", "inline_ref"),

grammar/func/src/grammar.json

+57-30
Original file line numberDiff line numberDiff line change
@@ -95,36 +95,63 @@
9595
}
9696
},
9797
{
98-
"type": "FIELD",
99-
"name": "key",
100-
"content": {
101-
"type": "CHOICE",
102-
"members": [
103-
{
104-
"type": "STRING",
105-
"value": "version"
106-
},
107-
{
108-
"type": "STRING",
109-
"value": "not-version"
98+
"type": "CHOICE",
99+
"members": [
100+
{
101+
"type": "SEQ",
102+
"members": [
103+
{
104+
"type": "FIELD",
105+
"name": "key",
106+
"content": {
107+
"type": "CHOICE",
108+
"members": [
109+
{
110+
"type": "STRING",
111+
"value": "version"
112+
},
113+
{
114+
"type": "STRING",
115+
"value": "not-version"
116+
}
117+
]
118+
}
119+
},
120+
{
121+
"type": "REPEAT1",
122+
"content": {
123+
"type": "STRING",
124+
"value": " "
125+
}
126+
},
127+
{
128+
"type": "FIELD",
129+
"name": "value",
130+
"content": {
131+
"type": "SYMBOL",
132+
"name": "version_identifier"
133+
}
134+
}
135+
]
136+
},
137+
{
138+
"type": "FIELD",
139+
"name": "key",
140+
"content": {
141+
"type": "CHOICE",
142+
"members": [
143+
{
144+
"type": "STRING",
145+
"value": "allow-post-modification"
146+
},
147+
{
148+
"type": "STRING",
149+
"value": "compute-asm-ltr"
150+
}
151+
]
110152
}
111-
]
112-
}
113-
},
114-
{
115-
"type": "REPEAT1",
116-
"content": {
117-
"type": "STRING",
118-
"value": " "
119-
}
120-
},
121-
{
122-
"type": "FIELD",
123-
"name": "value",
124-
"content": {
125-
"type": "SYMBOL",
126-
"name": "version_identifier"
127-
}
153+
}
154+
]
128155
}
129156
]
130157
},
@@ -1485,7 +1512,7 @@
14851512
},
14861513
"function_name": {
14871514
"type": "PATTERN",
1488-
"value": "(`.*`)|((\\.|~)?(([$a-zA-Z_](\\w|['?:])+)|([a-zA-Z])))"
1515+
"value": "(`.*`)|((\\.|~)?(([$a-zA-Z_](\\w|['?:$])+)|([a-zA-Z$])))"
14891516
},
14901517
"impure": {
14911518
"type": "STRING",

grammar/func/src/node-types.json

+17-1
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,14 @@
878878
"multiple": false,
879879
"required": true,
880880
"types": [
881+
{
882+
"type": "allow-post-modification",
883+
"named": false
884+
},
885+
{
886+
"type": "compute-asm-ltr",
887+
"named": false
888+
},
881889
{
882890
"type": "not-version",
883891
"named": false
@@ -890,7 +898,7 @@
890898
},
891899
"value": {
892900
"multiple": false,
893-
"required": true,
901+
"required": false,
894902
"types": [
895903
{
896904
"type": "version_identifier",
@@ -1508,6 +1516,10 @@
15081516
"type": "^>>=",
15091517
"named": false
15101518
},
1519+
{
1520+
"type": "allow-post-modification",
1521+
"named": false
1522+
},
15111523
{
15121524
"type": "asm",
15131525
"named": false
@@ -1524,6 +1536,10 @@
15241536
"type": "comment",
15251537
"named": true
15261538
},
1539+
{
1540+
"type": "compute-asm-ltr",
1541+
"named": false
1542+
},
15271543
{
15281544
"type": "const",
15291545
"named": false

0 commit comments

Comments
 (0)