Skip to content

Commit

Permalink
Exposes union_type directly instead of hiding it behind a type_list. …
Browse files Browse the repository at this point in the history
…This also reduces the state count by breaking up large definitions
  • Loading branch information
cfroystad committed Jan 31, 2022
1 parent 57f8554 commit 0ce1342
Show file tree
Hide file tree
Showing 8 changed files with 78,640 additions and 89,161 deletions.
8 changes: 6 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,17 @@ module.exports = grammar({
optional($._return_type)
),

arrow_function: $ => seq(
_arrow_function_header: $ => seq(
optional(field('attributes', $.attribute_list)),
optional($.static_modifier),
keyword('fn'),
optional(field('reference_modifier', $.reference_modifier)),
field('parameters', $.formal_parameters),
optional($._return_type),
),

arrow_function: $ => seq(
$._arrow_function_header,
'=>',
field('body', $._expression)
),
Expand Down Expand Up @@ -469,7 +473,7 @@ module.exports = grammar({
field('name', $.variable_name)
),

_type: $ => alias($.union_type, $.type_list),
_type: $ => $.union_type,

_types: $ => choice(
$.optional_type,
Expand Down
20 changes: 12 additions & 8 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,7 @@
}
]
},
"arrow_function": {
"_arrow_function_header": {
"type": "SEQ",
"members": [
{
Expand Down Expand Up @@ -2144,6 +2144,15 @@
"type": "BLANK"
}
]
}
]
},
"arrow_function": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_arrow_function_header"
},
{
"type": "STRING",
Expand Down Expand Up @@ -2457,13 +2466,8 @@
]
},
"_type": {
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "union_type"
},
"named": true,
"value": "type_list"
"type": "SYMBOL",
"name": "union_type"
},
"_types": {
"type": "CHOICE",
Expand Down
39 changes: 27 additions & 12 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
"named": true,
"subtypes": [
{
"type": "type_list",
"type": "union_type",
"named": true
}
]
Expand Down Expand Up @@ -4306,32 +4306,47 @@
{
"type": "named_type",
"named": true
},
}
]
}
},
{
"type": "unary_op_expression",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "optional_type",
"type": "_expression",
"named": true
},
{
"type": "primitive_type",
"type": "integer",
"named": true
}
]
}
},
{
"type": "unary_op_expression",
"type": "union_type",
"named": true,
"fields": {},
"children": {
"multiple": false,
"multiple": true,
"required": true,
"types": [
{
"type": "_expression",
"type": "named_type",
"named": true
},
{
"type": "integer",
"type": "optional_type",
"named": true
},
{
"type": "primitive_type",
"named": true
}
]
Expand Down Expand Up @@ -5035,11 +5050,11 @@
},
{
"type": "float",
"named": true
"named": false
},
{
"type": "float",
"named": false
"named": true
},
{
"type": "fn",
Expand Down Expand Up @@ -5135,11 +5150,11 @@
},
{
"type": "null",
"named": true
"named": false
},
{
"type": "null",
"named": false
"named": true
},
{
"type": "or",
Expand Down
Loading

0 comments on commit 0ce1342

Please sign in to comment.