fix unquoted strings and identifiers
This commit is contained in:
parent
6ec0bb5c59
commit
612b7fb871
6 changed files with 21 additions and 5 deletions
|
@ -116,7 +116,12 @@ module.exports = grammar({
|
||||||
shape_key: ($) => choice($.string, seq($._identifier, optional($._dash))),
|
shape_key: ($) => choice($.string, seq($._identifier, optional($._dash))),
|
||||||
|
|
||||||
_identifier: ($) =>
|
_identifier: ($) =>
|
||||||
token(prec(PREC.IDENTIFIER, /\-?([\w\d]+|([\w\d]+( +|\-)[\w\d]+)+)/)),
|
token(
|
||||||
|
prec(
|
||||||
|
PREC.IDENTIFIER,
|
||||||
|
/\-?([\w\d]+([\w\d`'"]+)?|([\w\d]+([\w\d `'"]+)?( +|\-)[\w\d]+([\w\d `'"]+)?)+)/
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
|
|
||||||
|
@ -255,7 +260,7 @@ module.exports = grammar({
|
||||||
dot: ($) => token("."),
|
dot: ($) => token("."),
|
||||||
|
|
||||||
_unquoted_string: ($) =>
|
_unquoted_string: ($) =>
|
||||||
token(prec(PREC.UNQUOTED_STRING, /[\w\-?!]([^'"`\n;{}]*[\w\-?!])?/)),
|
token(prec(PREC.UNQUOTED_STRING, /[^'"`\n\s;{}]([^\n;{}]*[^\n\s;{}])?/)),
|
||||||
|
|
||||||
string: ($) =>
|
string: ($) =>
|
||||||
choice(
|
choice(
|
||||||
|
|
|
@ -502,7 +502,7 @@
|
||||||
"value": 0,
|
"value": 0,
|
||||||
"content": {
|
"content": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "\\-?([\\w\\d]+|([\\w\\d]+( +|\\-)[\\w\\d]+)+)"
|
"value": "\\-?([\\w\\d]+([\\w\\d`'\"]+)?|([\\w\\d]+([\\w\\d `'\"]+)?( +|\\-)[\\w\\d]+([\\w\\d `'\"]+)?)+)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1103,7 +1103,7 @@
|
||||||
"value": 0,
|
"value": 0,
|
||||||
"content": {
|
"content": {
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "[\\w\\-?!]([^'\"`\\n;{}]*[\\w\\-?!])?"
|
"value": "[^'\"`\\n\\s;{}]([^\\n;{}]*[^\\n\\s;{}])?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
BIN
src/parser.c
BIN
src/parser.c
Binary file not shown.
|
@ -6,7 +6,7 @@ direction: value
|
||||||
shape: oval
|
shape: oval
|
||||||
label: ten
|
label: ten
|
||||||
constraint: utehu
|
constraint: utehu
|
||||||
icon: huell
|
icon: ./test.svg
|
||||||
opacity: 1
|
opacity: 1
|
||||||
fill: red
|
fill: red
|
||||||
stroke: red
|
stroke: red
|
||||||
|
@ -392,3 +392,4 @@ foo -> bar: {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,22 @@ Complex shape key
|
||||||
================================================================================
|
================================================================================
|
||||||
Foo bar
|
Foo bar
|
||||||
-Biz-baz-
|
-Biz-baz-
|
||||||
|
imAShape
|
||||||
|
im_a_shape
|
||||||
|
im a shape
|
||||||
|
i'm a shape
|
||||||
|
a-shape
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
(source_file
|
(source_file
|
||||||
(shape (shape_key))
|
(shape (shape_key))
|
||||||
(shape (shape_key))
|
(shape (shape_key))
|
||||||
|
(shape (shape_key))
|
||||||
|
(shape (shape_key))
|
||||||
|
(shape (shape_key))
|
||||||
|
(shape (shape_key))
|
||||||
|
(shape (shape_key))
|
||||||
)
|
)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue