support empty lines
This commit is contained in:
parent
78fe65f822
commit
811520dfd4
5 changed files with 54 additions and 18 deletions
|
@ -1,3 +1,6 @@
|
|||
foo.shape: 'oval'
|
||||
foo.bar.baz.shape: oval
|
||||
|
||||
|
||||
foo
|
||||
|
||||
bar : Foo Bar; baz
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@ module.exports = grammar({
|
|||
rules: {
|
||||
source_file: ($) => repeat($._definition),
|
||||
|
||||
_definition: ($) => choice($._root_attribute, $.connection, $.shape),
|
||||
_definition: ($) =>
|
||||
choice($._end, $._root_attribute, $.connection, $.shape),
|
||||
|
||||
connection: ($) =>
|
||||
seq(
|
||||
|
@ -108,8 +109,6 @@ module.exports = grammar({
|
|||
|
||||
_colon: ($) => seq(repeat(" "), ":", repeat(" ")),
|
||||
|
||||
_dash: ($) => token.immediate("-"),
|
||||
|
||||
_word: ($) => /[\w\d]+/,
|
||||
|
||||
arrow: ($) =>
|
||||
|
@ -122,6 +121,8 @@ module.exports = grammar({
|
|||
)
|
||||
),
|
||||
|
||||
_dash: ($) => token.immediate("-"),
|
||||
|
||||
_unquoted_string: ($) => token.immediate(/[^'"`\n;{]+/),
|
||||
|
||||
string: ($) =>
|
||||
|
@ -132,7 +133,7 @@ module.exports = grammar({
|
|||
),
|
||||
|
||||
_eof: ($) => choice("\n", "\0"),
|
||||
_end: ($) => choice(";", $._eof),
|
||||
_end: ($) => seq(repeat(" "), choice(";", $._eof)),
|
||||
|
||||
dot: ($) => ".",
|
||||
},
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
"_definition": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_end"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_root_attribute"
|
||||
|
@ -520,13 +524,6 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"_dash": {
|
||||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "STRING",
|
||||
"value": "-"
|
||||
}
|
||||
},
|
||||
"_word": {
|
||||
"type": "PATTERN",
|
||||
"value": "[\\w\\d]+"
|
||||
|
@ -608,6 +605,13 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"_dash": {
|
||||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "STRING",
|
||||
"value": "-"
|
||||
}
|
||||
},
|
||||
"_unquoted_string": {
|
||||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
|
@ -703,6 +707,16 @@
|
|||
]
|
||||
},
|
||||
"_end": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "STRING",
|
||||
"value": " "
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
|
@ -714,6 +728,8 @@
|
|||
"name": "_eof"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"dot": {
|
||||
"type": "STRING",
|
||||
|
|
BIN
src/parser.c
BIN
src/parser.c
Binary file not shown.
|
@ -67,3 +67,19 @@ a: Foo Bar; b: Biz Baz
|
|||
(shape (identifier) (label))
|
||||
)
|
||||
|
||||
================================================================================
|
||||
It should skip white spaces
|
||||
================================================================================
|
||||
|
||||
foo
|
||||
|
||||
bar : Foo Bar; baz
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(source_file
|
||||
(shape (identifier))
|
||||
(shape (identifier) (label))
|
||||
(shape (identifier))
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue