# States Creation

## "Agnes Lim" <kidlim@yahoo.com>24 Mar 2002 00:16:56 -0500

From comp.compilers

Related articles
States Creation kidlim@yahoo.com (Agnes Lim) (2002-03-24)
Re: States Creation kaarthik@cisco.com (Kaarthik) (2002-03-31)
Re: States Creation mwdeeds@yahoo.com (2002-03-31)
| List of all articles for this month |

 From: "Agnes Lim" Newsgroups: comp.compilers Date: 24 Mar 2002 00:16:56 -0500 Organization: Mailgate.ORG Server - http://www.Mailgate.ORG Keywords: parse, question Posted-Date: 24 Mar 2002 00:16:56 EST

Hi,

I am writing a LR(0) Parser and needs some advise on the creation of the
states from a given grammar.

Below is an example taken from the 'Dragon Book'. Can someone
explain how the states are being derived. I have tried to follow thru
the algorithm in the example but was unable to derived the second set of
Items I8 and I9.

Thanks.
---------------------------------------------------------------------
Example 1 :
Given Grammar :
E -> E + T
E -> T
T -> T * F
T -> F
F -> (E)
F -> id

Items created are as follows :
I0 :
E' -> .E
E -> .E+T
E -> .T
T -> .T*F
T -> .F
F -> .(E)
F -> .id

I1 :
E' -> E.
E -> E.+T

I2 :
E -> T.
T -> T.*F

I3 :
T -> F.

I4 :
F -> (.E)
E -> .E+T
E -> .T
T -> .T*F
T -> .F
F -> .(E)
F -> .id

I5 :
F -> id.

I6 :
E -> E+.T
T -> .T*F
T -> .F
F -> .(E)
F -> .id

I7 :
T -> T*.F
F -> .(E)
F -> .id

I8 :
F -> (E.)
E -> E.+T

I9 :
E -> E+T.
T -> T.*F

I10 :
T -> T*F.

I11 :
F -> (E).

Post a followup to this message