Marpa v. Parse::RecDescent: a rematch

[ This is cross-posted from the Ocean of Awareness blog. ]

In a recent post, I looked at an unusual language which serializes arrays and strings, using a mixture of counts and parentheses. Here is an example:

A2(A2(S3(Hey)S13(Hello, World!))S5(Ciao!))

The l…

Mixing procedural and declarative parsing gracefully

[ This is cross-posted from the Ocean of Awareness blog. ]

A declarative parser takes a description of your language and parses it for you. On the face of it, this sounds like the way you'd want to go, and Marpa offers that possibility -- it generates a parser from anything you can write in BNF and, if the parser is in one of the classes currently in practical use, that parse…

The Design of Four

[ This is cross-posted from the Ocean of Awareness blog. ]

In the Perl world at this moment, a lot is being said about the consequences of bad design. And it is useful to study design failures. But the exercise will come to nothing without a road to good design. This post will point out four Perl-centric projects that are worth study as models of good design.

The projects are ack, cpanm, local::lib and perlbrew. Each of these is perfect in the older sense of "having all that is requisite to its nature and kind" (Webster's 1828). If you are into Perl, they are all widely useful, and looking at them as a potential or an actual user is the best way to gain an appreciation of the art behind them.

Why Marpa works: table parsing

Marpa works very differently from the parsers in wide use today. Marpa is a table parser. And Marpa is unusual among table parsers -- its focus is on speed.

The currently favored parsers use stacks, in some cases together with a state machine. These have the advantage that it is easy to see how they can be made to run fast. They…

Is Earley parsing fast enough?

done in production compilers for existing programming languages? The answer is, practically none." -- Jay Earley's Ph.D thesis, p. 122.

[ This is cross posted from its home at the Ocean of Awareness blog.

In the above quote, the inventor of the Earley parsing algorithm poses a question. Is his algorithm fast enough for a production compiler? His answer …