grammar: add escape sequence for unquoted string

Closes #8
This commit is contained in:
Dmitriy Pleshevskiy 2023-01-05 16:28:22 +03:00
parent 4fdf38aebe
commit b9fa5785b4
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
6 changed files with 55 additions and 24 deletions

View file

@ -130,10 +130,12 @@ module.exports = grammar({
_identifier: ($) => _identifier: ($) =>
seq( seq(
optional("-"), choice(/[\w\d$-]/, $.escape_sequence),
/[\w\d$]/,
repeat( repeat(
token(prec(PREC.IDENTIFIER, /([\w\d'"$(),]+)?( +|-)[\w\d'"$()]+/)) choice(
$.escape_sequence,
token(prec(PREC.IDENTIFIER, /([\w\d'"$(),]+)?( +|-)[\w\d'"$()]+/))
)
), ),
optional(/[\w\d'"$()]+/), optional(/[\w\d'"$()]+/),
optional($._dash) optional($._dash)

View file

@ -539,30 +539,36 @@
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "STRING", "type": "PATTERN",
"value": "-" "value": "[\\w\\d$-]"
}, },
{ {
"type": "BLANK" "type": "SYMBOL",
"name": "escape_sequence"
} }
] ]
}, },
{
"type": "PATTERN",
"value": "[\\w\\d$]"
},
{ {
"type": "REPEAT", "type": "REPEAT",
"content": { "content": {
"type": "TOKEN", "type": "CHOICE",
"content": { "members": [
"type": "PREC", {
"value": 0, "type": "SYMBOL",
"content": { "name": "escape_sequence"
"type": "PATTERN", },
"value": "([\\w\\d'\"$(),]+)?( +|-)[\\w\\d'\"$()]+" {
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 0,
"content": {
"type": "PATTERN",
"value": "([\\w\\d'\"$(),]+)?( +|-)[\\w\\d'\"$()]+"
}
}
} }
} ]
} }
}, },
{ {

View file

@ -183,9 +183,13 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": false, "multiple": true,
"required": false, "required": false,
"types": [ "types": [
{
"type": "escape_sequence",
"named": true
},
{ {
"type": "string", "type": "string",
"named": true "named": true
@ -249,9 +253,13 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": false, "multiple": true,
"required": false, "required": false,
"types": [ "types": [
{
"type": "escape_sequence",
"named": true
},
{ {
"type": "string", "type": "string",
"named": true "named": true
@ -336,10 +344,6 @@
"type": "'", "type": "'",
"named": false "named": false
}, },
{
"type": "-",
"named": false
},
{ {
"type": "3d", "type": "3d",
"named": false "named": false

Binary file not shown.

View file

@ -226,3 +226,22 @@ foo.baz: {
) )
) )
) )
================================================================================
Connection with espaced key fragments
================================================================================
\#(hello)- -- b\#-world
--------------------------------------------------------------------------------
(source_file
(connection
(shape_key
(escape_sequence)
)
(arrow)
(shape_key
(escape_sequence)
)
)
)

Binary file not shown.