fix empty heredoc templates

This commit is contained in:
mhoffm
2021-06-27 15:54:15 +02:00
parent 6c5f3eba28
commit fd450bb5f6
3 changed files with 53 additions and 4 deletions

View File

@@ -129,7 +129,7 @@ public:
advance(lexer);
}
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) {
string expected_identifier = context_stack.back().heredoc_identifier;
@@ -138,7 +138,7 @@ public:
if (lexer->lookahead == *it) {
advance(lexer);
} 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
@@ -148,7 +148,7 @@ public:
}
if (lexer->lookahead == '\n') {
context_stack.pop_back();
return accept_and_advance(lexer, HEREDOC_IDENTIFIER);
return accept_inplace(lexer, HEREDOC_IDENTIFIER);
} else {
advance(lexer);
lexer->mark_end(lexer);