fix unquoted strings and identifiers

This commit is contained in:
Dmitriy Pleshevskiy 2022-12-09 15:02:21 +03:00
parent 6ec0bb5c59
commit 612b7fb871
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
6 changed files with 21 additions and 5 deletions

View file

@ -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(

View file

@ -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;{}])?"
} }
} }
}, },

Binary file not shown.

View file

@ -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: {
) )
) )

View file

@ -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.