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))),
_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
@ -255,7 +260,7 @@ module.exports = grammar({
dot: ($) => token("."),
_unquoted_string: ($) =>
token(prec(PREC.UNQUOTED_STRING, /[\w\-?!]([^'"`\n;{}]*[\w\-?!])?/)),
token(prec(PREC.UNQUOTED_STRING, /[^'"`\n\s;{}]([^\n;{}]*[^\n\s;{}])?/)),
string: ($) =>
choice(

View file

@ -502,7 +502,7 @@
"value": 0,
"content": {
"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,
"content": {
"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
label: ten
constraint: utehu
icon: huell
icon: ./test.svg
opacity: 1
fill: red
stroke: red
@ -392,3 +392,4 @@ foo -> bar: {
)
)

View file

@ -26,12 +26,22 @@ Complex shape key
================================================================================
Foo bar
-Biz-baz-
imAShape
im_a_shape
im a shape
i'm a shape
a-shape
--------------------------------------------------------------------------------
(source_file
(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.