Compiling Principles & Compiler Construction

Slides:



Advertisements
Similar presentations
Compilers Course 379K, TTH 9:30-11:00 Instructor: Dr. Doron A. Peled Office Hours: Mon 11:00-12:00.
Advertisements

Introduction to Compiler Construction
Compiler Principle and Technology Prof. Dongming LU Mar. 11th, 2015.
Compiler Construction by Muhammad Bilal Zafar (AP)
Yu-Chen Kuo1 Chapter 1 Introduction to Compiling.
1 Semantic Processing. 2 Contents Introduction Introduction A Simple Compiler A Simple Compiler Scanning – Theory and Practice Scanning – Theory and Practice.
Compiler Chang Chi-Chung Textbook Compilers: Principles, Techniques, and Tools, 2/E.  Alfred V. Aho, Columbia University  Monica S. Lam,
BİL744 Derleyici Gerçekleştirimi (Compiler Design)1.
College of Computer Science & Technology Compiler Construction Principles & Implementation Techniques -1- Self Introduction Ying JIN ( 金英 ) , PhD, Associate.
Compiling Principles & Compiler Construction Zhai Yuqing ource/compiler/
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Lecture 2 Phases of Compiler. Preprocessors, Compilers, Assemblers, and Linkers Preprocessor Compiler Assembler Linker Skeletal Source Program Source.
C Chuen-Liang Chen, NTUCS&IE / 1 COMPILER Chuen-Liang Chen Department of Computer Science and Information Engineering National Taiwan University Taipei,
Invitation to Computer Science 5th Edition
September 7, September 7, 2015September 7, 2015September 7, 2015 Azusa, CA Sheldon X. Liang Ph. D. Computer Science at Azusa Pacific University.
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.
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
Introduction to Compiler Construction Robert van Engelen COP5621 Compiler Construction Copyright Robert.
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style COMPILER DESIGN Review Joey Paquet,
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Joey Paquet, Lecture 12 Review. Joey Paquet, Course Review Compiler architecture –Lexical analysis, syntactic analysis, semantic.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
Compiler design Lecture 1: Compiler Overview Sulaimany University 2 Oct
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
CS 460/660 Compiler Construction. Class 01 2 Why Study Compilers? Compilers are important – –Responsible for many aspects of system performance Compilers.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
Topic #1: Introduction EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Introduction to Compiling
Introduction CPSC 388 Ellen Walker Hiram College.
Chapter 1 Introduction Major Data Structures in Compiler
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.
Chapter 1: Introduction 1 Compiler Designs and Constructions Chapter 1: Introduction Objectives: Course Objectives Introduction Dr. Mohsen Chitsaz.
1 Compiler & its Phases Krishan Kumar Asstt. Prof. (CSE) BPRCE, Gohana.
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.
Dr. Mohamed Ramadan Saady 314ALL CH1.1 Chapter 1: Introduction to Compiling.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
©SoftMoore ConsultingSlide 1 Structure of Compilers.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
CSC 8505 Compiler Construction
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
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)
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 1 INTRODUCTION TO COMPILER SUNG-DONG KIM, DEPT. OF COMPUTER ENGINEERING, HANSUNG UNIVERSITY.
System Software Theory (5KS03).
Advanced Computer Systems
Compiler Design (40-414) Main Text Book:
Introduction Chapter : Introduction.
Chapter 1 Introduction.
Introduction to Compiler Construction
Constructing Precedence Table
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
Compiler Lecture 1 CS510.
CS416 Compiler Design lec00-outline September 19, 2018
Introduction to Compiler Construction
Introduction CI612 Compiler Design CI612 Compiler Design.
Subject: Language Processor
CS416 Compiler Design lec00-outline February 23, 2019
Introduction to Compiler Construction
Chapter 10: Compilers and Language Translation
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
Introduction Chapter : Introduction.
Presentation transcript:

Compiling Principles & Compiler Construction Zhai Yuqing yqzhai@seu.edu.cn

Main References 1、Compilers:Principles,Techniques,and Tools(2nd Edition),A.V Aho,Ravi Sethi, J.D Ullman,人民邮电出版社,2008 2、Modern Compiler Implementation in C, Andrew W Appeal,人民邮电出版社,2005 3、Modern Compiler Implementation in Java,Andrew W Appeal,高等教育出版社,2003 4、编译原理及编译程序构造,秦振松,东南大学出版社,1997 5、程序设计语言编译原理,陈火旺,国防工业出版社,2000

The role of a compiler in a system DBMS OS Shell OS Kernel Kernel A Compiler Application Programs

Why to arrange the course of compilers? 1、 Seeing the development of a compiler gives you a feeling for how programs work. That can help you understand the internal process of program execution deeply

Why to arrange the course of compilers? 2、Many algorithms and models you will use in compilers are fundamental, and will be useful to you elsewhere: automata context-free grammars hash tables (symbol table) dynamic programming

Why to arrange the course of compilers? dynamic programming Characterize the structure of an optimal solution. Recursively define the value of an optimal solution. Compute the value of an optimal solution in a bottom-up fashion. Construct an optimal solution from computed information.

Why to arrange the course of compilers? 3、To program more efficient programs Notes: Compiler writing spans programming languages, machine architecture, language theory, algorithms, and software engineering. And the ideas behind principles and techniques of a compiler writing can be used many times in the career of a computer scientist.

Why to arrange the course of compilers? 4、

How to teach the course of compilers? Syntax Program Language Semantics Pragmatics High Level Human Language Translating Compiling Inverse compiling Assembling Machine Machine Translating:Oral Translating Compiling:Written Translating

How a program to be processed and run? Lexical & Syntax Analysis Source Code Corrected Code Syntax-directed Translation Intermediated Code Optimization Target Code Generation Optimized Code Assembling Code Assembler Binary Code Executable Code OS Linking DLL

The objective of the course To provide knowledge of paring techniques. To provide knowledge of error detection and recovery using different parsing techniques. To provide concepts in semantic and syntax analysis of a programming language. To provide concepts in intermediate code generation and optimization.

Framework of The Course 1、Introduction to compiling 2、Programming Language and Grammar Definition 3、Lexical Analysis Theoretical Model: Regular Grammar and Finite Automation Implementation: Lexical Analysis Program Tools : LEX 4、Syntax Analysis Theoretical Model:Context-free Grammar and Push-down Automation, LL(1) Grammar,LR Grammar Implementation: Recursive descent parsing Operator-precedence parsing LR parsing Using ambiguous grammars Tools: YACC

Framework of The Course 5、Intermediate Code Generation and Syntax-directed Translation 6、Type Checking and Run-Time Environment 7、Code Optimization: Block Optimization, Loop Optimization, Global Optimization 8、Target Code generation

How to learn the course? 1、Focus on understand the principles deeply 2、Notice the relations among the chapters 3、Do more exercises , more practices and combine the theory with the labs

How to evaluate? 1、Exercises – 10% 2、Experiments – 20% (Total 2 experiments) 3、Term examination –70%

Chapter 1 Introduction to Compiling 1、What is a compiler? very general definition: It is a piece of software that translates a program in one (artificial) language, Lang1, to a program in another (artificial) language, Lang2. narrower definition: Our primarily focus is the case where Lang1 is a programming language that humans like to program in, and Lang2 is (or is “closer to”) a machine language, that a computer “understands” and can execute. extra stipulation: The compiler should say something even if the input is not a valid program of Lang1. Namely, it should give an error message explaining why the input is not a valid program.

Chapter 1 Introduction to Compiling 1、What is a compiler? Compiler Source Program Target Program Error Messages

Chapter 1 Introduction to Compiling 2、 Why avoid compilers & program in machine language? A good programming language allows us to think at a level of abstraction suitable for the problem domain we are interested in. A good programming language should also facilitate robust code development.

Chapter 1 Introduction to Compiling 3、Structure of a compiler

Chapter 1 Introduction to Compiling 4、The Analysis-Synthesis Model of Compilation Linear analysis Hierarchical analysis Semantic analysis (type checking)

Chapter 1 Introduction to Compiling 4、The Analysis-Synthesis Model of Compilation Analysis part: Break up the source program into constitute pieces and create an intermediate representation of the source program Notes: One of ordinary intermediate representation methods is syntax tree /parse tree

Chapter 1 Introduction to Compiling 4、The Analysis-Synthesis Model of Compilation Syntax Tree/Parse tree: A hierarchical structure Assignment statement x=y+2*z Parse Tree Syntax Tree (is a compressed representation of parse tree) = x + y * 2 z exp = id exp exp op x exp op exp + id num * id y 2 z

Chapter 1 Introduction to Compiling 4、The Analysis-Synthesis Model of Compilation Synthesis part: Construct the desired target program from the intermediate representation

Chapter 1 Introduction to Compiling 5、Symbol-Table Management Record the identifiers used in the source program and collect information about various attributes of each identifier, such as its type, its scope A symbol table is a data structure containing a record for each identifier, with fields for the attributes of the identifier

Chapter 1 Introduction to Compiling 5、Symbol-Table Management Shared by later phases Allow to find the record for each identifier quickly and to store or retrieve data from the table quickly

Chapter 1 Introduction to Compiling 6、Error Detection and Reporting The syntax and semantic analysis phases usually handle a large fraction of the errors detectable by the compiler

Chapter 1 Introduction to Compiling 7、How to construct a compiler? Program in a machine language for target machine directly Program in an assembling language Notes: The kernel of a compiler is usually programmed in an assembling language Program in high-level language Notes: This is an ordinary method

Chapter 1 Introduction to Compiling 7、How to construct a compiler? Self-Compiling Use compiler-construction tools Lex,Yacc Port among different platforms Notes: When constructing a compiler, a source language, a destination language and the compiling methods should be considered

Chapter 1 Introduction to Compiling 8、Compiler-Construction Tools Parser generators: Produce syntax analyzers, normally from input that is based on a context-free grammar Scanner generators: Automatically generate lexical analyzers, normally from a specification based on regular expression

Chapter 1 Introduction to Compiling 8、Compiler-Construction Tools Syntax-directed translation engine: Produce collections of routines that walk the parse tree, generating intermediate code Automatic code generators: Take a collection of rules that define the translation of each operation of the intermediate language into the machine language for the target machine

Chapter 1 Introduction to Compiling 8、Compiler-Construction Tools Data-flow engines