Joey Paquet, 2007-20141 Lecture 12 Review. Joey Paquet, 2007-20142 Course Review Compiler architecture –Lexical analysis, syntactic analysis, semantic.

Slides:



Advertisements
Similar presentations
Compilation (Semester A, 2013/14) Lecture 6a: Syntax (Bottom–up parsing) Noam Rinetzky 1 Slides credit: Roman Manevich, Mooly Sagiv, Eran Yahav.
Advertisements

Translator Architecture Code Generator ParserTokenizer string of characters (source code) string of tokens abstract program string of integers (object.
Joey Paquet, 2000, 2002, 2008, Lecture 7 Bottom-Up Parsing II.
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.
Bottom-Up Syntax Analysis Mooly Sagiv html:// Textbook:Modern Compiler Design Chapter
CS Summer 2005 Top-down and Bottom-up Parsing - a whirlwind tour June 20, 2005 Slide acknowledgment: Radu Rugina, CS 412.
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.
(2.1) Grammars  Definitions  Grammars  Backus-Naur Form  Derivation – terminology – trees  Grammars and ambiguity  Simple example  Grammar hierarchies.
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.
Syntax and Semantics Structure of programming languages.
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 Review Joey Paquet,
Review 1.Lexical Analysis 2.Syntax Analysis 3.Semantic Analysis 4.Code Generation 5.Code Optimization.
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.
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
Recursive Descent Parsers Lecture 6 Mon, Feb 2, 2004.
Joey Paquet, 2000, Lecture 2 Lexical Analysis.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 4.
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.
Compiler Construction By: Muhammad Nadeem Edited By: M. Bilal Qureshi.
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.
CSC 4181 Compiler Construction
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
Compiler Syntactic Analysis r Two general classes of parsing techniques m Bottom-up (Operator-Precedence parsing) Begin with the terminal nodes.
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.
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.
Chapter 2: A Simple One Pass Compiler
CC410: System Programming Dr. Manal Helal – Fall 2014 – Lecture 12–Compilers.
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 design Bottom-up parsing: Canonical LR and LALR
Compiler Lecture 1 CS510.
CPSC 388 – Compiler Design and Construction
Subject: Language Processor
Chapter 10: Compilers and Language Translation
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 2, 09/04/2003 Prof. Roy Levow.
Compiler design Bottom-up parsing: Canonical LR and LALR
Compiler design Review COMP 442/6421 – Compiler Design
Presentation transcript:

Joey Paquet, Lecture 12 Review

Joey Paquet, Course Review Compiler architecture –Lexical analysis, syntactic analysis, semantic analysis, code optimization, code generation –Front-end, back-end –Role of each phase –Optionality of some phases

Joey Paquet, Course Review 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 –Implementation Case statement or state transition table/algorithm –Notable examination questions Generate a DFA from regular expressions Generate a DFA from NDFA

Joey Paquet, Course Review 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”

Joey Paquet, Course Review 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 STT with “action” and “goto” parts, called a “shift/reduce” parser.

Joey Paquet, Course Review Syntactic analysis (cont.) –Notable examination questions Given a grammar, generate a table for a table-driven top-down predictive parser Given a grammar, write 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 Given a STT and a token stream, execute a parse trace for any of the above parsing techniques

Joey Paquet, Course Review Semantic Analysis/translation –Roles Verify the semantic validity of the program Translate the program –Design Attribute migration Symbol table Syntax-directed translation Intermediate representations (optional) Optimization (optional) Semantic actions Semantic records

Joey Paquet, Course Review 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