Back to Shift-Reduce Parsing. On to Pause for Breath.
Held Monday, February 26, 2001
Summary
Today we consider how to build shift-reduce automata and the tables that represent them..
Overview
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
Follow of the left-hand side of the reduction.
Monday, 22 January 2001
Friday, 23 February 2001
Back to Shift-Reduce Parsing. On to Pause for Breath.
[Current]
[Discussions]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Primary
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Quizzes]
[Readings]
[Reference]
Sets
[Blackboard]
[98F]
Links
Disclaimer: I usually create these pages on the fly. This means that they are rarely proofread and may contain bad grammar and incorrect details. It also means that I may update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.
This page was generated by Siteweaver on Mon Apr 30 10:51:57 2001.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2001S/outline.16.html.
You may validate
this page's HTML.
The source was last modified Mon Feb 26 10:16:02 2001.