|Advice on Writing a Parser Generator firstname.lastname@example.org (Stefanie Scherzinger) (2003-08-10)|
|Re: Advice on Writing a Parser Generator email@example.com (Thant Tessman) (2003-08-10)|
|Re: Advice on Writing a Parser Generator firstname.lastname@example.org (Andi Kleen) (2003-08-10)|
|Re: Advice on Writing a Parser Generator email@example.com (Chris Dollin) (2003-08-15)|
|Re: Advice on Writing a Parser Generator firstname.lastname@example.org (Mykola Rabchevskiy) (2003-08-15)|
|Re: Advice on Writing a Parser Generator email@example.com (Rob Arthan) (2003-08-15)|
|Re: Advice on Writing a Parser Generator firstname.lastname@example.org (2003-08-15)|
|Re: Advice on Writing a Parser Generator email@example.com (Joachim Durchholz) (2003-08-20)|
|Re: Advice on Writing a Parser Generator cfc@shell01.TheWorld.com (Chris F Clark) (2003-08-23)|
|Re: Advice on Writing a Parser Generator firstname.lastname@example.org (Lex Spoon) (2003-08-23)|
|Re: Advice on Writing a Parser Generator email@example.com (2003-08-23)|
|Re: Advice on Writing a Parser Generator firstname.lastname@example.org (Thomas Skora) (2003-09-04)|
|[1 later articles]|
|From:||Rob Arthan <email@example.com>|
|Date:||15 Aug 2003 23:43:14 -0400|
|Organization:||Lemma 1 Ltd.|
|Keywords:||parse, LALR, bibliography, comment|
|Posted-Date:||15 Aug 2003 23:43:14 EDT|
Thant Tessman wrote:
> Stefanie Scherzinger wrote:
>> I plan to write a parser generator, very similar to YACC, for Java.
>> I was hoping to find some literature and advice on how to best
>> approach this.
> People will usually recommend the Dragon book, but that was always a
> tough read for me.
The Dragon book also makes the theory and practice of LALR(1) parser
generators seem much harder than it is, because it was written before
some valuable later research that produced better and more
understandable algorithms. The simplest and best approach to LALR(1)
parser generation, in my view, is that of Bermudez and Logothetis,
author="Manuel E. Bermudez and George Logothetis",
title="Simple Computation of LALR(1) Lookahead Sets",
journal="Information Processing Letters",
- they cleverly reuse the SLR(1) algorithm on a variant grammar to carry out
the LALR(1) look-ahead calculations.
> However, I was able to follow "Modern Compiler
> Implementation in ML" well enough to build an SLR parser generator (in
> C++ oddly enough). I haven't read it, but there's a version for Java:
Discovering the Bermudez-Logothetis paper last year made me realise
that the LALR(1) approach is worth the extra effort. The parser
generator called SLRP that comes as part of the OpenProofPower
development tools is an example implementation (see
http://www.lemma-one.com/ProofPower). It is written in Standard ML and
generates Standard ML code.
The output of SLRP is essentially just the parsing tables, so it would
be easy to adapt to other languages. I don't think that the
performance considerations of the 1970s and 1980s that caused parser
generators like yacc to produce a mixture of code and data rather than
just tables to feed into a a generic parsing function apply these days
(or do they?).
[Yacc produces parse tables, too. What looks like a mix of code and data
is the canned parser code + parse tables + a big switch in which it embeds
the action code to run on reductions. This is a good thing; otherwise
matching up the rule numbers with the action code is an error-prone
pain in the neck.
You can pull out the parse tables if you want, but there's usually no point.
Return to the
Search the comp.compilers archives again.