remove escape sequence for single quoted string
This commit is contained in:
parent
3fe837dccb
commit
fc3754658c
5 changed files with 32 additions and 30 deletions
|
@ -286,12 +286,7 @@ module.exports = grammar({
|
|||
choice(
|
||||
seq(
|
||||
"'",
|
||||
repeat(
|
||||
choice(
|
||||
alias($._unescaped_single_string_fragment, $.string_fragment),
|
||||
$.escape_sequence
|
||||
)
|
||||
),
|
||||
alias($._unescaped_single_string_fragment, $.string_fragment),
|
||||
"'"
|
||||
),
|
||||
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]+/),
|
||||
|
||||
|
|
|
@ -1213,25 +1213,13 @@
|
|||
"value": "'"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "ALIAS",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_unescaped_single_string_fragment"
|
||||
},
|
||||
"named": true,
|
||||
"value": "string_fragment"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "escape_sequence"
|
||||
}
|
||||
]
|
||||
}
|
||||
"type": "SYMBOL",
|
||||
"name": "_unescaped_single_string_fragment"
|
||||
},
|
||||
"named": true,
|
||||
"value": "string_fragment"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
|
@ -1279,7 +1267,7 @@
|
|||
"type": "IMMEDIATE_TOKEN",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[^'\\\\\\n]+"
|
||||
"value": "[^'\\n]+"
|
||||
}
|
||||
},
|
||||
"_unescaped_double_string_fragment": {
|
||||
|
|
BIN
src/parser.c
BIN
src/parser.c
Binary file not shown.
|
@ -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.
Loading…
Reference in a new issue