antlr / grammars-v4

Grammars written for ANTLR v4; expectation that the grammars are free of actions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[javascript] Parsing fails if there are curly braces inside a template literal

tanzaku opened this issue · comments

An error will occur when parsing a statement like the one below.

var nested = `Object in template literal ${JSON.stringify({ key: 'value' })}`

The error that occurs is as follows:

line 1:57 mismatched input '(' expecting TemplateCloseBrace
line 1:73 no viable alternative at input '}'
line 2:0 mismatched input '<EOF>' expecting {BackTick, '${', TemplateStringAtom}

I suspect that when there are curly braces within a template literal, the } is mistaken for the end of the template literal, causing an error.