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

View File

@ -866,8 +866,15 @@
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "PATTERN", "type": "TOKEN",
"value": "[\\w\\d$-]" "content": {
"type": "PREC",
"value": 0,
"content": {
"type": "PATTERN",
"value": "[\\w\\d$-]"
}
}
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
@ -891,7 +898,18 @@
"value": 0, "value": 0,
"content": { "content": {
"type": "PATTERN", "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", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "PATTERN", "type": "TOKEN",
"value": "[\\w\\d'\"$()]+" "content": {
"type": "PREC",
"value": 0,
"content": {
"type": "PATTERN",
"value": "[\\w\\d'\"$()]+"
}
}
}, },
{ {
"type": "BLANK" "type": "BLANK"
@ -2047,7 +2072,7 @@
"value": -1, "value": -1,
"content": { "content": {
"type": "PATTERN", "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) Handle end of file (issue #1)
================================================================================ ================================================================================

Binary file not shown.