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

Info iconThis preview shows pages 1–14. 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 P.C. Rossin College of Engineering & Applied Science Lehigh University January 18, 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 01/18/07 Today’s Outline ± Recap ± A simple syntax-directed translator (Chapter 2) ± Introduction (Section 2.1) ± Syntax definition (Section 2.2) ± Parsing (Section 2.4) ± Summary and homework
Background image of page 2
Instructor: Dr. Liang Cheng CSE302: Compiler Design 01/18/07 Six Compilation Phases ± Lexical analysis ± Syntax analysis ± Semantic analysis ± Intermediate code generation ± Code optimization ± Code generation
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 01/18/07 Outline ± Recap ± A simple syntax-directed translator (Chapter 2) ± Introduction (Section 2.1) ± Syntax definition (Section 2.2) ± Parsing (Section 2.4) ± Summary and homework
Background image of page 4
Instructor: Dr. Liang Cheng CSE302: Compiler Design 01/18/07 Contents in Chapter 2 ± Illustrate some compiler techniques via developing a simple language translator coded in Java (Appendix A) ± Source language ± Target language: three-address code ± The front-end of a compiler
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 01/18/07 Six Compilation Phases ± Lexical analysis ± Syntax analysis ± Semantic analysis ± Intermediate code generation ± Code optimization ± Code generation
Background image of page 6
Instructor: Dr. Liang Cheng CSE302: Compiler Design 01/18/07 A Simplified Model of A Compiler Front End ± do i=i+1; while (a[i]>v); ± 1: i = i + 1 t1 = a[i] if t1>v goto 1
Background image of page 7

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 01/18/07 Outline ± Recap ± A simple syntax-directed translator (Chapter 2) ± Introduction (Section 2.1) ± Syntax definition (Section 2.2) ± Parsing (Section 2.4) ± Summary and homework
Background image of page 8
Instructor: Dr. Liang Cheng CSE302: Compiler Design 01/18/07 A Formal Method of Describing Syntax ± Backus-Naur Form (1959) ± For Algol 58 (John Backus, the Peter Naur) ± BNF is equivalent to context-free grammars ± Context-free grammars were developed by Noam Chomsky in mid-1950s to define a class of languages called context-free languages ± A BNF grammar defines a language ± Recognizer vs. generators ± A BNF grammar or description is a production- rule collection
Background image of page 9

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 01/18/07 BNF Rules ± A BNF rule defines an abstraction for syntactic structure <while_stmt> while ( <logic_expr> ) <stmt> ± Abstractions are used to represent classes of syntactic structures: they act like syntactic variables (also called nonterminal symbols ) ± Terminal symbols : lexemes and tokens
Background image of page 10
Instructor: Dr. Liang Cheng CSE302: Compiler Design 01/18/07 LHS & RHS of BNF Rules ± A rule has a left-hand side (LHS) and a right-hand side (RHS), and consists of terminal and/or nonterminal symbols ± An abstraction (or nonterminal symbol) can have more than one RHS <stmt> <single_stmt> | begin <stmt_list> end
Background image of page 11

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 01/18/07 BNF Functionality ± Describe grammars and derivations ± Describe lists of similar constructs ± Parse trees ± Powerful enough to avoid grammar ambiguity ± Operator precedence and associativity
Background image of page 12
Instructor: Dr. Liang Cheng
Background image of page 13

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

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

This note was uploaded on 08/06/2008 for the course CSE 302 taught by Professor Cheng during the Spring '07 term at Lehigh University .

Page1 / 37

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

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

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