add emptyline rule

This commit is contained in:
Dmitriy Pleshevskiy 2022-12-06 12:40:18 +03:00
parent e7421caac0
commit bbbb253d22
Signed by: pleshevskiy
GPG Key ID: 1B59187B161C0215
3 changed files with 33 additions and 38 deletions

View File

@ -8,20 +8,21 @@ module.exports = grammar({
word: ($) => $._word,
conflicts: ($) => [
[$._identifier],
[$.identifier],
[$.arrow],
[$._identifier],
[$._shape_block],
[$._shape_block_definition],
[$._style_attr_block],
[$._inner_style_attribute],
[$._emptyline],
],
rules: {
source_file: ($) => repeat($._definition),
_definition: ($) =>
choice(seq(spaces, $._eof), $._root_attribute, $.connection, $.shape),
choice($._emptyline, $._root_attribute, $.connection, $.shape),
connection: ($) =>
seq(
@ -64,9 +65,7 @@ module.exports = grammar({
spaces,
"{",
spaces,
repeat(
choice(seq(spaces, $._eof), seq($._shape_block_definition, $._end))
),
repeat(choice($._emptyline, seq($._shape_block_definition, $._end))),
optional(seq($._shape_block_definition, optional($._end))),
spaces,
"}"
@ -95,7 +94,7 @@ module.exports = grammar({
spaces,
"{",
spaces,
repeat(choice($._eof, seq($._inner_style_attribute, $._end))),
repeat(choice($._emptyline, seq($._inner_style_attribute, $._end))),
optional(seq($._inner_style_attribute, optional($._end))),
spaces,
"}"
@ -178,6 +177,7 @@ module.exports = grammar({
_word: ($) => /[\w\d]+/,
_emptyline: ($) => seq(spaces, $._eof),
_eof: ($) => choice("\n", "\0"),
_end: ($) => seq(spaces, choice(";", $._eof)),
},

View File

@ -13,20 +13,8 @@
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "STRING",
"value": " "
}
},
{
"type": "SYMBOL",
"name": "_eof"
}
]
"type": "SYMBOL",
"name": "_emptyline"
},
{
"type": "SYMBOL",
@ -298,20 +286,8 @@
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "STRING",
"value": " "
}
},
{
"type": "SYMBOL",
"name": "_eof"
}
]
"type": "SYMBOL",
"name": "_emptyline"
},
{
"type": "SEQ",
@ -497,7 +473,7 @@
"members": [
{
"type": "SYMBOL",
"name": "_eof"
"name": "_emptyline"
},
{
"type": "SEQ",
@ -997,6 +973,22 @@
"type": "PATTERN",
"value": "[\\w\\d]+"
},
"_emptyline": {
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "STRING",
"value": " "
}
},
{
"type": "SYMBOL",
"name": "_eof"
}
]
},
"_eof": {
"type": "CHOICE",
"members": [
@ -1038,15 +1030,15 @@
},
"extras": [],
"conflicts": [
[
"_identifier"
],
[
"identifier"
],
[
"arrow"
],
[
"_identifier"
],
[
"_shape_block"
],
@ -1058,6 +1050,9 @@
],
[
"_inner_style_attribute"
],
[
"_emptyline"
]
],
"precedences": [],

Binary file not shown.