This preview shows pages 1–8. 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 Document
Unformatted text preview: TopDown Parsing, Part II Announcements Programming Project 1 due Friday, 11:59PM Office hours every day until then. Submission instructions will be emailed out tonight. Where We Are Lexical Analysis Syntax Analysis Semantic Analysis IR Generation IR Optimization Code Generation Optimization Source Code Machine Code Review of LL(1) L efttoright scan, L eftmost derivation, 1 token lookahead. Predict which production to use based on the current nonterminal and the lookahead token. Build an LL(1) parse table to make these lookups fast and streamlined. Review of FIRST Sets The set FIRST(A) is defined as the set of terminals that could be at the start of a string ultimately derived from A. Formally: FIRST(A) = { t  A * t v } Can compute iteratively: Set FIRST(A) = { t  A t v } Keep computing FIRST(A) = FIRST(A) FIRST(B) for all productions A w B v , where w is a string of nonterminals that can derive . Review of FOLLOW Sets The set FOLLOW(A) is defined as the set of terminals that could potentially follow a string produced from nonterminal A. Formally: FOLLOW(A) = { t  B * u At v } Can also be computed iteratively: Initially, set FOLLOW(A) = FIRST( w ) {} for all rules C v A w . Keep computing FOLLOW(A) = FOLLOW(A) FOLLOW(B) for all rules B v A w where w is or can derive . LL(1) Table Construction Compute FIRST(A) and FOLLOW(A) for all nonterminals A. For each rule A w and for each terminal t in FIRST( w ), set T[A, t] = w. Note that is not a terminal!...
View Full
Document
 Spring '09

Click to edit the document details