allow empty templates and template interpolations
This commit is contained in:
10
grammar.js
10
grammar.js
@@ -269,22 +269,22 @@ module.exports = grammar({
|
|||||||
|
|
||||||
quoted_template: $ => prec(PREC.quoted_template, seq(
|
quoted_template: $ => prec(PREC.quoted_template, seq(
|
||||||
$._quoted_template_start,
|
$._quoted_template_start,
|
||||||
repeat(choice(
|
optional(repeat(choice(
|
||||||
$.template_literal,
|
$.template_literal,
|
||||||
$.template_interpolation,
|
$.template_interpolation,
|
||||||
$.template_directive,
|
$.template_directive,
|
||||||
)),
|
))),
|
||||||
$._quoted_template_end,
|
$._quoted_template_end,
|
||||||
)),
|
)),
|
||||||
|
|
||||||
heredoc_template: $ => seq(
|
heredoc_template: $ => seq(
|
||||||
$.heredoc_start,
|
$.heredoc_start,
|
||||||
$.heredoc_identifier,
|
$.heredoc_identifier,
|
||||||
repeat(choice(
|
optional(repeat(choice(
|
||||||
$.template_literal,
|
$.template_literal,
|
||||||
$.template_interpolation,
|
$.template_interpolation,
|
||||||
$.template_directive,
|
$.template_directive,
|
||||||
)),
|
))),
|
||||||
$.heredoc_identifier,
|
$.heredoc_identifier,
|
||||||
),
|
),
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ module.exports = grammar({
|
|||||||
template_interpolation: $ => seq(
|
template_interpolation: $ => seq(
|
||||||
$._template_interpolation_start,
|
$._template_interpolation_start,
|
||||||
optional($.strip_marker),
|
optional($.strip_marker),
|
||||||
$.expression,
|
optional($.expression),
|
||||||
optional($.strip_marker),
|
optional($.strip_marker),
|
||||||
$._template_interpolation_end,
|
$._template_interpolation_end,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1181,6 +1181,9 @@
|
|||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_quoted_template_start"
|
"name": "_quoted_template_start"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "REPEAT",
|
"type": "REPEAT",
|
||||||
"content": {
|
"content": {
|
||||||
@@ -1201,6 +1204,11 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_quoted_template_end"
|
"name": "_quoted_template_end"
|
||||||
@@ -1219,6 +1227,9 @@
|
|||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "heredoc_identifier"
|
"name": "heredoc_identifier"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "REPEAT",
|
"type": "REPEAT",
|
||||||
"content": {
|
"content": {
|
||||||
@@ -1239,6 +1250,11 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "heredoc_identifier"
|
"name": "heredoc_identifier"
|
||||||
@@ -1292,10 +1308,18 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "expression"
|
"name": "expression"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
|
|||||||
@@ -669,7 +669,7 @@
|
|||||||
"fields": {},
|
"fields": {},
|
||||||
"children": {
|
"children": {
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
"required": true,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "expression",
|
"type": "expression",
|
||||||
|
|||||||
20533
src/parser.c
20533
src/parser.c
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,23 @@ foo = "${ var.bar }"
|
|||||||
(get_attr
|
(get_attr
|
||||||
(identifier))))))))))
|
(identifier))))))))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
empty template
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
foo = "${}"
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(config_file
|
||||||
|
(body
|
||||||
|
(attribute
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(template_expr
|
||||||
|
(quoted_template
|
||||||
|
(template_interpolation)))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
quoted template expression with escaped strings and fake strip marker
|
quoted template expression with escaped strings and fake strip marker
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user