jarser
is a parser.
jarser
is not a parser generator. yacc
and bison
are classic examples of parser
generators.
Currently, rule configuration and parsing are performed at runtime.
Install jarser
with npm.
$ npm install [--save] jarser
const Jarser = require('jarser');
const jarser = new Jarser();
jarser.addRule(...);
const rootNode = jarser.parse(tokens);
A scanner scans a file into a sequence of characters. (If using Node.js,
you can rely on the built-in fs
module for this.)
A lexer (or tokenizer) lexes a sequence of characters into a sequence of
tokens, using a defined set of rules. (I recommend jexer
for this stage:
jexer
on npm
jexer
on GitHub)
A parser parses a sequence of tokens into a syntax tree, using a defined
set of rules. (This is what jarser
does.)
A compiler compiles the syntax tree into target code, such as assembly.
An assembler assembles that code into machine code, which a processor can execute directly.