Terminology & Basic Concepts

Similar documents
Compiler Design. Computer Science & Information Technology (CS) Rank under AIR 100

Compilers. Prerequisites

Computer Principles and Components 1

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

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)


A Set Of Machine Language Instructions For A Program Is Called Source Code >>>CLICK HERE<<<

Programs are: CMPSCI 105/119/120: Programming, Flowchar<ng, and Running Program Flowcharts

From High Level to Machine Code. Compilation Overview. Computer Programs

COMPILER DESIGN LECTURE NOTES

III. Interpreters and Compilers

Compiling and Interpreting Programming. Overview of Compilers and Interpreters

Introduction to Java Programming

assembler Machine Code Object Files linker Executable File

Why Study Assembly Language?

Programming Languages

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

Compiler construction

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts

CST-402(T): Language Processors

INF5110 Compiler Construction

BITG 1113: Introduction To Computers And Programming Language LECTURE 1 LECTURE 1 1

Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?

Computer Organization and Assembly Language. Lab Session 3

Computer Basics 1/24/13. Computer Organization. Computer systems consist of hardware and software.

Practical Malware Analysis

An Introduction to Python (TEJ3M & TEJ4M)

IT151: Introduction to Programming (java)

Figure 28.1 Position of the Code generator

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker

1) What is the first step of the system development life cycle (SDLC)? A) Design B) Analysis C) Problem and Opportunity Identification D) Development

Lecture 09. Ada to Software Engineering. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

History of Computing. Ahmed Sallam 11/28/2014 1

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language

Low-Level Languages. Computer Programs and Programming Languages

CSE P 501 Compilers. Intermediate Representations Hal Perkins Spring UW CSE P 501 Spring 2018 G-1

CS 321 IV. Overview of Compilation

Computer Basics 1/6/16. Computer Organization. Computer systems consist of hardware and software.

Chapter 1. Hardware. Introduction to Computers and Programming. Chapter 1.2

Lecture 1: Course Introduction

Elements of Computers and Programming Dr. William C. Bulko. What is a Computer?

Life Cycle of Source Program - Compiler Design

Programming 1. Lecture 1 COP 3014 Fall August 28, 2017

COMP163. Introduction to Computer Programming. Introduction and Overview of the Hardware

Stating the obvious, people and computers do not speak the same language.

Software. Software. Software. Program Language. Programs written for the ENIAC

CHAPTER 1 Introduction to Computers and Java

Intermediate Representations

Chapter 1 Welcome Aboard

General Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design

Programming Languages

CS321 Languages and Compiler Design I. Winter 2012 Lecture 1

AP Computer Science A: Java Programming

Programming 1 - Honors

INFS 214: Introduction to Computing

Programming Languages and Program Development

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS

What is programming? What are computer languages and how have they evolved? What is the basic process of programming, including the tools involved?

Early computers (1940s) cost millions of dollars and were programmed in machine language. less error-prone method needed

Programming Languages and Compilers. Jeff Nucciarone AERSP 597B Sept. 20, 2004

CSE 401/M501 Compilers

Computational Physics Operating systems

Compilers and Interpreters

0 Introduction: Computer systems and program development

A Bit of History. Program Mem Data Memory. CPU (Central Processing Unit) I/O (Input/Output) Von Neumann Architecture. CPU (Central Processing Unit)

CSC488S/CSC2107S - Compilers and Interpreters. CSC 488S/CSC 2107S Lecture Notes

CHAPTER 1: INTRODUCTION TO COMPUTERS AND PROGRAMMING. 1 Muhalim Mohamed Amin Faculty of

CMPSCI 201: Architecture and Assembly Language

Problem Solving and Program Design - Chapter 1. Cory L. Strope

Introduction to Programming

Basic Concepts COE 205. Computer Organization and Assembly Language Dr. Aiman El-Maleh

CS 360 Programming Languages Interpreters

Programming 1. Lecture 1 COP 3014 Fall August 28, 2018

COMPUTER ORGANIZATION & ARCHITECTURE

Part (04) Introduction to Programming

Programming Languages FILS Andrei Vasilateanu

Introduction to Compilers

Instruction Set Architecture

SCSP Programming Technique C

C++ Programming Language Lecture 1 Introduction

CSC488S/CSC2107S - Compilers and Interpreters. CSC 488S/CSC 2107S Lecture Notes

Chapter 1. Preliminaries

CMPSCI 201 Fall 2006 Midterm #2 November 20, 2006 SOLUTION KEY

Size, Alignment, and Value Ranges of Data Types. Type Synonym Size Alignment Value Range. BYTE INTEGER*1 8 bits Byte

Chapter 1. Preliminaries

Lecture 1: Course Introduction

Java and Software Design

Chapter 1: An Overview of Computers and Programming Languages. Objectives. Objectives (cont d.) Introduction

ECS15, Lecture 10. Goals of this course 2/8/13. Mini-Review & Topic 3.2 Software. Today s agenda

Software Development. Integrated Software Environment

1 Little Man Computer

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

LESSON 13: LANGUAGE TRANSLATION

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Full file at

Lecture 15: Iteration and Recursion

Hardware Level Organization

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Printing this Slide Show

Game keystrokes or Calculates how fast and moves a cartoon Joystick movements how far to move a cartoon figure on screen figure on screen

Compiler Construction D7011E

Transcription:

Terminology & Basic Concepts Language Processors The basic model of a language processor is the black box translator (or transducer) Has one input stream, one output stream, and a black box (program) that translates between the two input stream output stream Black Box

Language Processors Kinds of Black Box Translators Although all are similar in many ways, we call language processors different things depending on their input and output streams A translator takes as input a program written in one programming language (the source language) and outputs another version of the program written in a different language (the object or target language) A compiler is a translator that takes as input a high level programming language (such as C, Java or Pascal) and outputs machine or assembly language for a target computer An assembler is a translator that takes as input assembly language and outputs machine language for a target computer A transliterator or preprocessor is a translator that translates one high level language to another high level language

Intermediate Languages Language Processors Often compilers, assemblers and other language processors are implemented in multiple stages, using a separate translator for each stage input stream intermediate stream intermediate stream output stream In this case there may be an intermediate form of the program between stages An intermediate language is a language used internally in a compiler to represent the program between stages An intermediate code is an intermediate language that is the machine language of an imaginary ideal ( virtual ) machine (e.g., Pascal P-code, Java JVM byte code) An interpreter is a program that directly executes intermediate code by simulating the hardware of the virtual machine

What is a Compiler? Compilers We will concentrate in this course on compilers, since all stages except the last are very similar for all high level language processors (interpreters, transliterators, HTML processors, etc.) A compiler is a program that translates a high level language (Pascal, C++, Turing, Java, C# etc.) to the machine or assembly language of a target computer SOURCE OBJECT High Level Language COMPILER Machine Language COMPUTER (PT Pascal) (Intel x86 Code) (Linux x86 Execution)

First Computers (early 1940 s) History of Compilers Programmed by hand in machine language using binary codes input using switches Assemblers (late 1940 s) Replaced binary codes with mnemonic operation names (e.g., ADD ) and binary memory addresses with location (variable) names (e.g., A, B, etc.) ADD A,R2 011110 010010

History of Compilers Early High Level Languages (1950 s) First high level language compilers (TRANSCODE, FORTRAN) simply handled translation of simple algebraic statements to machine or assembly code X=A*B+C MOV A,R2 MUL B,R2 MOV C,R3 ADD R2,R3 MOV R3,X Compilers were among the most complex programs of the time - large, challenging and difficult to build Since then, advances in both theory (formal languages and automata) and practice (modularity and table-driven methods) have combined to make compilers among the best understood and most elegantly engineered software systems

Goals for a Compiler The Compiler Itself Compilers should be small (use reasonable amounts of memory) and fast (use reasonable amounts of CPU and real time) Classical time / space tradeoff - can make compiler smaller in memory by storing data structures on disk, but that will make it much slower due to increased disk access Compilers must be reliable - should handle every input program, every time Compilers must be diagnostic - should give informative error messages about exactly what is wrong and where Compilers should have a good human interface - it should be easy and obvious to use and control, whether on the command line or in an IDE

Generated Code Goals for a Compiler Generated code should also be small and fast But again, we are faced with a tradeoff - for example unrolled loops are faster, but bigger There is also a tradeoff between the speed of the compiler and the speed of the generated code If the compiler spends a lot more time on optimization, it can make much faster generated code Generated code should be reliable - it should always work Generated code should be secure - it should not allow accidental violation of language constraints (e.g., subscripts out of bounds) Generated code should be diagnostic - run time failures should be caught and reported in terms of the original source program Generated code should be faithful - the code should do what the user wrote, not something else

Implementation and Maintenance Goals for a Compiler Like any software system, a compiler should be implemented in reasonable time and at reasonable cost It is particularly important that compilers be easy to maintain - compilers are critical components in computer use and must be fixed quickly Compilers be easy to modify - languages evolve and target machines change over time

Error Handling Goals for a Compiler A compiler should reliably both detect and diagnose language violations in the programs it compiles - it must check every language rule, and should give good advice on what exactly the problem is in each case A compiler must recover from detection of errors - that is, it should continue processing the rest of the program to look for other errors if at all possible Compilers should correct (but not ignore) simple errors when possible - for example, but supplying missing semicolons when flagging the error

Summary Language Processors Basic model input-translator-output Assemblers, compilers, transliterators Phased translation, intermediate languages, interpreters Goals for a compiler References Next Text, chapter 1 Basic structure of modern compilers and interpreters, and the role of their phases