CS308 Compiler Theory CS308 Compiler Theory
CS308 Compiler Theor y CS308 Compiler Theory 1
Grading Homework Pop-quizzes 10% ·Programming assignments:20%↓ 。Final exam:70%↑ CS308 Compiler Theory 2
Grading • Homework + Pop-quizzes : 10% • Programming assignments : 20% ↓ • Final exam : 70% ↑ CS308 Compiler Theory 2
Course Outline Introduction to Compiling A Simple Syntax-Directed Translator ·Lexical Analysis ·Syntax Analysis Context Free Grammars Top-Down Parsing,LL Parsing Bottom-Up Parsing,LR Parsing Syntax-Directed Translation Attribute Definitions Evaluation of Attribute Definitions Semantic Analysis,Type Checking Run-Time Organization Intermediate Code Generation ·Code Generation Machine-Independent Optimizations CS308 Compiler Theory 3
Course Outline • Introduction to Compiling • A Simple Syntax-Directed Translator • Lexical Analysis • Syntax Analysis – Context Free Grammars Context Free Grammars – Top-Down Parsing, LL Parsing – Bottom-Up Parsing, LR Parsing • S t yn ax-Di t d T l ti Directed Translation – Attribute Definitions – Evaluation of Attribute Definitions • Semantic Analysis, Type Checking • Run-Time Organization • Intermediate Code Generation Intermediate Code Generation • Code Generation • Machine-Independent Optimizations 3 p p CS308 Compiler Theory
Phases of A Compiler Source LexicalSyntax Semantic Intermediate Code Code Target Program AnalyzerAnalyzer Generator Optimizer GeneratorProgram Each phase transforms the source program from one representation into another representation. They communicate with error handlers. They communicate with the symbol table. CS308 Compiler Theory 4
Phases of A Compiler Lexical Analyzer Semantic Analyzer Syntax Analyzer Intermediate Code Generator Code Optimizer Code Generator Target Program Source Program • Each phase transforms the source program from one representation into another re presentation. • They communicate with error handlers. • They communicate with the symbol table. CS308 Compiler Theory 4
Lexical Analyzer Lexical Analyzer reads the source program character by character and returns the tokens of the source program. A token describes a pattern of characters having same meaning in the source program.(such as identifiers,operators,keywords,numbers, delimeters and so on) CS308 Compiler Theory 5
Lexical Analyzer • Lexical Analyzer reads the source program character by character and ret rns the returns the t ko ens of the so rce program of the source program. • A token describes a pattern of characters having same meaning in the source program. (such as identifiers, operators, keywords, numbers, source program. (such as identifiers, operators, keywords, numbers, delimeters and so on) CS308 Compiler Theory 5