fix ending heredoc identifiers must be on single line
This commit is contained in:
@@ -37,4 +37,3 @@ The aim is to build unit testcases from selected failure classes and slowly get
|
||||
* [x] add quoted template interpolations
|
||||
* [ ] add quoted template directives
|
||||
* [x] add heredoc templates
|
||||
|
||||
|
||||
@@ -12,14 +12,15 @@ After=coreos-metadata.service
|
||||
EOF
|
||||
|
||||
cert_options = <<EOF
|
||||
--cert-file=/etc/ssl/etcd/server.crt \
|
||||
--cert-file=/etc/ssl/etcd/server.crt \
|
||||
--client-cert-auth=true \
|
||||
--key-file=/etc/ssl/etcd/server.key \
|
||||
--peer-cert-file=/etc/ssl/etcd/peer.crt \
|
||||
--peer-key-file=/etc/ssl/etcd/peer.key \
|
||||
--peer-trusted-ca-file=/etc/ssl/etcd/ca.crt \
|
||||
--peer-client-cert-auth=true \
|
||||
--trusted-ca-file=/etc/ssl/etcd/ca.crtEOF
|
||||
--trusted-ca-file=/etc/ssl/etcd/ca.crt
|
||||
EOF
|
||||
}
|
||||
|
||||
data "template_file" "etcd_names" {
|
||||
@@ -279,7 +279,6 @@ module.exports = grammar({
|
||||
$._quoted_template_end,
|
||||
)),
|
||||
|
||||
// TODO user chosen identifiers
|
||||
heredoc_template: $ => seq(
|
||||
$.heredoc_start,
|
||||
$.heredoc_identifier,
|
||||
|
||||
@@ -73,7 +73,11 @@ public:
|
||||
}
|
||||
|
||||
bool scan(TSLexer* lexer, const bool* valid_symbols) {
|
||||
bool has_leading_whitespace_with_newline = false;
|
||||
while (iswspace(lexer->lookahead)) {
|
||||
if (lexer->lookahead == '\n') {
|
||||
has_leading_whitespace_with_newline = true;
|
||||
}
|
||||
skip(lexer);
|
||||
}
|
||||
if (lexer->lookahead == '\0') {
|
||||
@@ -127,7 +131,7 @@ public:
|
||||
context_stack.push_back({ .type = HEREDOC_TEMPLATE, .heredoc_identifier = identifier });
|
||||
return accept_and_advance(lexer, HEREDOC_IDENTIFIER);
|
||||
}
|
||||
if (valid_symbols[HEREDOC_IDENTIFIER] && in_heredoc_context()) {
|
||||
if (valid_symbols[HEREDOC_IDENTIFIER] && in_heredoc_context() && has_leading_whitespace_with_newline) {
|
||||
string expected_identifier = context_stack.back().heredoc_identifier;
|
||||
|
||||
for (string::iterator it = expected_identifier.begin(); it != expected_identifier.end(); ++it) {
|
||||
|
||||
@@ -146,3 +146,26 @@ foo = "hello $${ world"
|
||||
(literal_value
|
||||
(string_lit
|
||||
(template_literal)))))))
|
||||
|
||||
================================================================================
|
||||
tricky heredoc
|
||||
================================================================================
|
||||
|
||||
foo = <<END
|
||||
contains fake endings
|
||||
END (ineligible) END
|
||||
END
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(config_file
|
||||
(body
|
||||
(attribute
|
||||
(identifier)
|
||||
(expression
|
||||
(template_expr
|
||||
(heredoc_template
|
||||
(heredoc_start)
|
||||
(heredoc_identifier)
|
||||
(template_literal)
|
||||
(heredoc_identifier)))))))
|
||||
|
||||
Reference in New Issue
Block a user