GerHobbelt / jison

bison / YACC / LEX in JavaScript (LALR(1), SLR(1), etc. lexer/parser generator)
https://gerhobbelt.github.io/jison/
MIT License
118 stars 20 forks source link

action code sometimes doesn't get expanded properly when using ES6/2017 string templates #22

Open GerHobbelt opened 7 years ago

GerHobbelt commented 7 years ago
`this is an ES6 string which has double-quoted jison var ref like this: "${@var}"`

in the above situation, with the quotes inside the template string, around the jison variable reference, such a variable doesn't get expanded.

The problem existed in the jison grammar spec itself, but a quick hack at least has that one circumvented for the time being:

var js_var = @var;  // this DOES get expanded!
...`this is an ES6 string which has double-quoted jison var ref like this: "${js_var}"`
// ^^^ the above string template delivers as expected and doesn't barf a hairball when executed.

(See bnf.y for an example of this)

This needs to be fixed; we'll need the new tweaked recast library for real for this, as we've just hit the limit of regex replace power. ;-)