Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including lavriapg with all npm packages installed. Try it out:

var lavriapg = require("lavriapg")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

lavriapg v0.4.1

lalr(1) parser generator written in TypeScript


TypeScript LALR(1) Parser Generator


requirement: npm

$ mkdir pg
$ cd pg
$ npm init
$ npm install lavriapg --save


$ echo 1+1 | node ./node_modules/lavriapg/dist/sample.js


edit language and run the following code:

// TypeScript
import {language_parser, ParserGenerator} from "lavriapg";
import {readFileSync} from "fs";

const input = readFileSync("/dev/stdin", "utf8") as string;
const language = language_parser.parse(readFileSync("./node_modules/lavriapg/language", "utf8") as string); // set the language file path
const parser = new ParserGenerator(language).getParser();
// JavaScript(CommonJS)
const pg = require("lavriapg");
const fs = require("fs");
const input = fs.readFileSync("/dev/stdin", "utf8");
const language = pg.language_parser.parse(fs.readFileSync("./node_modules/lavriapg/language", "utf8")); // set the language file path
const parser = new pg.ParserGenerator(language).getParser();

this program parses input (from stdin) that has the lex and grammar rules defined by language and shows its AST.

language is language file and it expresses itself.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free