Skip to content

panyam/galore

Repository files navigation

Galore

A toolbox for language analyzers and parser generators in TypeScript.

Galore provides implementations of SLR, LALR, and LR(1) parsing algorithms with a simple grammar DSL. It works in Node.js and browsers with full TypeScript support.

Documentation

Full documentation and interactive examples: panyam.github.io/galore

Try grammars in the browser: Playground

Installation

npm install galore

Quick Example

import { newParser } from "galore";

const parser = newParser(`
  %token NUMBER /[0-9]+/

  Expr -> Expr "+" Term | Term ;
  Term -> Term "*" Factor | Factor ;
  Factor -> "(" Expr ")" | NUMBER ;
`, { type: "lalr" });

const result = parser.parse("1 + 2 * 3");

Features

  • Multiple parser types - SLR, LALR, and LR(1) table generation
  • Grammar DSL - BNF-style grammar definitions with regex token patterns
  • Parse table visualization - See shift/reduce tables and LR item sets
  • Conflict detection - Identifies shift-reduce and reduce-reduce conflicts
  • Semantic actions - Attach JavaScript actions to grammar rules
  • TypeScript native - Full type definitions included

Examples

The documentation includes several runnable examples:

License

MIT

About

An embedable parser generator library in/for typescript web applications

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors