Skip to content

Commit 7d5fa43

Browse files
authored
Merge pull request rescript-lang#192 from aspeddro/relax-prefix-template-string
fix: relax template string prefix
2 parents 65b4288 + 27912e4 commit 7d5fa43

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

grammar.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,11 +1457,13 @@ module.exports = grammar({
14571457

14581458
template_string: $ => seq(
14591459
token(seq(
1460-
optional(choice(
1461-
'j',
1462-
'js',
1463-
'json',
1464-
)),
1460+
optional(
1461+
choice(
1462+
/[a-z_][a-zA-Z0-9_']*/,
1463+
// escape_sequence
1464+
seq('\\"', /[^"]+/ , '"'),
1465+
)
1466+
),
14651467
'`',
14661468
)),
14671469
$.template_string_content,

test/corpus/literals.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ The caller should either handle this error, or expect that exit code.`
130130

131131
`\\`
132132

133+
anything`Hello`
134+
133135
----
134136

135137
(source_file
@@ -156,7 +158,8 @@ The caller should either handle this error, or expect that exit code.`
156158
(escape_sequence)
157159
(template_substitution (value_identifier)))))
158160
(expression_statement (template_string (template_string_content)))
159-
(expression_statement (template_string (template_string_content (escape_sequence)))))
161+
(expression_statement (template_string (template_string_content (escape_sequence))))
162+
(expression_statement (template_string (template_string_content))))
160163

161164
============================================
162165
Tricky template strings

0 commit comments

Comments
 (0)