|Method for state reduction in LALR(1) parsers? email@example.com (firstname.lastname@example.org) (2008-02-28)|
|Re: Method for state reduction in LALR(1) parsers? email@example.com (Paul B Mann) (2008-02-27)|
|From:||"Paul B Mann" <firstname.lastname@example.org>|
|Date:||Wed, 27 Feb 2008 23:53:21 -0600|
|Posted-Date:||28 Feb 2008 10:44:12 EST|
> I'm searching for a way to minimize the states of a LALR(1) parser.
> My thought of minimizing the states of a LALR(1) parser has been: What
> if the parser performs a shift and a reduce in one single step?
This is well documented in the book, "Compiler Construction" by Goos and
Waite, published about 1985, by Springer Verlag.
This is the technique used in the LR parser generator, LRGen at
The book says that by introducing SHIFT-REDUCE actions, you can
eliminate about 30% of the states. This will work fine for all states
that have only one reduce action. States that have more than one
reduce action, cannot be removed, however.
The GOTO action is usually a positive number in the parser tables and the
SHIFT-REDUCE number is a negative number. It does increase the
speed of the parsers, while reducing the size of the tables.
Paul B Mann
Return to the
Search the comp.compilers archives again.