grammar: some cleanup

This commit is contained in:
Dmitriy Pleshevskiy 2023-06-21 23:52:40 +03:00
parent 1395b25364
commit 731be00903
Signed by: pleshevskiy
GPG key ID: 79C4487B44403985
5 changed files with 56 additions and 74 deletions

View file

@ -95,10 +95,8 @@ module.exports = grammar({
seq( seq(
$._connection_path, $._connection_path,
repeat1(seq($.arrow, $._connection_path)), repeat1(seq($.arrow, $._connection_path)),
seq( optional(seq($._colon, optional($.label))),
optional(seq($._colon, optional($.label))), optional(seq(alias($._connection_block, $.block)))
optional(seq(alias($._connection_block, $.block)))
)
), ),
_connection_path: ($) => _connection_path: ($) =>
@ -370,13 +368,13 @@ module.exports = grammar({
attr_value_list: mkList(($) => $.attr_value), attr_value_list: mkList(($) => $.attr_value),
attr_value: ($) => attr_value: ($) =>
seq(choice($.boolean, $.integer, $.float, $.string, $._unquoted_string)), choice($.boolean, $.integer, $.float, $.string, $._unquoted_string),
// -------------------------------------------- // --------------------------------------------
_dash: ($) => token.immediate("-"), _dash: ($) => token.immediate("-"),
_colon: ($) => seq(":"), _colon: ($) => token(":"),
arrow: ($) => token(prec(PREC.ARROW, choice(/-+>/, /--+/, /<-+/, /<-+>/))), arrow: ($) => token(prec(PREC.ARROW, choice(/-+>/, /--+/, /<-+/, /<-+>/))),

View file

@ -89,58 +89,53 @@
} }
}, },
{ {
"type": "SEQ", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "CHOICE", "type": "SEQ",
"members": [ "members": [
{ {
"type": "SEQ", "type": "SYMBOL",
"name": "_colon"
},
{
"type": "CHOICE",
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_colon" "name": "label"
}, },
{ {
"type": "CHOICE", "type": "BLANK"
"members": [
{
"type": "SYMBOL",
"name": "label"
},
{
"type": "BLANK"
}
]
} }
] ]
},
{
"type": "BLANK"
} }
] ]
}, },
{ {
"type": "CHOICE", "type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [ "members": [
{ {
"type": "SEQ", "type": "ALIAS",
"members": [ "content": {
{ "type": "SYMBOL",
"type": "ALIAS", "name": "_connection_block"
"content": { },
"type": "SYMBOL", "named": true,
"name": "_connection_block" "value": "block"
},
"named": true,
"value": "block"
}
]
},
{
"type": "BLANK"
} }
] ]
},
{
"type": "BLANK"
} }
] ]
} }
@ -1976,32 +1971,27 @@
] ]
}, },
"attr_value": { "attr_value": {
"type": "SEQ", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "CHOICE", "type": "SYMBOL",
"members": [ "name": "boolean"
{ },
"type": "SYMBOL", {
"name": "boolean" "type": "SYMBOL",
}, "name": "integer"
{ },
"type": "SYMBOL", {
"name": "integer" "type": "SYMBOL",
}, "name": "float"
{ },
"type": "SYMBOL", {
"name": "float" "type": "SYMBOL",
}, "name": "string"
{ },
"type": "SYMBOL", {
"name": "string" "type": "SYMBOL",
}, "name": "_unquoted_string"
{
"type": "SYMBOL",
"name": "_unquoted_string"
}
]
} }
] ]
}, },
@ -2013,13 +2003,11 @@
} }
}, },
"_colon": { "_colon": {
"type": "SEQ", "type": "TOKEN",
"members": [ "content": {
{ "type": "STRING",
"type": "STRING", "value": ":"
"value": ":" }
}
]
}, },
"arrow": { "arrow": {
"type": "TOKEN", "type": "TOKEN",

View file

@ -515,10 +515,6 @@
"type": "3d", "type": "3d",
"named": false "named": false
}, },
{
"type": ":",
"named": false
},
{ {
"type": ";", "type": ";",
"named": false "named": false

Binary file not shown.

Binary file not shown.