News for hackers. Stuff that matters.

renjipanicker

Re:Show HN: Yantra – an LALR(1) parser generator for C++ on Thursday October 01, 2026 @01:09AM (#49917952)
Mostly still true, yeah. A few tools have made real progress on error tolerance, continuing past a mistake rather than just stopping, tree-sitter is probably the best example, it's explicitly built to produce a best-effort tree from broken input, which is why it's good for editors. ANTLR also has configurable recovery strategies, single-token insertion/deletion heuristics and the like.

But "tolerant" isn't the same as "as good as hand-written." A hand-rolled recursive descent parser can say something like "missing semicolon after return statement" because the code knows exactly what construct it's in.

A generated parser's error is usually derived mechanically from the state machine, "expected one of: X, Y, Z, got W", which is correct but generic. This is what Yantra does at the moment. Closing that specific gap would mostly require hand-authored, context-specific messages layered on top. But its a good problem to solve.

For yantra specifically, it doesn't have error recovery at all yet. A syntax or lexer error just stops parsing at that point, no resynchronization, no continuing to find more errors in one pass. It's a known, documented gap, not something I'd claim is solved. For the kind of smaller or evolving DSLs this is aimed at, that's probably an acceptable tradeoff, but it does exist as a limitation.

Re:Show HN: Yantra – an LALR(1) parser generator for C++ on Thursday October 01, 2026 @01:02AM (#49917922)
Thanks, I really appreciate that. The README's Quick Start should get you to a working parser in a couple minutes, and I'm around if you need any assistance.
Re:Show HN: Yantra – an LALR(1) parser generator for C++ on Thursday October 01, 2026 @12:25AM (#49917721)
Fair and true. Most production compilers (Clang, rustc, Go) have moved to hand-written recursive descent, largely for error messages and debuggability: a hand-rolled parser can say exactly what went wrong and try to recover, a generated one is working from a state table.

One thing worth separating out though: recursive descent is already top-down, so it gets "build the tree, then decide what to do with it" for free, the same way ANTLR's LL(*) does. The intresting part of what I built is that it's getting that capability while keeping LALR's bottom-up table-driven parsing.

Where a grammar-first tool like this is more useful is smaller or evolving DSLs, where you want the grammar as a readable, declarative spec with automatic conflict detection instead of hand-tuned lookahead logic, and cases like generating multiple outputs (e.g. C++ and Java) from one grammar, which is awkward to bolt onto a hand-rolled parser after the fact.

Re:Show HN: Yantra – an LALR(1) parser generator for C++ on Thursday October 01, 2026 @12:18AM (#49917679)
Right, mid-rule actions genuinely let you shuttle state into a child before it's parsed, so it's not nothing.

But as you said, it's still one linear left-to-right pass. Appreciate you drawing the line precisely.

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

https://github.com/TantrixAuto/yantra

Yantra is a C++ parser generator: lexer, parser, and AST walker all generated from one tool. It builds the whole AST first, then walks it.Most LALR parser generators (Yacc, Bison, Lemon) run your semantic actions during parsing, as each rule reduces, bottom-up.That means at the time a rule's action runs, you don't yet know what its parent looks like. This pushes a lot of grammars toward...

( Read More... | 16 comments | 7 points | on HN )
Re:Is C/C++ worth it? on Tuesday July 24, 2012 @03:02PM (#4287368)
While most of these discussions tend to focus on performance benchmarks as the primary criteria, there is another factor to consider.

To a large extent, it depends on the target platform. If you developing an application to work across the widest possible range of desktop and mobile platforms, C++ is your best bet.

Using C++, you can have a single code base that can be compiled for Windows, OSX, Linux, iOS, Android and WinMo. There is no other language that gives you that.

The UI code is not portable in any case, but that would be a common problem regardless of language.