Skip to content
Merged
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
6 changes: 3 additions & 3 deletions src/gen-lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ export function createLexer(grammar: CstGrammar) {
// grammar's template token; only called when such a token is declared.
function scanTemplateSpan(source: string, pos: number, validateEscapes: boolean): { endsWithInterp: boolean; end: number } {
while (pos < source.length) {
if (source[pos] === '\\') {
if (source.startsWith(tplInterpOpen, pos)) {
return { endsWithInterp: true, end: pos + tplInterpOpen.length };
} else if (source[pos] === '\\') {
// In tag position invalid escapes are legal (validateEscapes=false): just skip
// `\` + next char. Otherwise the escape must match the token's declared
// escapeValid pattern, else it's a scan error (e.g. `\u{110000}`, `\u{r}`).
Expand All @@ -100,8 +102,6 @@ export function createLexer(grammar: CstGrammar) {
} else {
pos += 2;
}
} else if (source.startsWith(tplInterpOpen, pos)) {
return { endsWithInterp: true, end: pos + tplInterpOpen.length };
} else if (source.startsWith(tplOpen, pos)) {
return { endsWithInterp: false, end: pos + tplOpen.length };
} else {
Expand Down
Loading