zaach / jison

Bison in JavaScript.
http://jison.org
4.33k stars 448 forks source link

Escaping $1 #380

Open brokenpylons opened 5 years ago

brokenpylons commented 5 years ago

I have an action with $1.replace(/['"](.+)['"]/, '$1' ). How do I escape the $1? The only solution I found is to use \u0024 instead of $, but that's a bit hacky.

blackshadev commented 5 years ago

I did this by defining a constant in a codeblock like shown below.

Sill pretty hacky, but I tried al sorts of escape sequences, none of them worked.

%{
var dollar = "$";
%}

... lex 

%%
rule : a + b { return dollar + "1"; }
;