Yantra is a new compiler compiler and LALR(1) parser generator developed in C++. The name 'Yantra' is Sanskrit for machine, referencing its state machine nature. It aims to provide a robust tool for parsing tasks within C++ environments.
Key features of Yantra include an integrated lexer, built-in support for UNICODE/UTF8 input, and a built-in Abstract Syntax Tree (AST) builder and walker. It supports bottom-up parsing (LALR) and top-down AST traversal. The lexer is multi-mode, allowing for complex parsing scenarios like nested multi-line comments, and operates in a push-based manner, processing input character by character as it arrives.
Yantra offers an optional amalgamated mode, generating the entire parser as a single C++ file with a main() function. Alternatively, in non-amalgamated mode, it produces separate .hpp and .cpp files for integration into existing projects.
Yantra has no dependencies beyond the C++ standard library, simplifying its build process. Users can clone the repository and build it using CMake, which produces the `ycc` executable. This executable is then used to generate parsers from grammar files.
An example demonstrates generating a parser from a grammar file (`hello.y`) that recognizes whitespace-separated alphabetic words. The `ycc` tool generates `hello.cpp` and `hello.log`. This generated C++ file can then be compiled with any C++23 compliant compiler (Clang, GCC, MSVC) to create an executable parser. The parser can process strings directly or read from files, and it provides detailed AST output or error messages for invalid input.
Yantra's parsing mechanism involves parsing the entire input into an AST first, then walking the AST top-down to execute semantic actions. This differs from many other parser generators where actions run bottom-up as each rule is reduced.
✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →
One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.
One email a day. Unsubscribe in one click, any time.
Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.
▶ Play today's briefNew every morning, and the back catalogue is archived by date.
Yantra, a new LALR(1) parser generator written in C++, has been released, offering features like an integrated lexer, Unicode/UTF8 support, and built-in AST capabilities. This tool provides developers with a dependency-free option for generating parsers for C++ projects.