Conartist6 clarifies BABLR as push parser with LR mechanics
8 Nov 1 8:51 PM · 10d ago · 1 post · 2 comments · 2 sources · development 8 of 8
A Lobsters commenter clarifies that BABLR is actually a push parser held by grammar control, with LR semantics and special shift instruction handling for infix grammars, not a Pratt parser.
Vini Psmaker Blog post author, compiler developerDouglas Crockford Parser theorist (cited)
The whole story postscomments the bright band is this development · numbered dots are the others · click one to jump
Reported in the same hours no headline names this development itself — these 1 claim were published in its stretch
-
1 outlet Pratt parsing is a black box
first by HN Frontpage, 8d ago
What people said 9 voices · verbatim
-
> Is it a pratt parser? No. Briefly skimming that file (I spent a few minutes trying to chase definitions across repos before I gave up), it _looks_ like a conventional recursive-descent pull parser, where pulling is implemented via generators. You could also be using the generators for backtracking but I don't see any evidence of that in this…
-
Tangential - on the 'use [] instead of <>' advice that you referenced in the post, I wish more languages would experiment with making types first class values that just get passed in regular () braces instead.With erased static types, you can do arbitrary operations on types-as-values at compile time and just compile the static result into the…
-
It's actually a push parser though! The thread of control is held by the grammar not the core. Wherever you see `eatMatch` parsing can backtrack, but otherwise it's LR. It uses a special shift instruction to handle infix grammars.
-
Is this the same algorithm commonly known as "recursive descent" parsing and one of the oldest parsing algorithms? The array index example is just recursive descent and the expression parsing is recursive descent with abstracted operators instead of a parsing function per precedence level.GCC used to use a type of parser generator but switched to…
-
I've written a few Pratt parsers in my time. You don't need a lexer and you can have more parser states than are implied by 'nud' and 'led'. They can be incredibly extensible. For example, if you can parse the expression "{a:1, b:2}" then you might naturally have an Expr state (nud), a Between state (led) and a DictKey state; that might initially…
-
I'd like to see a bit more about how compares to peg or something like ohm/ometa - am I correct assuming you pretty much give up the benefits of a readable grammar as documentation?Maybe I just need to see something super simple like a calculator with expressions side by side to grasp the trade-off?
-
Author here.I was using Pratt parsing for almost a year in a macro-heavy language that I've been developing before finally sitting down on my chair to write my thoughts on Pratt parsing. Code is closed right now because I don't want LLMs training on my code before 0.1, but I'll open source it again later.Happy to answer questions.
-
"Pratt can't parse statements" - can't you treat ';' as an operator whose meaning is "then"? You can then read "DOTHIS(); DOTHAT()" as an expression.
-
> Traditional parsing techniques register semantic actions to production rules.Are there any professional slop interpreters who can explain what this means?
All 8 developments of Vini Psmaker argues Pratt parsing tutorials miss the point →
LobstersHacker NewsMastodonNewswires