Related articles |
---|
Generating Code for Compound Conditional Expressions from an Abstract seescreen@gmail.com (2009-06-02) |
Re: Generating Code for Compound Conditional Expressions from an Abstr torbenm@pc-003.diku.dk (2009-06-03) |
Re: Generating Code for Compound Conditional Expressions from an Abstr gene.ressler@gmail.com (Gene) (2009-06-03) |
Re: Generating Code for Compound Conditional Expressions from an Abstr seescreen@gmail.com (SeeScreen) (2009-06-14) |
Re: Generating Code for Compound Conditional Expressions from an Abstr seescreen@gmail.com (SeeScreen) (2009-06-20) |
From: | SeeScreen <seescreen@gmail.com> |
Newsgroups: | comp.compilers |
Date: | Sat, 20 Jun 2009 08:52:06 -0700 (PDT) |
Organization: | Compilers Central |
References: | 09-06-011 09-06-022 09-06-050 |
Keywords: | code |
Posted-Date: | 21 Jun 2009 16:52:25 EDT |
On Jun 14, 1:22 pm, SeeScreen <seescr...@gmail.com> wrote:
> On Jun 3, 9:47 pm, Gene <gene.ress...@gmail.com> wrote:
>
> > On Jun 3, 12:42 am, seescr...@gmail.com wrote:
>
> > > Does anyone know of any links to any really good examples of:
> > > Generating Code for Compound Conditional Expressions from an Abstract
> > > Syntax Tree?
>
> > The Red Dragon Book (Aho Sethi and Ullman) does a nice job with this.
>
> Yes, the Red Dragon Book did prove to be an excellent source, this
> time after spending weeks trying to figure this out on my own and re-
> reading chapter eight yet another time, it was quite clear.
>
> Although section on compound conditional expressions (pages 500-503)
> provided a superb solution, it seems that I was able to improve upon
> the way to process control flow statements discussed on pages 504-506.
> I found no use what-so-ever for the nextlist construct, thus my
> solution was exactly this much simpler.
I see now why I was able to simplify the implementation removing the
nextlist construct. This construct is probably still required for a
single pass compiler.
Since I parsed all of the code into an Abstract Syntax Tree and
annotated this tree as code generation progressed the nextlist was not
needed. Also on pages 468-469 of the Red Dragon Book, the E.code
construct was not needed for this same reason.
After the code was parsed into an Abstract Syntax Tree, the code was
generated from a single function that was recursively called with the
YACC production number. The YACC production number formed the cases in
a large switch statement.
A very useful debugging function that I created was to output the
Abstract Syntax Tree to XML using a very simple function that was
recursively called. Then I could use the freeware "XML Viewer" to
examine the structure of the tree.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.