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_start,
|
||||
repeat(choice(
|
||||
optional(repeat(choice(
|
||||
$.template_literal,
|
||||
$.template_interpolation,
|
||||
$.template_directive,
|
||||
)),
|
||||
))),
|
||||
$._quoted_template_end,
|
||||
)),
|
||||
|
||||
heredoc_template: $ => seq(
|
||||
$.heredoc_start,
|
||||
$.heredoc_identifier,
|
||||
repeat(choice(
|
||||
optional(repeat(choice(
|
||||
$.template_literal,
|
||||
$.template_interpolation,
|
||||
$.template_directive,
|
||||
)),
|
||||
))),
|
||||
$.heredoc_identifier,
|
||||
),
|
||||
|
||||
@@ -299,7 +299,7 @@ module.exports = grammar({
|
||||
template_interpolation: $ => seq(
|
||||
$._template_interpolation_start,
|
||||
optional($.strip_marker),
|
||||
$.expression,
|
||||
optional($.expression),
|
||||
optional($.strip_marker),
|
||||
$._template_interpolation_end,
|
||||
),
|
||||
|
||||
@@ -1182,24 +1182,32 @@
|
||||
"name": "_quoted_template_start"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_literal"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_interpolation"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_directive"
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_literal"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_interpolation"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_directive"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
@@ -1220,24 +1228,32 @@
|
||||
"name": "heredoc_identifier"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_literal"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_interpolation"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_directive"
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_literal"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_interpolation"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "template_directive"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
@@ -1293,8 +1309,16 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
|
||||
@@ -669,7 +669,7 @@
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"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
|
||||
(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
|
||||
================================================================================
|
||||
|
||||
Reference in New Issue
Block a user