Re: Parsing techniques

jon@mauney.com
1 Dec 1996 22:52:42 -0500

          From comp.compilers

Related articles
Parsing techniques lex@prl.philips.nl (1993-05-04)
Re: Parsing techniques ipser@solomon.technet.sg (1993-05-07)
Re: Parsing techniques simonh@swidev.demon.co.uk (1993-05-08)
Parsing techniques kentr@rollinssoft.com (Kent Rollins) (1996-11-26)
Re: Parsing techniques scotts@metaware.com (Scott Stanchfield) (1996-12-01)
Re: Parsing techniques jon@mauney.com (1996-12-01)
Re: Parsing techniques miano@worldnet.att.net (1996-12-01)
Re: Parsing techniques jlilley@empathy.com (1996-12-01)
Re: Parsing techniques icedancer@ibm.net (1996-12-03)
Re: Parsing techniques house@usq.edu.au (Ron House) (1996-12-07)
Re: Parsing techniques grosch@cocolab.sub.com (1996-12-09)
Re: Parsing techniques parrt@MageLang.com (Terence Parr) (1996-12-09)
[2 later articles]
| List of all articles for this month |
From: jon@mauney.com
Newsgroups: comp.compilers
Date: 1 Dec 1996 22:52:42 -0500
Organization: Mauney Computer Consulting
References: 96-11-157
Keywords: parse, C++, LL(1), LALR

Kent Rollins <kentr@rollinssoft.com> writes:


>... Most of the literature I have read seems to imply that
>LL(k) grammars are only for small/simple languages and that LR
>grammars must be used for thicker languages like C++.
>... Can C++ successfully be parsed with an LL(k) grammar? If


Having written both LL and LR parser generators, and both LL and LR
parsers using those and several other tools, let me give my take:


If you're trying to actually get something accomplished, the quality
of the specific tool is more important than the theoretical properties
of the parsing algorithm. You want a generator that automates as much
grunt work as possible, while giving you flexibility at the same time.
There's a lot more to that than just computing state machnes and
follow sets.


Good parser generators go well beyond what the clean theoretical model
implies. The dangling-else construct of C is theoretically impossible
for LL parsers, but LL parser generators typically handle it anyway.
The correct LR grammar for C's if-then-else is a pain in the butt, but
LR generators accept the more convenient form and handle it properly.
I maintain that syntax error handling is far easier in LL, in theory,
but the real question is how well the tool does it, not how well the
published research articles do it. Ugly languages like C++ require so
many compromises that you will quickly forget what the parsing
algorithm is anyway.


If you want to parse C++, you'll get a lot farther starting with PCCTS
than with yacc.
--
Jon Mauney jon@mauney.com
Mauney Computer Consulting (919) 828-8053
Raleigh NC
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.