jison-lex

0.3.4 • Public • Published

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

Usage: jison-lex [file] [options]

file     file containing a lexical grammar

Options:
   -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

var JisonLex = require('jison-lex');

var grammar = {
  rules: [
    ["x", "return 'X';" ],
    ["y", "return 'Y';" ],
    ["$", "return 'EOF';" ]
  ]
};

// or load from a file
// var grammar = fs.readFileSync('mylexer.l', 'utf8');

// generate source
var lexerSource = JisonLex.generate(grammar);

// or create a parser in memory
var lexer = new JisonLex(grammar);
lexer.setInput('xyxxy');
lexer.lex();
// => 'X'
lexer.lex();
// => 'Y'

## license
MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.3.4
    32,126
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.3.4
    32,126
  • 0.3.3
    3
  • 0.3.2
    113
  • 0.2.1
    32,881
  • 0.2.0
    3
  • 0.1.0
    7
  • 0.0.1
    5

Package Sidebar

Install

npm i jison-lex

Homepage

jison.org

Weekly Downloads

65,138

Version

0.3.4

License

none

Last publish

Collaborators

  • zaach