remove escape sequence for single quoted string

This commit is contained in:
Dmitriy Pleshevskiy 2022-12-11 14:16:23 +03:00
parent 3fe837dccb
commit fc3754658c
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
5 changed files with 32 additions and 30 deletions

View file

@ -286,12 +286,7 @@ module.exports = grammar({
choice(
seq(
"'",
repeat(
choice(
alias($._unescaped_single_string_fragment, $.string_fragment),
$.escape_sequence
)
),
"'"
),
seq(
@ -306,7 +301,7 @@ module.exports = grammar({
)
),
_unescaped_single_string_fragment: ($) => token.immediate(/[^'\\\n]+/),
_unescaped_single_string_fragment: ($) => token.immediate(/[^'\n]+/),
_unescaped_double_string_fragment: ($) => token.immediate(/[^"\\\n]+/),

View file

@ -1212,11 +1212,6 @@
"type": "STRING",
"value": "'"
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
@ -1226,13 +1221,6 @@
"named": true,
"value": "string_fragment"
},
{
"type": "SYMBOL",
"name": "escape_sequence"
}
]
}
},
{
"type": "STRING",
"value": "'"
@ -1279,7 +1267,7 @@
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "[^'\\\\\\n]+"
"value": "[^'\\n]+"
}
},
"_unescaped_double_string_fragment": {

Binary file not shown.

View file

@ -57,6 +57,25 @@ Use quoted string as a shape key
(shape (shape_key (string (string_fragment))))
)
================================================================================
Use escape sequence in quoted string as a shape key
================================================================================
'\# hello \# world'
"\# hello \# world"
--------------------------------------------------------------------------------
(source_file
(shape (shape_key (string (string_fragment))))
(shape (shape_key (string
(escape_sequence)
(string_fragment)
(escape_sequence)
(string_fragment)
)))
)
================================================================================
Define multiple shapes using semicolons
================================================================================
@ -159,9 +178,9 @@ foo: |go
)
================================================================================
Text block with quotes (d2-vim style)
Text block with quotes (custom escape characters)
================================================================================
foo: |`go
foo: |$$$go
awsSession := From(c.Request.Context())
@ -171,7 +190,7 @@ foo: |`go
ctx, cancelFn := context.WithTimeout(c.Request.Context(), AWS_TIMEOUT)
defer cancelFn()
`|
$$$|
--------------------------------------------------------------------------------
@ -190,7 +209,7 @@ Online text block
================================================================================
foo: | helo world |
bar: |%%md ## hello world %%|
bar: |##md ## hello world ##|
--------------------------------------------------------------------------------

Binary file not shown.