[Instructions] [Search] [Current] [Syllabus] [Handouts] [Outlines] [Assignments]
Held Monday, September 28, 1998
Handouts
Notes
A ::= A a A ::= b
S' ::= S $
S' ::= . S $
S
and the end-of-input symbol''
S' ::= . E $ E ::= . E + T E ::= . E - T E ::= . T
S' ::= . E $ E ::= . E + T E ::= . E - T E ::= . T T ::= . T mulop F T ::= . F F ::= . id F ::= . num F ::= . ( E )
S' ::= E . $ E ::= E . + T E ::= E . - T
E ::= E + . T
T, so we need to fill in
all the items that say ``ready to see a T''
E ::= E + . T T ::= . T mulop F T ::= . F F ::= . id F ::= . num F ::= . ( E )
E ::= E + T . T ::= T . mulop F
E. The
second suggests that we may be in the midst of a T.
How do we decide which it is? By context (and a little lookahead
in some cases).
closure
closure(State S)
repeat
for each item, N ::= alpha . M beta in S
for each production M ::= gamma
add M ::= . gamma to S
end for each production
end for each item
until no changes are made to S
return S
end closure
goto
goto(State S, Symbol s)
NewS = {}
for each item N ::= alpha . s beta in S
NewS = NewS union { N ::= alpha s . beta }
end for
return closure(NewS)
end goto
S0 = { S' ::= . S $ }
S0 = closure(S0);
while there are unmarked states
pick a state, S
mark S
for each symbol, s, add state goto(S,s) with edge labelled s
end while
History
Back to Predictive parsing, continued. On to Semantic actions.
[Instructions] [Search] [Current] [Syllabus] [Handouts] [Outlines] [Assignments]
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Wed Sep 30 09:09:58 1998.
This page generated on Wed Sep 30 11:30:10 1998 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu