We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byKeon Blizard
Modified about 1 year ago
Copyright © 2005 Elsevier Imperative languages Imperative languages, particularly the von Neumann languages, predominate –They will occupy the bulk of our attention We also plan to spend a lot of time on functional, logic languages
Copyright © 2005 Elsevier Compilation vs. Interpretation Compilation vs. interpretation –not opposites –not a clear-cut distinction Pure Compilation –The compiler translates the high-level source program into machine language then goes away:
Copyright © 2005 Elsevier Compilation vs. Interpretation Pure Interpretation –Interpreter stays around for the execution of the program –Interpreter is the locus of control during execution
Copyright © 2005 Elsevier Compilation vs. Interpretation Interpretation: –Greater flexibility –Better diagnostics (error messages) Compilation: –Better performance –Earlier diagnostics
Copyright © 2005 Elsevier Compilation vs. Interpretation Common case is compilation or simple pre- processing, followed by interpretation Most language implementations include a mixture of both compilation and interpretation
Copyright © 2005 Elsevier Compilation vs. Interpretation Note that, in general, compilation does not produce machine language for hardware Compilation is translation from one language into another Compilation entails semantic understanding and analysis of what is being processed Pre-processing is also translation, but does not entail understanding (It will often let errors through)
Copyright © 2005 Elsevier Compilation vs. Interpretation Implementation strategies: –Preprocessor Removes comments and white space Expands abbreviations in the style of a macro assembler
Copyright © 2005 Elsevier Compilation vs. Interpretation Implementation strategies: –The C Preprocessor (conditional compilation) Preprocessor deletes portions of code, which allows several versions of a program to be built from the same source
Copyright © 2005 Elsevier Compilation vs. Interpretation Implementation strategies: –Source-to-Source Translation (C++) C++ implementations based on the early AT&T compiler generated an intermediate program in C, instead of an assembly language:
Copyright © 2005 Elsevier Compilation vs. Interpretation Implementation strategies: –Library of Routines and Linking A linker program merges the appropriate library of subroutines (e.g., math functions such as sin, cos, log, etc.) into the final program:
Copyright © 2005 Elsevier Compilation vs. Interpretation Implementation strategies: –Dynamic and Just-in-Time Compilation In some cases a programming system may deliberately delay compilation until the last possible moment. –Lisp or Prolog invoke the compiler on the fly, to translate newly created source into machine language, or to optimize the code for a particular input set. –The Java language definition defines a machine-independent intermediate form known as byte code. Byte code is the standard format for distribution of Java programs. It may be compiled at run time. –The main C# compiler produces.NET Common Intermediate Language (CIL), which is then translated into machine code immediately prior to execution.
Copyright © 2005 Elsevier C Style Execution Static –Compilation -.o –Static Linking -.dll or.exe Dynamic (sequential order) –Loading –Dynamic Linking –Execution
Copyright © 2005 Elsevier Java/C# Style Execution Static –Compilation (.class) Dynamic (mixed order) –Loading –(Bytecode analysis) –Dynamic Linking –(JIT Compilation) –Execution
Copyright © 2005 Elsevier An Overview of Compilation Phases of Compilation
Copyright © 2005 Elsevier An Overview of Compilation Scanning: –divides the program into "tokens", which are the smallest meaningful units –scanning is recognition of a regular language, e.g., via DFA (Deterministic Finite Automaton) –Separating scanning from parsing increases efficiency
Copyright © 2005 Elsevier An Overview of Compilation Parsing is recognition of a context-free language, e.g., via PDA (Pushdown Automaton) –Parsing discovers the "context free" structure of the program –Produces a parse tree (or concrete syntax tree)
Copyright © 2005 Elsevier An Overview of Compilation Semantic analysis is the discovery of meaning in the program –Produces an abstract syntax tree –Compiler does static semantic analysis: the meaning that can be deduced at compile time –Things that cannot be deduced until runtime (e.g., array subscript out of bounds) are part of the program's dynamic semantics
Copyright © 2005 Elsevier An Overview of Compilation Intermediate form (IF) done after semantic analysis (if the program passes all checks) –IFs are often chosen for machine independence, ease of optimization, or compactness (these are somewhat contradictory) –They often resemble machine code for some imaginary idealized machine; e.g. a stack machine, or a machine with arbitrarily many registers –Many compilers actually move the code through more than one IF
Copyright © 2005 Elsevier An Overview of Compilation Optimization takes an intermediate-code program and produces another one that does the same thing faster, or in less space –The term is a misnomer; we just improve code –The optimization phase is optional Code generation phase produces assembly language or (sometime) relocatable machine language
Copyright © 2005 Elsevier An Overview of Compilation Symbol table: all phases rely on a symbol table that keeps track of all the identifiers in the program and what the compiler knows about them –This symbol table may be retained (in some form) for use by a debugger, even after compilation has completed
Copyright © 2005 Elsevier An Overview of Compilation Lexical and Syntax Analysis –GCD Program (Pascal)
Copyright © 2005 Elsevier An Overview of Compilation Lexical and Syntax Analysis –GCD Program Tokens Scanning (lexical analysis) and parsing recognize the structure of the program, groups characters into tokens, the smallest meaningful units of the program
Copyright © 2005 Elsevier An Overview of Compilation Lexical and Syntax Analysis –Context-Free Grammar and Parsing Parsing organizes tokens into a parse tree that represents higher-level constructs in terms of their constituents Potentially recursive rules known as context-free grammar define the ways in which these constituents combine
Copyright © 2005 Elsevier An Overview of Compilation Context-Free Grammar and Parsing –Example (Pascal program)
Copyright © 2005 Elsevier An Overview of Compilation Context-Free Grammar and Parsing –GCD Program Parse Tree Next slide
Copyright © 2005 Elsevier An Overview of Compilation Context-Free Grammar and Parsing –GCD Program Parse Tree (continued)
Copyright © 2005 Elsevier An Overview of Compilation Abstract Syntax Tree
Programming Language Theory 2014, 1 Chapter 1 :: Introduction Origin : Michael L. Scott School of Computer & Information Engineering,
1 Programming Languages Tevfik Koşar Lecture - II January 19 th, 2006.
Copyright © 2005 Elsevier Chapter 1 :: Introduction Programming Language Pragmatics Michael L. Scott.
Chapter 1 :: Introduction Programming Language Pragmatics Michael L. Scott.
Chapter 1 :: Introduction Programming Language Pragmatics, Fourth Edition Michael L. Scott Copyright © 2016 Elsevier.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
COP4020 Programming Languages Introduction Prof. Robert van Engelen (modified by Prof. Em. Chris Lacher)
COP4020 Programming Languages Compiler phases Prof. Xin Yuan.
1 Chapter 1. Introduction. 2 Outline Language Processors The Structure of a Compiler The Evolution of Programming Languages Why study principle of programming.
CS 355 – PROGRAMMING LANGUAGES Dr. X. Topics Influences on Language Design Language Categories Language Design Trade-Offs Implementation Methods Programming.
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.
Compiler Construction CPCS302 Dr. Manal Abdulaziz.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Introduction and Syntax. Course objectives Discuss features of programming languages. Discuss how the features are implemented in a simple computer architecture.
CST320 - Lec 11 Why study compilers? n n Ties lots of things you know together: –Theory (finite automata, grammars) –Data structures –Modularization –Utilization.
CPSC Compiler Tutorial 9 Review of Compiler.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
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.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Concepts of Programming Languages Lecturer: Dr. Emad Nabil Lecture # 2.
1 Programming Languages Fundamentals Cao Hoaøng Truï Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa TP. HCM.
Presented by : A best website designer company. Chapter 1 Introduction Prof Chung. 1.
LECTURE 3 Compiler Phases. COMPILER PHASES Compilation of a program proceeds through a fixed series of phases. Each phase uses an (intermediate) form.
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 Compiler Design (40-414) Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007 Evaluation: Midterm.
1 Compiler & its Phases Krishan Kumar Asstt. Prof. (CSE) BPRCE, Gohana.
Chapter 17 Programming Tools The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander.
CHAPTER 1 INTRODUCTION TO COMPILER SUNG-DONG KIM, DEPT. OF COMPUTER ENGINEERING, HANSUNG UNIVERSITY.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
1-1 Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria Influences on Language.
Topic #1: Introduction EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
Compiler Design Lexical Analysis Syntactical Analysis Semantic Analysis Optimization Code Generation.
Introduction to Compilers. Related Area Programming languages Machine architecture Language theory Algorithms Data structures Operating systems Software.
CSI 3125, Preliminaries, page 1 Programming languages and the process of programming –Programming means more than coding. –Why study programming languages?
1. 10% Assignments/ class participation 10% Pop Quizzes 05% Attendance 25% Mid Term 50% Final Term 2.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Chapter 1 Introduction Samuel College of Computer Science & Technology Harbin Engineering University.
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.
CSC 4181 Compiler Construction Overview of Compilers Part 1 Introduction1.
Unit-1 Introduction PREPARED BY: PROF. HARISH I RATHOD COMPUTER ENGINEERING DEPARTMENT GUJARAT POWER ENGINEERING & RESEARCH INSTITUTE COMPILER DESIGN (170701)
Introduction CPSC 388 Ellen Walker Hiram College.
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.
Chapter 1 Introduction Study Goals: Master: the phases of a compiler Understand: what is a compiler Know: interpreter,compiler structure.
Compiler Construction1 A Compulsory Module for Students in Computer Science Department Faculty of IT / Al – Al Bayt University First Semester 2009/2010.
1 Introduction to Compiling CS308 Compiler Theory.
COP4020 Programming Languages Compilation and Interpretation Prof. Xin Yuan.
Chapter 1 Introduction. Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview.
© 2017 SlidePlayer.com Inc. All rights reserved.