[GoLUG] A tad bit pricey!

Hendrik Boom hendrik at topoi.pooq.com
Wed Dec 6 14:03:09 EST 2023


On Tue, Dec 05, 2023 at 11:59:42AM -0500, Steve Litt wrote:
> 
> If you're at all curious about lex/yacc or Flex/Bison parsers, in order
> to be able to learn anything at all you need to be at tomorrow night's
> meeting.

I was quite enthusiastic about LR(k) parsing in the early 70's,
when the technology was being developed.

I used it in my Algol 69 compiler.

But nowadays I prefer recursive-descent parsing, which in theory is
much less capable.

Why?

Because when you reach a place where the automaton-generated parser
doesn't have enough lookahead you can easily defer to hand-coded tricks
that bypss the problem.  This turns out to be much less easy with
LR(k) grammars.

And it's quite easy to hand-code a recursive-descent parser.

And if you machine-generate a recursive-descent parser, the grammar
can often contain actual code here and there instead of terminals
or nonterminals.  That makes it easy to express stuff that doesn't
fit the grammar formalism.

-- hendrik



More information about the GoLUG mailing list