zaach / jison

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

Reuse syntax across projects? #355

Open metasansana opened 7 years ago

metasansana commented 7 years ago

Now that modules for JavaScript are more or less standardized (syntax at least) it would be useful if jison and the lexer knew how to import directives.

Not sure how feasible this is with the current code base but I find myself copy and pasting syntax from existing projects to new ones.

Perhaps something like

%lex
%import {StringLiteral, NumberLiteral} from 'path/to/syntax'
 %
{StringLiteral}  return {STRING_LITERAL}

/lex

%import  {js} from 'path/to/syntax'
%start js
%%