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

Info icon This 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
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right 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
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
Image of page 5

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

View Full Document Right 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
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
Image of page 7

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

View Full Document Right 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
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
Image of page 9

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

View Full Document Right 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
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
Image of page 11

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

View Full Document Right 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
Image of page 12
Instructor: Dr. Liang Cheng
Image of page 13

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern