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
This document was uploaded on 07/18/2011.
 Spring '09

Click to edit the document details