grammar: fix unquoted shape identifier with escape sequence

Closes #21
This commit is contained in:
Dmitriy Pleshevskiy 2023-06-21 17:36:06 +03:00
parent 0003298cb8
commit fdcb5613a5
Signed by: pleshevskiy
GPG key ID: 79C4487B44403985
5 changed files with 59 additions and 10 deletions

View file

@ -199,14 +199,15 @@ module.exports = grammar({
_identifier: ($) =>
seq(
choice(/[\w\d$-]/, $.escape_sequence),
choice(token(prec(PREC.IDENTIFIER, /[\w\d$-]/)), $.escape_sequence),
repeat(
choice(
$.escape_sequence,
token(prec(PREC.IDENTIFIER, /([\w\d'"$(),]+)?( +|-)[\w\d'"$()]+/))
token(prec(PREC.IDENTIFIER, /[\w\d'"$(),]+/)),
token(prec(PREC.IDENTIFIER, /( +|-)[\w\d'"$()]+/))
)
),
optional(/[\w\d'"$()]+/),
optional(token(prec(PREC.IDENTIFIER, /[\w\d'"$()]+/))),
optional($._dash)
),
@ -388,7 +389,7 @@ module.exports = grammar({
token(
prec(
PREC.UNQUOTED_STRING,
/[^'"`\\|\n\s;{}\[\]]([^\\\n;{}\[\]]*[^\\\n\s;{}\[\]])?/
/[^'"`\\|\n\s;{}\[\]][^\\\n;{}\[\]]*[^\\\n\s;{}\[\]]?/
)
)
)

View file

@ -866,8 +866,15 @@
"type": "CHOICE",
"members": [
{
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 0,
"content": {
"type": "PATTERN",
"value": "[\\w\\d$-]"
}
}
},
{
"type": "SYMBOL",
@ -891,7 +898,18 @@
"value": 0,
"content": {
"type": "PATTERN",
"value": "([\\w\\d'\"$(),]+)?( +|-)[\\w\\d'\"$()]+"
"value": "[\\w\\d'\"$(),]+"
}
}
},
{
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 0,
"content": {
"type": "PATTERN",
"value": "( +|-)[\\w\\d'\"$()]+"
}
}
}
@ -902,8 +920,15 @@
"type": "CHOICE",
"members": [
{
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 0,
"content": {
"type": "PATTERN",
"value": "[\\w\\d'\"$()]+"
}
}
},
{
"type": "BLANK"
@ -2047,7 +2072,7 @@
"value": -1,
"content": {
"type": "PATTERN",
"value": "[^'\"`\\\\|\\n\\s;{}\\[\\]]([^\\\\\\n;{}\\[\\]]*[^\\\\\\n\\s;{}\\[\\]])?"
"value": "[^'\"`\\\\|\\n\\s;{}\\[\\]][^\\\\\\n;{}\\[\\]]*[^\\\\\\n\\s;{}\\[\\]]?"
}
}
}

Binary file not shown.

View file

@ -1,3 +1,26 @@
================================================================================
Declare unquoted shape identifier with escape sequence (issue #21)
================================================================================
hello\[world\]
\#ello\[world\]
--------------------------------------------------------------------------------
(source_file
(shape
(shape_key
(escape_sequence)
(escape_sequence)
)
)
(shape
(shape_key
(escape_sequence)
(escape_sequence)
(escape_sequence)
)
)
)
================================================================================
Handle end of file (issue #1)
================================================================================

Binary file not shown.