Mar20 - CSE302: Compiler Design Instructor: Dr. Liang Cheng...

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

View Full Document Right Arrow Icon
CSE302: Compiler Design Instructor: Dr. Liang Cheng Department of Computer Science and Engineering Lehigh University March 20, 2007
Background image of page 1

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

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE302: Compiler Design 03/20/07 Outline ± Recap ± LR(0) parsing and SLR(1) parsing ± General/Canonical LR(1) parsing ± Lookahead LR(1) / LALR(1) parsing ± Summary and homework
Background image of page 2
Instructor: Dr. Liang Cheng CSE302: Compiler Design 03/20/07 LR Parsing: A Schematic View ± Bottom-up parsing ± Rightmost derivations and right-sentential forms Parsing stack Input buffer Actions $ InputString$ lookahead zero or one token, decide S/R ... ... $StartSymbol $ accept
Background image of page 3

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

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE302: Compiler Design 03/20/07 Finite Automata for Both LR(0) and SLR(1) Parsing ± Finite automata of parsing states ± LR(0) items are used to identify the parsing states ± A →α ± . α is an item (initial item) ± We may about to recognize A by A →α ± →α . is also an item (complete item) ± α may be a handle for reduction ± →βγ ± →β . γ , A . βγ , and A →βγ . are LR(0) items ± NFA construction ± Subset construction for NFA to DFA
Background image of page 4
Instructor: Dr. Liang Cheng CSE302: Compiler Design 03/20/07 LR(0) Parser NFA Construction X ± A →α .X β⎯ →α X. β ± Shift action if X is a terminal ε ± →α .X β⎯ . γ ± Reduction action if X is a non-terminal
Background image of page 5

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

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE302: Compiler Design 03/20/07 The LR(0) and SLR(1) Parsing Algorithms ± LR( 0 ) parsing ± If state s contains A →α .X β where X is a terminal, then shift and the state changes to s ’conta in ing A α X. β ± If state s contains A →γ ., then reduce by A →γ ( stack ops ) and the state changes to s’ containing B
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 19

Mar20 - CSE302: Compiler Design Instructor: Dr. Liang Cheng...

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

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