This preview shows pages 1–17. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: BottomUp Parsing II Announcements Programming Project 1 due tonight at 11:59PM. Written Assignment 1 due next Wednesday, 5:00PM. If you need help: Hrysoula will be holding OH from 1:00 3:00 today in Gates 24A. Feel free to ask on www.piazzza.com Or email the staff directly at cs143sum1011staff@lists.stanford.edu . Submission instructions on course website. Programming Project 2 out, due Wednesday, July 13 at 11:59PM. Where We Are Lexical Analysis Syntax Analysis Semantic Analysis IR Generation IR Optimization Code Generation Optimization Source Code Machine Code Recap from Last Time A lefttoright, bottomup parse is a rightmost derivation traced in reverse . A handle is a substring of a sentential form that can be reduced without getting stuck. Bottomup parsing is often done as shift/reduce parsing: Split the text to parse into two groups. Shift : Push a new token atop the stack. Reduce : Update the top of the stack by applying a reduction. Question: How do we find the handle? Viable Prefixes A viable prefix is a string w such that, for some v , w  v is a legal configuration in a shift/reduce parser. In other words, a viable prefix is a string of terminals and nonterminals, that does not extend past a handle, that can be completed with terminals into a sentential form. Critical Fact The set of viable prefixes for any grammar is a regular language . Critical Fact The set of viable prefixes for any grammar is a regular language . This is a nontrivial result! Tracking our Position in Productions S E $ E T E E + T T int T ( E ) int + int * int $ + int ) ( int + int Tracking our Position in Productions S E $ E T E E + T T int T ( E ) int + int * int $ + int ) ( int + int S E $ Tracking our Position in Productions S E $ E T E E + T T int T ( E ) int + int * int $ + int ) ( int + int S E $ E E + T Tracking our Position in Productions S E $ E T E E + T T int T ( E ) int + int * int $ + int ) ( int + int S E $ E E + T E T Tracking our Position in Productions S E $ E T E E + T T int T ( E ) int + int * int $ + int ) ( int + int S E $ E E + T E T T int Tracking our Position in Productions S E $ E T E E + T T int T ( E ) int + int * int $ + int ) ( int + int S E $ E E + T E T T int Tracking our Position in Productions S E $ E T E E + T T int T ( E ) int + int * int $ + int ) ( int + int S E $ E E + T E T T int Tracking our Position in Productions S E $ E T E E + T T int T ( E ) int + int * int $ + T ) ( int + int S E $ E E + T E T T int Tracking our Position in Productions S E $ E T E E + T T int T ( E ) int + int * int $ + T ) ( int + int S E $ E E + T E T Tracking our Position in Productions...
View
Full
Document
 Spring '09

Click to edit the document details