Related articles |
---|
Looking for a LL version of C grammar peakhunt@yahoo.com (2004-02-26) |
Re: Looking for a LL version of C grammar isaac@latveria.castledoom.org (Isaac) (2004-02-27) |
Re: Looking for a LL version of C grammar vbdis@aol.com (2004-03-02) |
Re: Looking for a LL version of C grammar k301x@yahoo.com (dtf) (2004-03-11) |
From: | vbdis@aol.com (VBDis) |
Newsgroups: | comp.compilers |
Date: | 2 Mar 2004 11:08:46 -0500 |
Organization: | AOL Bertelsmann Online GmbH & Co. KG http://www.germany.aol.com |
References: | 04-02-145 |
Keywords: | C, parse |
Posted-Date: | 02 Mar 2004 11:08:46 EST |
peakhunt@yahoo.com schreibt:
>So based on some internet search and dragon book, I tried to convert
>the LALR to LL using left recursion removal and left factoring with no
>avail. The situation became kind of nightmare due to , hmm..., you
>know, the first/follow problem and I'm not really sure this is the way
>to go.
Recently I've handcrafted an top-down parser for C, based on some
available informal grammars. It took about one day to implement the
parser, with much lookahead or backtracking so far. But it took much
more time to implement just the semantics for the declarations, and I
had to modify the grammar and the parser in some places, because some
header files contained strange aberrations even from the language
specification.
> (I'm not a compiler expert and am just doing this as my hobby.)
Perhaps you should play some time with CoCo/R or similar RDP
generator. It has helped me a lot in understanding how a grammar can
be translated into parser code. But I also found it a waste of time to
tweak grammars for some stupid parser generator, in detail for
languages like C, which turn out to be context sensitive at a second
glance. I'd rather accept some error messages from the parser
generator, and correct the created code in the indicated places
manually.
BTW, the source code of an alpha version of my C
scanner/preprocessor/parser is available from
http://members.aol.com/vbdis/WinScan0.zip
if you have use for Object Pascal (Delphi) code.
This project is still under construction, the parser currently only
accepts declarations and skips procedure definitions (compound
statments).
DoDi
Return to the
comp.compilers page.
Search the
comp.compilers archives again.