{
  "id": 11098938,
  "title": "Show HN: Yantra – an LALR(1) parser generator for C++",
  "url": "https://urgent.news/2026/10/01/show-hn-yantra-an-lalr-1-parser-generator-for-c",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-01T02:30:48.000Z",
  "source": {
    "name": "Hacker News",
    "slug": "hacker-news",
    "url": "https://github.com/TantrixAuto/yantra"
  },
  "original_language": "en",
  "account": "Yantra is a C++ compiler compiler and LALR(1) parser generator that offers a range of core features. The name Yantra, derived from Sanskrit, signifies a machine, specifically a state machine in this context. Building Yantra is straightforward, requiring only the C++ standard library and a CMake build process, resulting in the ycc executable located in the bin/ directory. To utilize Yantra, one must save a grammar file, such as hello.y, which generates hello.cpp and hello.log files. Compiling these files using any C++23 compiler produces a self-contained parser with its own main() function. The grammar example provided recognizes one or more whitespace-separated alphabetic words, with the -s option allowing direct input feeding to the parser, as opposed to -f for file input or -i for interactive console input. Unlike most parser generators, Yantra parses the entire input into an Abstract Syntax Tree (AST) first, then walks it top-down, calling semantic actions. This unique ordering enables the parent rule's action to execute before its children are visited. For instance, in the calc.y grammar file, the expression \"1 + 2 + 3\" is parsed left-associatively as (1 + 2) + 3, with the outer Adding node (root of the tree) printing first, followed by its left child (Number: 1) and right child (another Adding node with its own two children). This parsing process inherently builds an efficient AST without requiring extra AST classes or a separate walking pass, which would be necessary in hand-written recursive-descent or bottom-up parsers. For a comprehensive understanding of Yantra, it is recommended to refer to the Build Instructions and Tutorial, along with the known limitations. Additional resources include a GitHub repository (https://github.com/TantrixAuto/lingo) containing a standalone sample project that utilizes Yantra, a language server extension (https://github.com/rajware/yantra-language-server) for syntax highlighting in various IDEs, and the Yantra C++ parser generator itself, which provides lexer, parser, and AST generation in a single tool.",
  "summary": null,
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}