Related articles |
---|
Parsing fully context-free grammars lowell@coasttocoastresearch.com (Lowell Thomas) (2005-09-17) |
Re: Parsing fully context-free grammars haberg@math.su.se (2005-09-18) |
Re: Parsing fully context-free grammars lowell@coasttocoastresearch.com (Lowell Thomas) (2005-09-22) |
Re: Parsing fully context-free grammars haberg@math.su.se (2005-09-23) |
Re: Parsing fully context-free grammars paul@parsetec.com (Paul Mann) (2005-10-02) |
Re: Parsing fully context-free grammars haberg@math.su.se (2005-10-02) |
Re: Parsing fully context-free grammars drikosv@otenet.gr (Evangelos Drikos) (2005-10-03) |
Re: Parsing fully context-free grammars paul@parsetec.com (Paul Mann) (2005-10-04) |
Re: Parsing fully context-free grammars hannah@schlund.de (2005-10-06) |
Re: Parsing fully context-free grammars drikosv@otenet.gr (Evangelos Drikos) (2005-10-07) |
[1 later articles] |
From: | haberg@math.su.se (Hans Aberg) |
Newsgroups: | comp.compilers |
Date: | 23 Sep 2005 15:58:40 -0400 |
Organization: | Mathematics |
References: | 05-09-090 |
Keywords: | parse |
Posted-Date: | 23 Sep 2005 15:58:40 EDT |
"Lowell Thomas" <lowell@coasttocoastresearch.com> wrote:
> Well, in particular, I'm looking at the two parse trees in Fig. 4.6,
> pg. 175 of the Dragon Book. If you just read the translation from the
> leaves of the trees, the first gives
>
> if(expr) then {if(expr) then {stmt} else {stmt}}
>
> the second gives
>
> if(expr) then {if(expr) then {stmt}} else {stmt}
>
> APG actually generates the first tree. But during a depth-first
> traversal of that tree, using different stack push/pop mechanisms at
> the recursive "stmt" nodes, it's not hard to match the "else" either
> of the two "then"s, effectively emulating the second tree during a
> depth-first traversal of the first.
When writing a compiler, one needs to have the parse tree built according
to the grammar specification, due to the stuff put into the actions of the
rules. So therefore, I think one will have little use for a parser
generator that cannot build the proper parse trees. But this is not
intended as an evaluation of your ideas.
--
Hans Aberg
Return to the
comp.compilers page.
Search the
comp.compilers archives again.