LR(1) Confusion...

seldilotr@hotmail.com (EldiLoTR)
21 Feb 2003 00:45:37 -0500

          From comp.compilers

Related articles
LR(1) Confusion... seldilotr@hotmail.com (2003-02-21)
| List of all articles for this month |

From: seldilotr@hotmail.com (EldiLoTR)
Newsgroups: comp.compilers
Date: 21 Feb 2003 00:45:37 -0500
Organization: http://groups.google.com/
Keywords: LR(1), parse, question
Posted-Date: 21 Feb 2003 00:45:37 EST

Hi All,


I'm working on an LR(1) parser generator and I have several questions.


1. Do you know of any good C/C++ LR(1) parser generator out there?
I've scanned the net but couldn't find any. Also, a simple LR(1)
binary would also be good for testing my own source.


2. I have an example which seems very odd; The book does have several
mistakes so I presume that this is yet another one, but since I don't
have too MANY examples, I can't really be sure that my implementation
is correct. The example goes like that -


S->E$
E->T+E
E->T
E->x
T->x
------------
Closure(I0) comes out (in the example) like that:
S->.E$ ?
E->.T+E $
E->.T $
E->.x +
E->.x $


And in my application it comes out like that:
S->.E$ $
E->.T+E $
E->.T $
E->.x $
T->.x +
T->.x $


Now, I passed on the algorithm and I don't understand how can it be
that the example doesn't contain, for example {T->.x,+}. As I
understood it, the algorithm carries on with its search until no more
changes occur - and if you take E->.T+E and test it, you get Beta as
"+", of which First("+")="+" since it's terminal, and there you have
the (T->.x,+).


Can someone please explain?


Thanks a lot!


Post a followup to this message

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