课程名 编译原理 Compiling Techniques

Slides:



Advertisements
Similar presentations
Introduction to Compiler Construction
Advertisements

By Neng-Fa Zhou Compiler Construction CIS 707 Prof. Neng-Fa Zhou
Lecture 01 - Introduction Eran Yahav 1. 2 Who? Eran Yahav Taub 734 Tel: Monday 13:30-14:30
Programming Languages Structure
Compiler Construction
Compiler Construction1 A Compulsory Module for Students in Computer Science Department Faculty of IT / Al – Al Bayt University First Semester 2009/2010.
Summer 02-03Programming Language Concepts1 Programming Language Concepts (CS 360) Lecture 1: Overview, Grammars, and Little Languages Jeremy R. Johnson.
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.
CPSC 388 – Compiler Design and Construction Lecture: MWF 11:00am-12:20pm, Room 106 Colton.
Course Revision Contents  Compilers  Compilers Vs Interpreters  Structure of Compiler  Compilation Phases  Compiler Construction Tools  A Simple.
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
COP4020 Programming Languages
Chapter 1. Introduction.
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.
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.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
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.
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.
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.
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.
Programming Language Concepts (CIS 635) Elsa L Gunter 4303 GITC NJIT,
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
Objective of the course Understanding the fundamentals of the compilation technique Assist you in writing you own compiler (or any part of compiler)
COMP 3002: Compiler Construction Pat Morin School of Computer Science.
Compilers: History and Context COMP Outline Compilers and languages Compilers and architectures – parallelism – memory hierarchies Other uses.
Chapter 1 Introduction Samuel College of Computer Science & Technology Harbin Engineering University.
Chapter 1. Introduction.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Lecture 9 Symbol Table and Attributed Grammars
Advanced Computer Systems
Compiler Design (40-414) Main Text Book:
PRINCIPLES OF COMPILER DESIGN
Chapter 1 Introduction.
Introduction to Compiler Construction
PROGRAMMING LANGUAGES
Introduction.
Chapter 1 Introduction.
-by Nisarg Vasavada (Compiled*)
CISC 7120X Programming Languages and Compilers
Compiler Lecture 1 CS510.
CS 536 / Fall 2017 Introduction to programming languages and compilers
Compiler Construction
CS416 Compiler Design lec00-outline September 19, 2018
Introduction to Compiler Construction
Course supervisor: Lubna Siddiqui
Lecture 2: General Structure of a Compiler
Front End vs Back End of a Compilers
Introduction CI612 Compiler Design CI612 Compiler Design.
Compiler 薛智文 TH 6 7 8, DTH Spring.
COP4020 Programming Languages
Compiler 薛智文 TH 6 7 8, DTH Spring.
CS416 Compiler Design lec00-outline February 23, 2019
Principles of Programming Languages
Introduction to Compiler Construction
CISC 7120X Programming Languages and Compilers
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Compiler Construction
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
Compiler 薛智文 M 2 3 4, DTH Spring.
Introduction to Compiler Construction
Presentation transcript:

课程名 编译原理 Compiling Techniques 浙江大学计算机学院与软件学院 编译原理课程组

Information Instructor 李莹 cnliying@zju.edu.cn 13335880866 Teacher Assistant 孙煦雪 sunxuxue@zju.edu.cn 15858138880

Text Books The Dragon Book: Compilers Principles, Techniques, & Tools, Second Edition, Alfred V. Aho The Tiger Book: Modern Compiler Implementation in C, Andrew Appel

Grade Distribution attend class 10% Homework Class test or Mid-Term Exam 15% Final during exam period: 65%

Course Structure Course has theoretical and practical aspects Compiling Techniques Compiler Design

Compiler: why? 1940’s The first electronic computers Programming in machine language Slow , tedious and error prone 1954 IBM develops the 704 All programming done in assembly Software costs exceeded hardware costs!

Compiler: why? Emerge of higher-level languages with higher-level notations more easily programming Fortran Scientific computation Cobol Business data processing Lisp Symbolic computation

Higher-level Language A compiler For machine Higher-level Language Machine Language For human Compiler

Why Study Compilers Basic idea for constructing translators. Principle and Techniques reusable in other CS domains. Influences hardware design, e.g., RISC, VLIW. Tools (mostly “optimization”) for enhancing software reliability and security. Excellent software-engineering example --- theory meets practice. Essential software tool.

A compiler A compiler is a program that can read a program in one language and translate it into an equivalent program in another language Compiler Target Program Source Program Input Output

A Interpreter An interpreter directly execute the operations of source program on inputs Interpreter Source program Input Output

A language-processing system

The structure Two parts of a compiler operate as a sequence of phases Analysis, front end Synthesis,back end operate as a sequence of phases

Lexical Analysis Reads stream of characters Group the characters into lexemes For each lexemes, output a Token <token-name, attribute-value>

Syntax Analysis Reads Token stream Create tree-like intermediate representation (syntax tree) The grammatical structure of the token stream

Semantic Analysis Uses syntax tree information in Symbol table understand the meaning of program Too hard for compilers only check Semantic consistency Type checking Type conversions (Coercions)

Intermediate Code Geneartion For portability and reuse Before generate target program Generate intermediate representations first Three address code Code sequence One operator Three operands (max)

Code Optimization To improve the intermediate code Run faster Use less memory Consume less power

Code Generation Takes an intermediate representation as input Maps it to target language Registers and memory allocation Translate IR instructions into machine instructions

Symbol-Table Management An essential function of a compiler Records variable names various attributes of them

Passes Several phases may be grouped into a pass A pass reads an input file and writes an output file An example of a pass including: Lexical analysis, parsing, semantic analysis IR generation.

Compiler construction tools-1 Some tools could be used to help compiler construction Parser Generators. automatically produce syntax analyzers from a grammatical description of a programming language.Yacc Scanner Generators. produce lexical analyzers from a regular-expression description of the tokens of a language.Lex Syntax-directed translation engines. produce collections of routines for walking a parse tree and generating intermediate code.

Compiler construction tools-2 Code-generator generators. produce a code generator from a collection of rules for translating each operation of the intermediate language into the machine language for a target machine. Data-flow analysis engines. facilitate the gathering of information about how values are transmitted from one part of a program to each other part. Compiler-construction toolkit. provide an integrated set of routines for constructing various phases of a compiler.

The move to Higher-level Languages First generation languages: machine languages. Second generation: assembly languages. Third generation: higher-level languages, Fortran, Cobol, Lisp, C…. Forth generation: languages designed for specific applications, NOMAD, SQL Fifth generation: logic- and constraint-based languages, Prolog and OPS5

Another classification of languages Imperative how a computation is to be done C, C++, C#, Java Declarative what computation is to be done ML, Haskell, Prolog Von neumann languages Object-oriented languages Scripting languages

Impacts on Compilers Can help promote the use of high-level languages Compiler writing is challenging. A compiler must translate correctly the potentially infinite set of programs

Application of Compiler Technology Implementation of higher-level programming languages Optimizations for computer architectures Design of new computer architectures Program translations Software productivity tools

Optimizations for computer architecture Parallelism Multi-core, many-core VLIW (very long instruction word), issue multiple operations in parallel Memory hierarchies Several levels of storage The closer, the faster Registers, CPU cache Main memory disks

Design of new computer architecture RISC Specialized architecture VLIW SIMD

Program translation Binary translation x86 →Sparc x86 →arm Hardware synthesis VHDL RTL Database query interpreters Compiled simulation

Software Productivity Tools Type checking Bounds Checking Memory-Management tools Code generators

Summary Language Processors Compiler Phases Machine and Assembly languages Modeling in Compiler Design Code Optimization Higher-level Languages Compilers and Computer Architecture Software Productivity and Software Security Programming Language Basics: Scope Rules, Environments, Block Structure, Parameter Passing, Aliasing

The end of Lecture01