‹ BackHN Continuity

Thread

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

33 points · 17 comments · renjipanicker

  1. froh · · focus · HN ↗
    do you intend to add sth like python bindings, especially for the AST and walker classes?

    then Yantra would become great to parse well-known structured data from python at low-level speed.

    1. renjipanicker · · focus · HN ↗
      Not currently on a concrete roadmap, but the architecture was deliberately left open for this. The C++ code generator is literally named cpp_generator.cpp, not just generator.cpp, specifically leaving room for other backends later.

      One clarification on the "low-level speed from Python" part though: I think the more useful path there isn't a separate Python code-generator (which would mean Python itself doing the AST walking, probably giving up most of that speed), but Python bindings over the generated C++ classes, something like pybind11 or nanobind wrapping the AST and walker types. That gets you both: parse and walk at C++ speed, call it from Python. A true Python backend would be a different, slower thing aimed at a different use case (prototyping grammars without a C++ toolchain, say).

      No promises on timeline, but if there's real interest I'd probably go the bindings route first.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.