Yantra - LALR(1) parser generator for C++

Show HN: Yantra – an LALR(1) parser generator for C++

Yantra is a powerful LALR(1) parser generator for C++ that integrates a lexer, parser, and AST builder into one tool. It builds a full AST first, then walks it top-down, enabling parent actions before children. Features include UTF-8 support, multi-mode lexer, and optional amalgamated output. With no dependencies beyond the C++ standard library, it's easy to build and use. Ideal for compiler and language tooling, Yantra offers a fresh alternative to Bison and ANTLR.

Yantra always builds the full AST first, then walks it top-down in a separate pass, so a parent rule's action can run before its children are visited.
  1. MichaelMoser123

    Good luck.

    I once knew how to fix shift/reduce reduce/reduce errors, but that was a long time ago.

    With recursive descent parser you need to check for left recursion, which is somewhat less tricky.

  2. mingodad

    For people interested on this topic I strongly recommend to also look at Ben Hanson https://github.com/BenHanson/parsertl17 and based on it I've created an online LALR(1) playground here https://mingodad.github.io/parsertl-playground/playground/ where you have around 350 non trivial. grammars to experiment (select one from the `Examples` dropdown and then click `Parse` to see a parse tree for the input in `Input`, it also generates EBNF to generate nice navigable railroad diagrams on https://www.bottlecaps.de/rr/ui .

  3. userbinator

    It's a little surprising to see new parser generators being written, long after the vast majority of compilers have already settled on recursive descent / precedence climbing (including https://news.ycombinator.com/item?id=49913192 , which is currently nearby on the front page.)

More from this day

2026-10-01