Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1457,11 +1457,13 @@ module.exports = grammar({

template_string: $ => seq(
token(seq(
optional(choice(
'j',
'js',
'json',
)),
optional(
choice(
/[a-z_][a-zA-Z0-9_']*/,
// escape_sequence
seq('\\"', /[^"]+/ , '"'),
)
),
'`',
)),
$.template_string_content,
Expand Down
5 changes: 4 additions & 1 deletion test/corpus/literals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ The caller should either handle this error, or expect that exit code.`

`\\`

anything`Hello`

----

(source_file
Expand All @@ -156,7 +158,8 @@ The caller should either handle this error, or expect that exit code.`
(escape_sequence)
(template_substitution (value_identifier)))))
(expression_statement (template_string (template_string_content)))
(expression_statement (template_string (template_string_content (escape_sequence)))))
(expression_statement (template_string (template_string_content (escape_sequence))))
(expression_statement (template_string (template_string_content))))

============================================
Tricky template strings
Expand Down