diff --git a/grammar.js b/grammar.js index c1ed37e..64eb727 100644 --- a/grammar.js +++ b/grammar.js @@ -1461,7 +1461,7 @@ module.exports = grammar({ ), '`', )), - $.template_string_content, + optional($.template_string_content), '`' ), @@ -1470,6 +1470,7 @@ module.exports = grammar({ choice( $._template_chars, $.template_substitution, + /\s/, choice( alias('\\`', $.escape_sequence), $.escape_sequence, diff --git a/test/corpus/literals.txt b/test/corpus/literals.txt index 14f4e2c..bbf84f5 100644 --- a/test/corpus/literals.txt +++ b/test/corpus/literals.txt @@ -111,6 +111,9 @@ Quote escaping Template strings ============================================ +`` +` ` +` \b` `one line` `multi line` @@ -132,9 +135,13 @@ The caller should either handle this error, or expect that exit code.` anything`Hello` + ---- (source_file + (expression_statement (template_string)) + (expression_statement (template_string (template_string_content))) + (expression_statement (template_string (template_string_content (escape_sequence)))) (expression_statement (template_string (template_string_content))) (expression_statement (template_string (template_string_content))) (expression_statement (template_string (template_string_content)))