Add record types
This commit is contained in:
parent
506fab8896
commit
dd0af53fa0
5 changed files with 970 additions and 736 deletions
19
grammar.js
19
grammar.js
|
|
@ -244,10 +244,23 @@ module.exports = grammar({
|
|||
|
||||
_type: ($) => choice(
|
||||
$.type_alias,
|
||||
$.record_type,
|
||||
),
|
||||
|
||||
type_alias: ($) => $.identifier,
|
||||
|
||||
record_type: ($) => seq(
|
||||
"{",
|
||||
sepBy(",", $._typed_field),
|
||||
"}",
|
||||
),
|
||||
|
||||
_typed_field: ($) => seq(
|
||||
field("name", $.identifier),
|
||||
":",
|
||||
field("type", $.identifier),
|
||||
),
|
||||
|
||||
function_declaration: ($) => seq(
|
||||
"function",
|
||||
$._function_declaration_common,
|
||||
|
|
@ -271,12 +284,6 @@ module.exports = grammar({
|
|||
")",
|
||||
),
|
||||
|
||||
_typed_field: ($) => seq(
|
||||
field("name", $.identifier),
|
||||
":",
|
||||
field("type", $.identifier),
|
||||
),
|
||||
|
||||
variable_declaration: ($) => seq(
|
||||
"var",
|
||||
field("name", $.identifier),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue