Skip to content

A-LPG/LPG2

Repository files navigation

LPG2

VS Code Marketplace version

LPG2 (Lookahead Parser Generator v2) compiles .g / .lpg grammars into parse tables and semantic-action code for your target language.

Current version: 2.3.0 (lpg-v2.3.0)

中文文档 · Documentation index

Documentation

Docs are layered by audience. New to LPG? Start with the Quick Start.

Document Audience Contents
Quick Start (5 min) Beginners Download/build generator → run calculator
Concepts Beginners How generator / templates / runtime fit together
Tutorial Beginners Step-by-step calculator grammar
User guide Grammar authors, integrators Tooling, CLI, languages, runtimes, FAQ
Developer guide Generator maintainers Build, layout, bootstrap, tests, backends
AI / Agent playbook AI coding agents Workflow, CLI, language matrix, anti-patterns (AGENTS.md)
Chinese docs 中文读者 上手 / 概念 / 教程 / USER / AI 等
Contributing Contributors Build, goldens, PR process
Doc index Pick a path by role
Ecosystem Integrators / release Runtime versions, package coords, release checklist

Topics:

Repository layout

Path Role
lpg2/ Generator sources
runtime/ Language runtimes (git submodules)
tool/ VS Code extension and language server (submodules)
grammars-example/ Example grammars (submodule)
examples/calculator/ Runnable calculator starter
docs/ Documentation (docs/en/ default; Chinese alongside)

Quick try

Fastest: npm

npx lpg2 --help
npx lpg2 -programming_language=java -table your.g

Browser playground (WASM, built by CI): playground/.

The C++ runtime provides token-level re-lex + statement-level re-parse (not tree-sitter subtree reuse); see USER.md / ECOSYSTEM.md.

Recommended: Release binary + calculator

  1. Download a platform archive from GitHub Releases and verify SHA256SUMS
  2. Init the runtime submodule for your language (e.g. Java):
git submodule update --init runtime/lpg-runtime
export LPG_BIN=/path/to/bin/lpg-v2.3.0
./examples/calculator/scripts/run.sh java

Full steps: docs/en/QUICKSTART.md.

Or build the generator from source:

cd lpg2
cmake -S . -B build && cmake --build build -j
export LPG_BIN="$PWD/build/lpg-v2.3.0"
cd ..
./examples/calculator/scripts/run.sh java

Integration and CLI details: user guide.

Related projects

About

The LALR parser generator (LPG) is a tool for developing scanners and parsers. Supports multi-language . Input is specified by BNF rules. LPG supports backtracking (to resolve ambiguity), automatic AST generation and grammar inheritance.

Topics

Resources

License

Contributing

Security policy

Stars

8 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors