package
A parser for lexical grammars used by jison
npm install lex-parserGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
A parser for lexical grammars used by jison and jison-lex.
npm install lex-parserTo build the parser yourself, clone the git repo then run:
makeThis will generate lex-parser.js.
var lexParser = require('lex-parser');
// parse a lexical grammar and return JSON
lexParser.parse("%% ... ");The parser can parse its own lexical grammar, shown below:
NAME [a-zA-Z_][a-zA-Z0-9_-]*
%s indented trail rules
%x code start_condition options conditions action
%%
<action>[^{}]+ return 'ACTION_BODY'
<action>"{" yy.depth++; return '{'
<action>"}" yy.depth == 0 ? this.begin('trail') : yy.depth--; return '}'
<conditions>{NAME} return 'NAME'
<conditions>">" this.popState(); return '>'
<conditions>"," return ','
<conditions>"*" return '*'
<rules>\n+ /* */
<rules>\s+ this.begin('indented')
<rules>"%%" this.begin('code'); return '%%'
<rules>[a-zA-Z0-9_]+ return 'CHARACTER_LIT'
<options>{NAME} yy.options[yytext] = true
<options>\n+ this.begin('INITIAL')
<options>\s+\n+ this.begin('INITIAL')
<options>\s+ /* empty */
<start_condition>{NAME} return 'START_COND'
<start_condition>\n+ this.begin('INITIAL')
<start_condition>\s+\n+ this.begin('INITIAL')
<start_condition>\s+ /* empty */
<trail>.*\n+ this.begin('rules')
MIT