MichaelBuhler / jarser

a parser in javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jarser

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.

Installation

Install jarser with npm.

$ npm install [--save] jarser

Usage

const Jarser = require('jarser');
const jarser = new Jarser();
jarser.addRule(...);
const rootNode = jarser.parse(tokens);

A quick lesson in compilation

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.

About

a parser in javascript

License:MIT License


Languages

Language:JavaScript 100.0%