Re: Trouble understanding LL(k) vs. LALR(k) etc.

Clint Olsen <clint@0lsen.net>
15 Apr 2004 20:22:38 -0400

          From comp.compilers

Related articles
[3 earlier articles]
Re: Trouble understanding LL(k) vs. LALR(k) etc. cdc@maxnet.co.nz (Carl Cerecke) (2004-03-19)
Re: Trouble understanding LL(k) vs. LALR(k) etc. derkgwen@HotPOP.com (Derk Gwen) (2004-03-26)
Re: Trouble understanding LL(k) vs. LALR(k) etc. cfc@shell01.TheWorld.com (Chris F Clark) (2004-03-26)
Re: Trouble understanding LL(k) vs. LALR(k) etc. f40mczf02@sneakemail.com (Karsten Nyblad) (2004-04-03)
Re: Trouble understanding LL(k) vs. LALR(k) etc. clint@0lsen.net (Clint Olsen) (2004-04-14)
Re: Trouble understanding LL(k) vs. LALR(k) etc. cfc@shell01.TheWorld.com (Chris F Clark) (2004-04-15)
Re: Trouble understanding LL(k) vs. LALR(k) etc. clint@0lsen.net (Clint Olsen) (2004-04-15)
Re: Trouble understanding LL(k) vs. LALR(k) etc. cfc@shell01.TheWorld.com (Chris F Clark) (2004-04-21)
| List of all articles for this month |

From: Clint Olsen <clint@0lsen.net>
Newsgroups: comp.compilers
Date: 15 Apr 2004 20:22:38 -0400
Organization: Comcast Online
References: 04-03-042 04-03-057 04-03-072 04-03-091 04-04-029 04-04-049
Keywords: parse
Posted-Date: 15 Apr 2004 20:22:38 EDT

On 2004-04-15, Chris F Clark <cfc@shell01.TheWorld.com> wrote:
>
> // grammar (fragment)
> a_comma_list: "a" ("," "a")*;
> { int i; for (i = 0; i < yy_psr_last(); ++i ) {
> cout << yy_psr_ref(i).yy_type();
> } }
>
> // sample input
> a,a,a
>
> The yy_psr_last() function returns the length (number of tokens) of
> the text that was matched, 5 for the sample input (3 a's and 2
> commas). The yy_psr_ref(i) functions returns the tokens in sequence,
> for the sample input "a" "," "a" "," "a" and the yy_type() function
> returns the type number assigned for that token, perhaps 1 for "a" and
> 2 for ",". As a result, the example would print 1 2 1 2 1 for the
> sample input.


Chris:


Thanks for the detailed explanation. I did have a question about the
stack though. It seems in this case your stack would grow to
accomodate the entire match - similar to using right recursion in
traditional yacc. Do you have issues with extremely deep stack growth
using this technique? Imagine a case where you could have hundreds of
identifiers separated by commas. You'd have to snarf all of that
before calling the rule.


I thought your explanation was very helpful and I think the idea of merging
the DFA and DPDA to be very interesting.


Thanks,


-Clint


Post a followup to this message

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