Skip to content

Commit 270c6fa

Browse files
authored
Merge pull request #74 from onbjerg/onbjerg/fix-global-using-directive
fix: support global using directives
2 parents d38dcd0 + de9dcd9 commit 270c6fa

File tree

6 files changed

+56908
-52959
lines changed

6 files changed

+56908
-52959
lines changed

grammar.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ module.exports = grammar({
161161
$.constant_variable_declaration,
162162
$.user_defined_type_definition,
163163
$.event_definition,
164+
$.using_directive,
164165
),
165166

166167
user_defined_type_definition: $ => seq(
@@ -294,14 +295,45 @@ module.exports = grammar({
294295
optional(field("name", $.identifier)),
295296
),
296297

298+
user_definable_operator: $ => choice(
299+
"&",
300+
"~",
301+
"|",
302+
"^",
303+
"+",
304+
"-",
305+
"/",
306+
"%",
307+
"*",
308+
"-",
309+
"==",
310+
">",
311+
">=",
312+
"<",
313+
"<=",
314+
"!=",
315+
),
316+
297317
using_directive: $ => seq(
298318
'using',
299-
alias($.user_defined_type, $.type_alias),
319+
choice(
320+
alias($.user_defined_type, $.type_alias),
321+
seq('{', commaSep1($.using_alias), '}')
322+
),
300323
'for',
301324
field("source", choice($.any_source_type, $.type_name)),
325+
optional('global'),
302326
$._semicolon
303327
),
304328

329+
using_alias: $ => seq(
330+
$.user_defined_type,
331+
optional(seq(
332+
"as",
333+
$.user_definable_operator,
334+
))
335+
),
336+
305337
any_source_type: $ => '*',
306338

307339
// -- [ Statements ] --

src/grammar.json

Lines changed: 177 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)