Concordia University Department of Computer Science and Software Engineering Click to edit Master title style COMPILER DESIGN Review Joey Paquet, 2000-2015.

Slides:



Advertisements
Similar presentations
Joey Paquet, 2000, 2002, 2008, Lecture 7 Bottom-Up Parsing II.
Advertisements

Chap. 5, Top-Down Parsing J. H. Wang Mar. 29, 2011.
Mooly Sagiv and Roman Manevich School of Computer Science
Semantic analysis Parsing only verifies that the program consists of tokens arranged in a syntactically-valid combination, we now move on to semantic analysis,
Introduction The compilation approach uses a program called a compiler, which translates programs written in a high-level programming language into machine.
9/27/2006Prof. Hilfinger, Lecture 141 Syntax-Directed Translation Lecture 14 (adapted from slides by R. Bodik)
1 Semantic Processing. 2 Contents Introduction Introduction A Simple Compiler A Simple Compiler Scanning – Theory and Practice Scanning – Theory and Practice.
Slide1 Chapter 4 Lexical and Syntax Analysis. slide2 OutLines: In this chapter a major topics will be discussed : Introduction to lexical analysis, including.
FE.1 CSE4100 Final Exam Advice and Hints Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University of Connecticut 191 Auditorium.
Compiler Summary Mooly Sagiv html://
Compiler Construction
Yu-Chen Kuo1 Chapter 2 A Simple One-Pass Compiler.
BİL744 Derleyici Gerçekleştirimi (Compiler Design)1.
Lexical and syntax analysis
2.2 A Simple Syntax-Directed Translator Syntax-Directed Translation 2.4 Parsing 2.5 A Translator for Simple Expressions 2.6 Lexical Analysis.
Joey Paquet, 2000, 2002, Lecture 3 Syntactic Analysis Part I.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
1 October 2, October 2, 2015October 2, 2015October 2, 2015 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University Azusa.
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
1 Semantic Analysis Aaron Bloomfield CS 415 Fall 2005.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style COMPILER DESIGN Introduction to code generation.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style COMPILER DESIGN Lexical analysis Joey Paquet,
Joey Paquet, Lecture 12 Review. Joey Paquet, Course Review Compiler architecture –Lexical analysis, syntactic analysis, semantic.
Review 1.Lexical Analysis 2.Syntax Analysis 3.Semantic Analysis 4.Code Generation 5.Code Optimization.
Syntactic Analysis Natawut Nupairoj, Ph.D. Department of Computer Engineering Chulalongkorn University.
May 31, May 31, 2016May 31, 2016May 31, 2016 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University Azusa Pacific University,
1 Lecture 5: Syntax Analysis (Section 2.2) CSCI 431 Programming Languages Fall 2002 A modification of slides developed by Felix Hernandez-Campos at UNC.
Bernd Fischer RW713: Compiler and Software Language Engineering.
1 Chapter 1 Introduction. 2 Outlines 1.1 Overview and History 1.2 What Do Compilers Do? 1.3 The Structure of a Compiler 1.4 The Syntax and Semantics of.
CPS 506 Comparative Programming Languages Syntax Specification.
Compiler design Lecture 1: Compiler Overview Sulaimany University 2 Oct
Joey Paquet, 2000, Lecture 10 Introduction to Code Generation and Intermediate Representations.
Introduction to Code Generation and Intermediate Representations
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
. n COMPILERS n n AND n n INTERPRETERS. -Compilers nA compiler is a program thatt reads a program written in one language - the source language- and translates.
Introduction to Compiling
Compiler Design Introduction 1. 2 Course Outline Introduction to Compiling Lexical Analysis Syntax Analysis –Context Free Grammars –Top-Down Parsing –Bottom-Up.
Compiler Introduction 1 Kavita Patel. Outlines 2  1.1 What Do Compilers Do?  1.2 The Structure of a Compiler  1.3 Compilation Process  1.4 Phases.
1 A Simple Syntax-Directed Translator CS308 Compiler Theory.
PZ03BX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ03BX –Recursive descent parsing Programming Language.
Course Revision.. Contents  Lexical Analysis  Our Compiler Structure  Tokens, Lexemes & Patterns  RE’s & Regular Definitions  Transition Diagrams.
Programming Languages and Design Lecture 2 Syntax Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
C H A P T E R T W O Linking Syntax And Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
What is a compiler? –A program that reads a program written in one language (source language) and translates it into an equivalent program in another language.
CSC 4181 Compiler Construction
COMP 3438 – Part II-Lecture 5 Syntax Analysis II Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Compiler Syntactic Analysis r Two general classes of parsing techniques m Bottom-up (Operator-Precedence parsing) Begin with the terminal nodes.
COMP 3438 – Part II-Lecture 6 Syntax Analysis III Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
1 Compiler Construction Vana Doufexi office CS dept.
CH4.1 CSE244 Midterm Subjects Aggelos Kiayias Computer Science & Engineering Department The University of Connecticut 371 Fairfield Road, Box U-155 Storrs,
CS416 Compiler Design1. 2 Course Information Instructor : Dr. Ilyas Cicekli –Office: EA504, –Phone: , – Course Web.
Prologue Sung-Dong Kim, Dept. of Computer Engineering, Hansung University.
Objective of the course Understanding the fundamentals of the compilation technique Assist you in writing you own compiler (or any part of compiler)
Syntax Analysis By Noor Dhia Syntax analysis:- Syntax analysis or parsing is the most important phase of a compiler. The syntax analyzer considers.
Review 1.Structure of the course Lexical Analysis Syntax Analysis Grammar & Language RG & DFA Top-down LL(1) Parsing Bottom-Up LR Layered Automation Semantic.
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 12–Compilers.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style COMPILER DESIGN Error recovery in top-down.
2016/7/9Page 1 Lecture 11: Semester Review COMP3100 Dept. Computer Science and Technology United International College.
System Software Theory (5KS03).
Lexical and Syntax Analysis
Programming Languages Translator
50/50 rule You need to get 50% from tests, AND
Compiler Lecture 1 CS510.
Introduction CI612 Compiler Design CI612 Compiler Design.
CPSC 388 – Compiler Design and Construction
Subject: Language Processor
Chapter 10: Compilers and Language Translation
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
Compiler design Bottom-up parsing: Canonical LR and LALR
Compiler design Review COMP 442/6421 – Compiler Design
Presentation transcript:

Concordia University Department of Computer Science and Software Engineering Click to edit Master title style COMPILER DESIGN Review Joey Paquet, COMP 442/6421 – Compiler Design

Concordia University Department of Computer Science and Software Engineering Objective: to verify that the students grasp the theoretical aspects of compiler design, as taught in class. Duration: 180 minutes. Open-book examination: all course notes, any textbook, or paper documents allowed, no electronic device permitted. Examination Joey Paquet, COMP 442/6421 – Compiler Design

Concordia University Department of Computer Science and Software Engineering Compiler architecture Phases: Lexical analysis syntactic analysis semantic analysis code optimization code generation Front-end, back-end Mechanisms: Parsing tables symbol table semantic actions/semantic records attribute migration Functioning/role of each phase/component/mechanisms Optionality of some phases Course review Joey Paquet, COMP 442/6421 – Compiler Design

Concordia University Department of Computer Science and Software Engineering Lexical analysis Roles White space removal Processing comments Check and recover from lexical errors Creation of a stream of tokens Design Translation of regular expressions into a DFA Thomson transformation Implementation Case statement or state transition table/algorithm Notable examination questions Generate a DFA from regular expressions Generate a DFA from NDFA Course review Joey Paquet, COMP 442/6421 – Compiler Design

Concordia University Department of Computer Science and Software Engineering Syntactic analysis Roles Analyze the program’s structure Check and recover from syntax errors leading to useful and comprehensive compiler output Design Generative context-free grammars, generating a derivation proving the validity of the input program according to the grammar First and follow sets, grammar transformation (left recursions, ambiguities) All designs are based on a stack mechanism Top-down: predictive parsing, recursive descent, table-driven (require removal of left recursions, ambiguities) Bottom-up: SLR, CLR, LALR (item generation) Error recovery using “synchronizing tokens” Syntax-directed translation Course review Joey Paquet, COMP 442/6421 – Compiler Design

Concordia University Department of Computer Science and Software Engineering Syntactic analysis (cont.) Implementation Recursive descent top-down: each production is implemented as a function matching terminals and calling other such functions to parse non-terminals according to other rules Table-driven top-down: table is constructed using the first and follow sets, based on the notion of “generative grammar” Bottom-up: SLR, CLR, LALR: creation of a DFA using items and first and follow sets, creation of the state transition table with “action” and “goto” parts, called a “shift/reduce” parser. Course review Joey Paquet, COMP 442/6421 – Compiler Design

Concordia University Department of Computer Science and Software Engineering Syntactic analysis (cont.) Notable examination questions Given a grammar, generate a table for a table-driven top-down predictive parser Given a grammar, write some functions for a recursive-descent predictive parser Given a grammar, eliminate left recursions and ambiguities Given a grammar, generate the sets of (CLR, SLR, LALR) items, then generate the corresponding state transition table and/or state transition diagram Given a state transition table and a token stream, execute a parse trace for any of the above bottom-up parsing techniques Course review Joey Paquet, COMP 442/6421 – Compiler Design

Concordia University Department of Computer Science and Software Engineering Semantic Analysis/translation Roles Verify the semantic validity of the program Optionally, generate an intermediate representation Translate the program into executable code Design Attribute migration Symbol table Syntax-directed translation Intermediate representations (optional) Optimization, high level and/or low level (optional) Semantic actions Semantic records Course review Joey Paquet, COMP 442/6421 – Compiler Design

Concordia University Department of Computer Science and Software Engineering Semantic Analysis/translation (cont.) Implementation Attribute migration: parameter passing or semantic stack Symbol table: nested tables to manage scoping Intermediate representation: trees, directed acyclic graphs, tree traversal/analysis algorithms for further processing Intermediate code: postfix notation, three-address code, quadruples, pcode, byte code Notable examination questions Attribute migration tracing Parse execution trace using a semantic stack Course review Joey Paquet, COMP 442/6421 – Compiler Design