jison: how to add “require” in jison file?

I search online documentation but haven't found the way. For a rule like below (taken from the calculator example), I want to refer to external code.

expressions
    :  NUMBER
        {$$ = new My.Number(yytext);}

To achieve that, I need to require('My') somewhere in the jison file but when I try to add require, it is removed from the js file generated.

Answers:

Answer

You can add another section after your grammar, like this:

%%
const My = require('My') 

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.