Show HN: Yantra – an LALR(1) parser generator for C++
Yantra is a new LALR(1) parser generator written in C++ that functions as a powerful compiler compiler with no dependencies beyond the C++ standard library. It features a CMake build system, generates self-contained parsers, and processes input into an Abstract Syntax Tree (AST) before executing semantic actions.
Why it matters
This tool provides C++ developers with a robust, dependency-free solution for creating parsers, potentially simplifying compiler and language tool development for various applications.
Yantra is a powerful compiler compiler and LALR(1) parser generator written in C++, with the following core features:
The name Yantra is Sanskrit for machine , as in state machine in this context.
Yantra has no dependencies beyond the C++ standard library, so building it is a plain CMake build:
git clone git@github.com:TantrixAuto/yantra.git cd yantra mkdir build && cd build cmake .. cmake --build . This produces the ycc executable in bin/ . Save a grammar file, hello.y :
start := stmts; stmts := stmts stmt; stmts := stmt; stmt := ID; ID := "[A-Za-z]+"; WS := "\s"!; Then generate a parser from it:
bin/ycc -c ascii -f hello.y -a This writes hello.cpp (an amalgamated, self-contained parser with its own main() ) and hello.log . Compile it with any C++23 compiler:
Get smarter about the news
Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.
Create free accountAlready have an account? Sign in