jison icon indicating copy to clipboard operation
jison copied to clipboard

Escaping $1

Open brokenpylons opened this issue 6 years ago • 1 comments

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.

brokenpylons avatar Oct 25 '18 10:10 brokenpylons

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"; }
;

blackshadev avatar Nov 06 '18 07:11 blackshadev