Name: jison-lex
Owner: looker
Description: generates lexical analyzers. used by jison.
Forked from: zaach/jison-lex
Created: 2017-06-16 21:04:13.0
Updated: 2017-06-16 21:04:14.0
Pushed: 2017-06-16 21:16:21.0
Homepage: null
Size: 41
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A lexical analyzer generator used by jison. It takes a lexical grammar definition (either in JSON or Bison's lexical grammar format) and outputs a JavaScript lexer.
npm install jison-lex -g
e: jison-lex [file] [options]
file containing a lexical grammar
ons:
o FILE, --outfile FILE Filename and base module name of the generated parser
t TYPE, --module-type TYPE The type of module to generate (commonjs, js)
-version print version and exit
JisonLex = require('jison-lex');
grammar = {
les: [
["x", "return 'X';" ],
["y", "return 'Y';" ],
["$", "return 'EOF';" ]
r load from a file
ar grammar = fs.readFileSync('mylexer.l', 'utf8');
enerate source
lexerSource = JisonLex.generate(grammar);
r create a parser in memory
lexer = new JisonLex(grammar);
r.setInput('xyxxy');
r.lex();
> 'X'
r.lex();
> 'Y'
icense