040_Top_Down_Parsing_2

040_Top_Down_Parsing_2 - Top-Down Parsing, Part II...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Top-Down 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 eft-to-right 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

Page1 / 40

040_Top_Down_Parsing_2 - Top-Down Parsing, Part II...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online