Show HN: Yantra – an LALR(1) parser generator for C++
Thread
Loading the complete thread in the background. This saved snapshot is available now. Refresh
Unofficial Hacker News client; not affiliated with Y Combinator.
Show HN: Yantra – an LALR(1) parser generator for C++
Loading the complete thread in the background. This saved snapshot is available now. Refresh
Unofficial Hacker News client; not affiliated with Y Combinator.
kazinator · · focus · HN ↗
Of course, it's not the same as having the parse tree all done from a previous pass and just walking it to do semantics.
renjipanicker · · focus · HN ↗
[dead]
userbinator · · focus · HN ↗
renjipanicker · · focus · HN ↗
[dead]
traes · · focus · HN ↗
renjipanicker · · focus · HN ↗
[dead]
Calavar · · focus · HN ↗
> 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.
You are not describing the difference between hand rolled and generated but top down (LL) vs. bottom up (LR).
Bottom up parsers can parse a larger set of languages than top down parsers, but the tradeoff is you don't know what you are parsing until you successfully reduce the rule (unlike top down parsers). This is why errors in bottom up parsers often lack additional context like "after return statement" and can only give a list of which alternative symbols would have been valid.
There may be a some confusion here because hand-written recursive decent parsers are generally top down while the most popular parser generators (yacc, bison) are bottom up. However top down parser generators do also exists (ANTLR, Coco/R). ANTLR in particular gives pretty decent error messages out of the box.
renjipanicker · · focus · HN ↗
[dead]
ahmedezat_katte · · focus · HN ↗
[dead]
kazinator · · focus · HN ↗
If we have a compiler for language X in language X, and don't use any tools such as a parser or lexer generator, then there is nothing but code in X in the project, and that makes the developer of language X feel like they have earned major brownie points ... err, I mean, ... that they have kept their project free of cumbersome dependencies.
If language X is a one-implementation invention, then the tooling won't exist which hits these checkboxes: (1) is written in X; (2) generates code for X. By the time language X is mature enough that its ecosystem has something like that, it is long past the point where it would make sense to introduce it into its one and only implementation. There would have to be interest in writing another implementation.
E.g. the first C compilers would never have used Yacc.
Among languages that have one implementation, and that use parser generators, we will almost always see that another language is used for bootstrapping and the generator is for that language.
For some designers, that is a bruise to the ego, or else an unappetizing dependency. Even if they are boostrapping with another language, they are thinking forward to a future release where they will ditch that: they will rewrite parts that are in the boostrapping language in the new language to make it self-hosting.
If you use tooling like parser generation, which is in the ecosystem of, and oriented toward, the to-be-jettisoned-one-day boostrapping language, that throws a barrier in the path toward self-hosting. So you tend not to do it.
Like if you are boostrapping with C, and have it in the back of your mind to get rid of it, do you want to be bringing in a complicated tool with its own input language, which generates C? You think twice and are more likely to go ahead if you've resigned yourself to sticking with the C dependency.
froh · · focus · HN ↗
this is extra helpful if the parser generator also generates intuitive language bindings to, e.g. python or TS.
fithisux · · focus · HN ↗
renjipanicker · · focus · HN ↗
mingodad · · focus · HN ↗
renjipanicker · · focus · HN ↗
[dead]
signa11 · · focus · HN ↗
froh · · focus · HN ↗
then Yantra would become great to parse well-known structured data from python at low-level speed.
renjipanicker · · focus · HN ↗
[dead]
MichaelMoser123 · · focus · HN ↗
renjipanicker · · focus · HN ↗
[dead]
sxzygz · · focus · HN ↗
At least I think that's the case. Clarification appreciated.
renjipanicker · · focus · HN ↗
[dead]