Skip to content

Commit b160804

Browse files
authored
Add using Keyword to JavaScript (#1215)
`using` is a new Keyword in JavaScript. See [MDM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using) for more information.
1 parent 17e5911 commit b160804

File tree

6 files changed

+31
-4
lines changed

6 files changed

+31
-4
lines changed

lexers/embedded/javascript.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
<token type="KeywordDeclaration"/>
134134
<push state="slashstartsregex"/>
135135
</rule>
136-
<rule pattern="(abstract|async|await|boolean|byte|char|class|const|debugger|double|enum|export|extends|final|float|goto|implements|import|int|interface|long|native|package|private|protected|public|short|static|super|synchronized|throws|transient|volatile)\b">
136+
<rule pattern="(abstract|async|await|boolean|byte|char|class|const|debugger|double|enum|export|extends|final|float|goto|implements|import|int|interface|long|native|package|private|protected|public|short|static|super|synchronized|throws|transient|using|volatile)\b">
137137
<token type="KeywordReserved"/>
138138
</rule>
139139
<rule pattern="(true|false|null|NaN|Infinity|undefined)\b">

lexers/embedded/typescript.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226
<push state="slashstartsregex" />
227227
</rule>
228228
<rule
229-
pattern="(abstract|async|boolean|class|const|debugger|enum|export|extends|from|get|global|goto|implements|import|interface|namespace|package|private|protected|public|readonly|require|set|static|super|type)\b"
229+
pattern="(abstract|async|boolean|class|const|debugger|enum|export|extends|from|get|global|goto|implements|import|interface|namespace|package|private|protected|public|readonly|require|set|static|super|type|using)\b"
230230
>
231231
<token type="KeywordReserved" />
232232
</rule>

lexers/testdata/javascript.actual

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ const filePath = String.raw`C:\Development\profile\aboutme.html`;
44

55
let n = 0x21 + 1_000;
66
let n2 = 1e3;
7+
8+
using resource = new Resource();

lexers/testdata/javascript.expected

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,16 @@
5959
{"type":"Text","value":" "},
6060
{"type":"LiteralNumberFloat","value":"1e3"},
6161
{"type":"Punctuation","value":";"},
62+
{"type":"Text","value":"\n\n"},
63+
{"type":"KeywordReserved","value":"using"},
64+
{"type":"Text","value":" "},
65+
{"type":"NameOther","value":"resource"},
66+
{"type":"Text","value":" "},
67+
{"type":"Operator","value":"="},
68+
{"type":"Text","value":" "},
69+
{"type":"Keyword","value":"new"},
70+
{"type":"Text","value":" "},
71+
{"type":"NameOther","value":"Resource"},
72+
{"type":"Punctuation","value":"();"},
6273
{"type":"Text","value":"\n"}
6374
]

lexers/testdata/typescript.actual

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const moduleName = modules.map();
22

3+
using resource = new Resource();
4+
35
declare module "fs" {}
46
declare module "@custom/plugin" {}
57
declare module "../../compiler/types" {}
@@ -20,4 +22,4 @@ type FirstChar<K extends string> = K extends `${infer X}${infer _}`
2022
: never
2123
type SChar = FirstChar<"stuff">
2224

23-
export { TestComponent }
25+
export { TestComponent }

lexers/testdata/typescript.expected

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
{"type":"NameOther","value":"map"},
1111
{"type":"Punctuation","value":"();"},
1212
{"type":"Text","value":"\n\n"},
13+
{"type":"KeywordReserved","value":"using"},
14+
{"type":"Text","value":" "},
15+
{"type":"NameOther","value":"resource"},
16+
{"type":"Text","value":" "},
17+
{"type":"Operator","value":"="},
18+
{"type":"Text","value":" "},
19+
{"type":"Keyword","value":"new"},
20+
{"type":"Text","value":" "},
21+
{"type":"NameOther","value":"Resource"},
22+
{"type":"Punctuation","value":"();"},
23+
{"type":"Text","value":"\n\n"},
1324
{"type":"KeywordReserved","value":"declare"},
1425
{"type":"Text","value":" "},
1526
{"type":"KeywordReserved","value":"module"},
@@ -188,5 +199,6 @@
188199
{"type":"Text","value":" "},
189200
{"type":"NameOther","value":"TestComponent"},
190201
{"type":"Text","value":" "},
191-
{"type":"Punctuation","value":"}"}
202+
{"type":"Punctuation","value":"}"},
203+
{"type":"Text","value":"\n"}
192204
]

0 commit comments

Comments
 (0)