add emptyline rule
This commit is contained in:
parent
e7421caac0
commit
bbbb253d22
3 changed files with 33 additions and 38 deletions
12
grammar.js
12
grammar.js
|
@ -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)),
|
||||
},
|
||||
|
|
|
@ -12,21 +12,9 @@
|
|||
"_definition": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "STRING",
|
||||
"value": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_eof"
|
||||
}
|
||||
]
|
||||
"name": "_emptyline"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
@ -297,21 +285,9 @@
|
|||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "STRING",
|
||||
"value": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_eof"
|
||||
}
|
||||
]
|
||||
"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": [],
|
||||
|
|
BIN
src/parser.c
BIN
src/parser.c
Binary file not shown.
Loading…
Reference in a new issue