fix empty heredoc templates
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.3.0 - not yet released
|
||||||
|
|
||||||
|
fix:
|
||||||
|
* correct expression for identifiers
|
||||||
|
* allow empty template interpolations
|
||||||
|
* allow empty templates
|
||||||
|
|
||||||
## 0.2.0 - 2021-06-26
|
## 0.2.0 - 2021-06-26
|
||||||
|
|
||||||
feature:
|
feature:
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public:
|
|||||||
advance(lexer);
|
advance(lexer);
|
||||||
}
|
}
|
||||||
context_stack.push_back({ .type = HEREDOC_TEMPLATE, .heredoc_identifier = identifier });
|
context_stack.push_back({ .type = HEREDOC_TEMPLATE, .heredoc_identifier = identifier });
|
||||||
return accept_and_advance(lexer, HEREDOC_IDENTIFIER);
|
return accept_inplace(lexer, HEREDOC_IDENTIFIER);
|
||||||
}
|
}
|
||||||
if (valid_symbols[HEREDOC_IDENTIFIER] && in_heredoc_context() && has_leading_whitespace_with_newline) {
|
if (valid_symbols[HEREDOC_IDENTIFIER] && in_heredoc_context() && has_leading_whitespace_with_newline) {
|
||||||
string expected_identifier = context_stack.back().heredoc_identifier;
|
string expected_identifier = context_stack.back().heredoc_identifier;
|
||||||
@@ -138,7 +138,7 @@ public:
|
|||||||
if (lexer->lookahead == *it) {
|
if (lexer->lookahead == *it) {
|
||||||
advance(lexer);
|
advance(lexer);
|
||||||
} else {
|
} else {
|
||||||
return accept_and_advance(lexer, TEMPLATE_LITERAL_CHUNK);
|
return accept_inplace(lexer, TEMPLATE_LITERAL_CHUNK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check if the identifier is on a line of its own
|
// check if the identifier is on a line of its own
|
||||||
@@ -148,7 +148,7 @@ public:
|
|||||||
}
|
}
|
||||||
if (lexer->lookahead == '\n') {
|
if (lexer->lookahead == '\n') {
|
||||||
context_stack.pop_back();
|
context_stack.pop_back();
|
||||||
return accept_and_advance(lexer, HEREDOC_IDENTIFIER);
|
return accept_inplace(lexer, HEREDOC_IDENTIFIER);
|
||||||
} else {
|
} else {
|
||||||
advance(lexer);
|
advance(lexer);
|
||||||
lexer->mark_end(lexer);
|
lexer->mark_end(lexer);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ foo = "${ var.bar }"
|
|||||||
(identifier))))))))))
|
(identifier))))))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
empty template
|
empty template interpolation
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
foo = "${}"
|
foo = "${}"
|
||||||
@@ -37,6 +37,48 @@ foo = "${}"
|
|||||||
(quoted_template
|
(quoted_template
|
||||||
(template_interpolation)))))))
|
(template_interpolation)))))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
empty heredoc template
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
foo = <<END
|
||||||
|
END
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(config_file
|
||||||
|
(body
|
||||||
|
(attribute
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(template_expr
|
||||||
|
(heredoc_template
|
||||||
|
(heredoc_start)
|
||||||
|
(heredoc_identifier)
|
||||||
|
(heredoc_identifier)))))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
heredoc with fake ending
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
foo = <<END
|
||||||
|
END not!
|
||||||
|
END
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(config_file
|
||||||
|
(body
|
||||||
|
(attribute
|
||||||
|
(identifier)
|
||||||
|
(expression
|
||||||
|
(template_expr
|
||||||
|
(heredoc_template
|
||||||
|
(heredoc_start)
|
||||||
|
(heredoc_identifier)
|
||||||
|
(template_literal)
|
||||||
|
(heredoc_identifier)))))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
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