looker/jison-lex

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

jison-lex

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.

install

npm install jison-lex -g

usage
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
programatic usage
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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.