Add type declarations
For now, simplified to type aliases only.
This commit is contained in:
parent
e898312c95
commit
506fab8896
5 changed files with 2004 additions and 1701 deletions
14
grammar.js
14
grammar.js
|
|
@ -228,12 +228,26 @@ module.exports = grammar({
|
|||
|
||||
_declaration_chunk: ($) => prec.left(
|
||||
choice(
|
||||
repeat1($.type_declaration),
|
||||
repeat1(choice($.function_declaration, $.primitive_declaration)),
|
||||
$.variable_declaration,
|
||||
$.import_declaration,
|
||||
),
|
||||
),
|
||||
|
||||
type_declaration: ($) => seq(
|
||||
"type",
|
||||
field("name", $.identifier),
|
||||
"=",
|
||||
field("value", $._type)
|
||||
),
|
||||
|
||||
_type: ($) => choice(
|
||||
$.type_alias,
|
||||
),
|
||||
|
||||
type_alias: ($) => $.identifier,
|
||||
|
||||
function_declaration: ($) => seq(
|
||||
"function",
|
||||
$._function_declaration_common,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue