Compiler Construction

Similar documents
Compiler Construction Lecture 1: Introduction Summer Semester 2017 Thomas Noll Software Modeling and Verification Group RWTH Aachen University

Compiler Construction Lecture 1: Introduction Winter Semester 2018/19 Thomas Noll Software Modeling and Verification Group RWTH Aachen University

Static Program Analysis

Static Program Analysis

Compiler Construction

Compiler Construction

CS Compiler Construction West Virginia fall semester 2014 August 18, 2014 syllabus 1.0

Translator Design CRN Course Administration CMSC 4173 Spring 2017

Translator Design CRN Course Administration CMSC 4173 Spring 2018

Compiler Construction

Compiler Construction

Compiler Construction

Compiler Construction

Compiler Construction

Compiler Construction

CS321 Languages and Compiler Design I. Winter 2012 Lecture 1

Compiler Construction

12048 Compilers II. Computer Science Engineering, 8º semester Mandatory, 2º Cycle. Theoretical credits: 3.0 Lab credits: 1.5. Theory: José Neira

Formal Languages and Compilers Lecture I: Introduction to Compilers

Compiler I (dt. Übersetzer I) Prof. Dr. Uwe Kastens Winter 2001/2002

Philadelphia University Faculty of Information Technology Department of Computer Science --- Semester, 2007/2008. Course Syllabus

2001 bei Prof. Dr. Uwe Kastens

Compiler Construction

Compiler Design (40-414)

CMPE 152 Compiler Design

CS/SE 153 Concepts of Compiler Design

CA Compiler Construction

CMPE 152 Compiler Design

Compiler Construction I

Compiler Construction

Earlier edition Dragon book has been revised. Course Outline Contact Room 124, tel , rvvliet(at)liacs(dot)nl

Compiler Construction LECTURE # 1

Evaluation of Semantic Actions in Predictive Non- Recursive Parsing

Principles of Compiler Construction ( )

Compiler Construction I

CMPE 152 Compiler Design

Name of chapter & details

CST-402(T): Language Processors

INF5110 Compiler Construction

Crafting a Compiler with C (II) Compiler V. S. Interpreter

Compiler I. (dt. Übersetzer I) Prof. Dr. Uwe Kastens. Winter 2001/2002. Lecture Compiler I WS 2001/2002 / Slide 01

Compiler Construction

CS/SE 153 Concepts of Compiler Design

Error Recovery during Top-Down Parsing: Acceptable-sets derived from continuation

Compiler Design Overview. Compiler Design 1

Automatic Scanning and Parsing using LEX and YACC

Compilers. Pierre Geurts

CSCI 565 Compiler Design and Implementation Spring 2014

Principles of Compiler Construction ( )

HOLY ANGEL UNIVERSITY COLLEGE OF INFORMATION AND COMMUNICATIONS TECHNOLOGY COMPILER THEORY COURSE SYLLABUS

Compiler Design. Dr. Chengwei Lei CEECS California State University, Bakersfield

LECTURE 3. Compiler Phases

Quick Parser Development Using Modified Compilers and Generated Syntax Rules

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF CSE COURSE PLAN

CS131: Programming Languages and Compilers. Spring 2017

Working of the Compilers

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Compiler construction

Undergraduate Compilers in a Day

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

Compiler Theory Introduction and Course Outline Sandro Spina Department of Computer Science

LP - Programming Languages

Compiler Construction

Evaluation Scheme L T P Total Credit Theory Mid Sem Exam

Application Specific Signal Processors S

COMP 3002: Compiler Construction. Pat Morin School of Computer Science

Grammars and Parsing. Paul Klint. Grammars and Parsing

INTRODUCTION PRINCIPLES OF PROGRAMMING LANGUAGES. Norbert Zeh Winter Dalhousie University 1/10

Experiences in Building a Compiler for an Object-Oriented Language

CS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106

Introduction to Compiler Construction

Compilers. Computer Science 431

Compiler Construction

CSE 504: Compiler Design

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

EI326 ENGINEERING PRACTICE & TECHNICAL INNOVATION (III-G) Kenny Q. Zhu Dept. of Computer Science Shanghai Jiao Tong University

Introduction to Compiler Construction

Principles of Programming Languages [PLP-2015] Detailed Syllabus

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

DEPARTMENT OF INFORMATION TECHNOLOGY AUTOMATA AND COMPILER DESIGN. B.Tech-IT, III Year -I Sem

Defining Program Syntax. Chapter Two Modern Programming Languages, 2nd ed. 1

Introduction to Compiler Design

Compilers for Modern Architectures Course Syllabus, Spring 2015

COMPILERS AND INTERPRETERS Lesson 4 TDDD16

CS426 Compiler Construction Fall 2006

Compiler Construction 1. Introduction. Oscar Nierstrasz

Compiler Construction D7011E

CS 432 Fall Mike Lam, Professor. Compilers. Advanced Systems Elective

Structure of a compiler. More detailed overview of compiler front end. Today we ll take a quick look at typical parts of a compiler.

CSCI 2041: Advanced Language Processing

Compiler Construction 2010 (6 credits)

COLLEGE OF ENGINEERING, NASHIK. LANGUAGE TRANSLATOR

TDDD55 - Compilers and Interpreters Lesson 3

Syntax and Type Analysis

G.PULLAIH COLLEGE OF ENGINEERING & TECHNOLOGY

Programmiersprachen (Programming Languages)

2. Syntax and Type Analysis

COMPILER CONSTRUCTION LAB 2 THE SYMBOL TABLE. Tutorial 2 LABS. PHASES OF A COMPILER Source Program. Lab 2 Symbol table

LECTURE NOTES ON COMPILER DESIGN P a g e 2

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

Transcription:

Compiler Construction Lecture 1: Introduction Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de http://moves.rwth-aachen.de/teaching/ss-14/cc14/ Summer Semester 2014

Outline 1 Preliminaries 2 Introduction Compiler Construction Summer Semester 2014 1.2

People Lectures: Thomas Noll (noll@cs.rwth-aachen.de) Exercise classes: Friedrich Gretz (fgretz@cs.rwth-aachen.de) Souymodip Chakraborty (chakraborty@cs.rwth-aachen.de) Student assistant: Philipp Berger Samiro Discher Compiler Construction Summer Semester 2014 1.3

Target Audience BSc Informatik: Wahlpflicht Theoretische Informatik MSc Informatik: Theoretische Informatik MSc Software Systems Engineering: Theoretical Foundations of SSE (was: Theoretical CS) Compiler Construction Summer Semester 2014 1.4

Expectations What you can expect: how to implement (imperative) programming languages application of theoretical concepts compiler = example of a complex software architecture gaining experience with tool support What we expect: basic knowledge in imperative programming languages algorithms and data structures formal languages and automata theory Compiler Construction Summer Semester 2014 1.5

Organization Schedule: Lecture Mon 14:15 15:45 AH 6 (starting 14 April) Lecture Wed 10:15 11:45 AH 6 (starting 9 April) Exercise class Fri 08:15 09:45 AH 2 (starting 16 April) Special: 16 April (exercise), 2/4 June (itestra) see overview at http://moves.rwth-aachen.de/teaching/ss-14/cc14/ 1st assignment sheet next week, presented 25 April Work on assignments in groups of 2-3 people Written exams (2h, 6 Credits) on 25 July/3 September Admission requires at least 50% of the points in the exercises Written material in English, lecture and exercise classes in German, rest up to you Compiler Construction Summer Semester 2014 1.6

Outline 1 Preliminaries 2 Introduction Compiler Construction Summer Semester 2014 1.7

What Is It All About? Compiler = Program: Source code Target code Source code: in high-level programming language, tailored to problem imperative vs. declarative (functional, logic) vs. object-oriented sequential vs. concurrent Target code: low-level code, tailored to machine platform-independent byte code (for virtual machine such as JVM) platform-dependent assembly/machine code (RISC/CISC/parallel/...) Compiler Construction Summer Semester 2014 1.8

Usage of Compiler Technology I Programming language interpreters Ad-hoc implementation of small programs in scripting languages (perl, bash,...) Programs usually interpreted, i.e., executed stepwise Moreover: many non-scripting languages also involve interpreters (e.g., JVM as byte code interpreter) Compiler Construction Summer Semester 2014 1.9

Usage of Compiler Technology II Web browsers Receive HTML (XML) pages from web server Analyse (parse) data and translate it to graphical representation Compiler Construction Summer Semester 2014 1.10

Usage of Compiler Technology III Text processors L A TEX = programming language for texts of various kinds Translated to DVI, PDF,... Compiler Construction Summer Semester 2014 1.11

Properties of a Good Compiler I Efficiency of generated code Goal: target code as fast and/or memory efficient as possible program analysis and optimization cf. course on Static Program Analysis (WS 2012/13, 2014/15) Efficiency of compiler Goal: translation process as fast and/or memory efficient as possible (for inputs of arbitrary size) fast (linear-time) algorithms sophisticated data structures Compiler Construction Summer Semester 2014 1.12

Properties of a Good Compiler II Correctness Goals: conformance to source and target language specifications; equivalence of source and target code compiler validation and verification proof-carrying code,... cf. course on Semantics and Verification of Software (SS 2013, 2015) Remark: mutual tradeoffs! Compiler Construction Summer Semester 2014 1.13

Aspects of a Programming Language Syntax: How does a program look like? hierarchical composition of programs from structural components Semantics: What does this program mean? Static semantics : properties which are not (easily) definable in syntax (declaredness of identifiers, type correctness,...) Dynamic semantics : execution evokes state transformations of an (abstract) machine Pragmatics length and understandability of programs learnability of programming language appropriateness for specific applications... Compiler Construction Summer Semester 2014 1.14

Motivation for Rigorous Formal Treatment Example 1 From NASA s Mercury Project: FORTRAN DO loop DO 5 K = 1,3: DO loop with index variable K DO 5 K = 1.3: assignment to (real) variable DO5K 2 How often is the following loop traversed? FORTRAN IV: once PASCAL: never for i := 2 to 1 do... 3 What if p = nil in the following program? while p <> nil and p^.key < val do... Pascal: strict Boolean operations Modula: non-strict Boolean operations Compiler Construction Summer Semester 2014 1.15

Historical Development Code generation: since 1940s ad-hoc techniques concentration on back-end first FORTRAN compiler in 1960 Formal syntax: since 1960s LL/LR parsing shift towards front-end semantics defined by compiler/interpreter Formal semantics: since 1970s operational denotational axiomatic cf. course on Semantics and Verification of Software Automatic compiler generation: since 1980s [f]lex, yacc, ANTLR, action semantics,... cf. http://catalog.compilertools.net/ Compiler Construction Summer Semester 2014 1.16

Compiler Phases Lexical analysis (Scanner): Syntax analysis (Parser): Semantic analysis: Generation of intermediate code: recognition of symbols, delimiters, and comments by regular expressions and finite automata determination of hierarchical program structure by context-free grammars and pushdown automata checking context dependencies, data types,... by attribute grammars translation into (target-independent) intermediate code by tree translations Code optimization: to improve runtime and/or memory behavior Generation of target code: tailored to target system Additionally: optimization of target code, symbol table, error handling Compiler Construction Summer Semester 2014 1.17

Conceptual Structure of a Compiler Source code Lexical analysis (Scanner) Syntax analysis (Parser) Semantic analysis Generation of intermediate code Code optimization Generation of machine code Target code x1 := y2 + 1; regular expressions/finite Assgn automata Var Exp Sum Var Const (id,x1)(gets,)(id,y2)(plus,)(int,1) context-free grammars/pushdown Assgnok automata Assgn Var Exp attribute grammars Sum Var Const Assgnok intvar Expint intvar Expint Sumint intvar Const int Sumint tree translations intvar Const int LOAD y2; LIT 1; ADD; STO x1...... [omitted: symbol table, error handling] Compiler Construction Summer Semester 2014 1.18

Classification of Compiler Phases Analysis vs. synthesis Analysis: lexical/syntax/semantic analysis (determination of syntactic structure, error handling) Synthesis: generation of (intermediate/machine) code + optimization Front-end vs. back-end Front-end: machine-independent parts (analysis + intermediate code + machine-independent optimizations) Back-end: machine-dependent parts (generation + optimization of machine code) Historical: n-pass compiler n = number of runs through source program nowadays mainly one-pass Compiler Construction Summer Semester 2014 1.19

Literature (CS Library: Handapparat Softwaremodellierung und Verifikation ) General Special A.V. Aho, M.S. Lam, R. Sethi, J.D. Ullman: Compilers Principles, Techniques, and Tools; 2nd ed., Addison-Wesley, 2007 A.W. Appel, J. Palsberg: Modern Compiler Implementation in Java, Cambridge University Press, 2002 D. Grune, H.E. Bal, C.J.H. Jacobs, K.G. Langendoen: Modern Compiler Design, Wiley & Sons, 2000 R. Wilhelm, D. Maurer: Übersetzerbau, 2. Auflage, Springer, 1997 O. Mayer: Syntaxanalyse, BI-Wissenschafts-Verlag, 1978 D. Brown, R. Levine T. Mason: lex & yacc, O Reilly, 1995 T. Parr: The Definite ANTLR Reference, Pragmatic Bookshelf, 2007 Historical W. Waite, G. Goos: Compiler Construction, 2nd edition, Springer, 1985 N. Wirth: Grundlagen und Techniken des Compilerbaus, Addison-Wesley, 1996 Compiler Construction Summer Semester 2014 1.20