Compilers. Introduction to Compilers. Lecture 1. Spring term. Mick O Donnell: michael.odonnell@uam.es Alfonso Ortega: alfonso.ortega@uam.
|
|
- Austen Hardy
- 8 years ago
- Views:
Transcription
1 Compilers Spring term Mick O Donnell: michael.odonnell@uam.es Alfonso Ortega: alfonso.ortega@uam.es Lecture 1 to Compilers 1
2 Topic 1: What is a Compiler? 3 What is a Compiler? A compiler is a computer program which coverts source code written in a high level programming language into another form, typically machine code. unsigned int gcd (unsigned int a, unsigned int b) { if (a == 0 &&b == 0) b = 1; else if (b == 0) b = a; else if (a!= 0) while (a!= b) if (a <b) b -= a; else a -= b; } return b; The machine code is a sequence of instructions for the machine to perform. 4 2
3 Why study Compilers? Very few computer scientists actually write or modify compilers. So why is this a core subject? Some computer scientists need to understand how compilers work, so that they can write them. For this reason, the knowledge needs to be passed on. But more importantly, understanding how our computer programs are compiled and executed can help any programmer understand how the code they write drives the machine, and thus help us write faster, more effective programs. 5 Topic 2: History of Programming Languages 6 3
4 Development of Programming FIXED HARDWARE Early automatic machines were constructed with a single task in mind, and thus could not be programmed. Machines would process data supplied by the user. E.g., Cash Registers, Ballot Counters. PROGRAMMABLE HARDWARE In the 1940s, the first programmable computing machines were made. Users could change the way in which the machine processed data by configuring a number of switches on the machine. STORED PROGRAMS Some machines allowed operators to enter program line by line, stored in memory. In 1944, Harvard Mark I accepted programs stored on paper tape. In : The magnetic drum memory was introduced as a data storage device for computers. 7 Development of Programming (Cont.) MACHINE CODE The earliest programmable computers worked directly in machine code. A machine code program is a sequence of instructions, each instruction consists of an operator, and (in the early days) a single argument, which would be either a value (e.g., an integer), or a reference to a register (a memory location). The CPU loads in one instruction at a time, and executes that instruction. The next instruction in sequence is then loaded in. Each instruction is represented as a fixed number of bits (in early days, 8 bits were used, although currently 64 bit instructions are common). The first 4 bits represented the operator ( e.g., 00 for NOOP, 01 for ADD, 02 for MOV, etc. The remaining 4 bits represent the data to operate on. e.g Add 1 to the current sum. 8 4
5 Development of Programming (cont.) INTRODUCTION OF ASSEMBLY LANGUAGE Programming in machine code is very slow, requiring the programmer to continually keep track of which binary code represents which operation, and converting numbers into binary. Assembly Language introduced a mnemonic representation, using symbols such as ADD, MOV or POP to use rather than the binary codes. A program called the ASSEMBLER then translates the assembly language program into machine code. Assembly programs also allow the inclusion of comments, which explain the program to other programmers, but are ignored in the conversion to machine code. Distinct assembly language for each machine type. EXAMPLE mov al, 0x Development of Programming (cont.) HIGH LEVEL PROGRAMMING LANGUAGES Assembly language is specific to a particular machine code, and thus a particular machine type. The next step was to develop programming languages which work on any machine. Each machine provides a compiler to translate the high-level language to the machine code for that machine. Some writing in assembler still took place where optimal performance needed (and still happens today!) 1945: Zuse developed plankalkul (plan calculus) the first programming language. This was the predecessor of algorithmic programming languages and concepts of logic programming. It was designed to be a chess-playing program. 1949: Short Order, developed by John Mauchly, is thought to be the first high-level programming language an IBM team lead by John W. Backus developed FORTRAN 10 5
6 Development of Programming (cont.) NEW PARADIGMS While the earliest HLPLs were seen as sequences of instructions, the developing experience of using compilers to map from abstract languages to machine runnable code allowed computer scientists to experiment with the way programming languages were formulated. Best known of the new programming paradigms are: Functional (Lisp, Scheme, ML, Haskell), Logical (Prolog, etc.), Object-oriented (C++, Java, CLOS, Python, etc.) 11 Development of Programming (cont.) VIRTUAL MACHINES In the standard approach, source programs are compiled to distinct machine code formats for each hardware/os platform. An alternative approach compiles the source code to a platformindependent form of machine code, called Byte. Each platform then provides software (e.g., Java Runtime for Windows) to execute the byte code on that platform. The byte code thus does not drive the CPU directly: the virtual machine examines the byte code to see which of its functions it should run. For this reason, the virtual machine is usually called an interpreter. 12 6
7 Development of Programming (cont.) INTERPRETED LANGUAGES? Programming languages such as Java, Perl, Python, Tcl/Tk, etc. are often called interpreted languages, because historically they have always been used only in virtual machines. However, more and more compilers are becoming available for these languages, which produce native machine code from the source code. For this reason, calling a language interpreted or compiled is on the way out, as a given language can be used in both environments. 13 Topic 3: History of Compilers 14 7
8 Development of Compilers Machine code No need for processing, used directly Assembly code: Translated to machine code via a direct mapping (e.g., replace symbol MOV with hex code 0A BC Comments dropped during mapping High level programs Initial approaches wrote compiler in machine code, with knowledge of the programming language coded directly. Later approaches separated language structure from the code, using the notion of grammars: PROGRAM begin STATEMENT* end STATEMENT VAR = EXPR ; print EXPR EXPR VAR NUM EXPR + EXPR etc. 15 Evolution of Bugs The term bug was used to refer to hardware problems as early as 1878, e.g., Thomas Edison to a friend: It has been just so in all of my inventions. The first step is an intuition, and comes with a burst, then difficulties arise this thing gives out and [it is] then that "Bugs" as such little faults and difficulties are called show themselves. Regularly applied to problems in radar electronics during WW II First computer bug: 1947: Working on a prototype of the Mark II, at Harvard, an operator finds the first computer "bug," logged at 15:45 hours on September 9, 1947, a moth that had caused a relay failure. 1962: NASA Mariner 1 went off-course during launch : four people died when exposed to lethal doses of radiation from Therac- 25 linear accelerator machines, used for treatment of cancer. Software errors caused machines to incorrectly calculate the amount of radiation being delivered to the patient. 1989: A computer in Paris read files on traffic violations and then mistakenly sent out letters charging 41,000 traffic offenders with crimes including murder, drug trafficking, extortion, and prostitution. Recipients were described as "surprised." 16 8
9 Topic 4: How Compilers Work 17 How does a compiler work? A compiler can be viewed in two parts: 1. Source : which takes as input source code as a sequence of characters, and interprets it as a structure of symbols (vars, values, operators, etc.) 2. Object Generator: which takes the structural analysis from (1) and produces runnable code as output. 18 9
10 How does a compiler work? A compiler can be viewed in two parts: 1. Source : which takes as input source code as a sequence of characters, and interprets it as a structure of symbols (vars, values, operators, etc.) 2. Object Generator: which takes the structural analysis from (1) and produces runnable code as output. Source 19 How does a compiler work? A compiler can be viewed in two parts: 1. Source : which takes as input source code as a sequence of characters, and interprets it as a structure of symbols (vars, values, operators, etc.) 2. Object Generator: which takes the structural analysis from (1) and produces runnable code as output. Source Generat or Object 20 10
11 How does a compiler work? A compiler can be viewed in two parts: 1. Source : which takes as input source code as a sequence of characters, and interprets it as a structure of symbols (vars, values, operators, etc.) 2. Object Generator: which takes the structural analysis from (1) and produces runnable code as output. The Source is machine-independent, while the Object Generator needs to be produce different code for each machine-type, and is thus machine-dependent. 21 How does a compiler work? A compiler can be viewed in two parts: 1. Source : which takes as input source code as a sequence of characters, and interprets it as a structure of symbols (vars, values, operators, etc.) 2. Object Generator: which takes the structural analysis from (1) and produces runnable code as output. The Source is machine-independent, while the Object Generator needs to be produce different code for each machine-type, and is thus machine-dependent. (1) is often called the front-end of the compiler, and (2) the back-end 22 11
12 How does a compiler work? The Front End typically has three stages: Lexical Analysis: accepts the source code as a sequence of chars, outputs the code as a sequence of tokens. Syntax : interprets the program tokens as a structured program. Semantic : checks that variables are instantiated before use, etc. FRONT END Source Lexical Syntactic Semantic 23 The Lexical FRONT END Source Lexical Syntactic Semantic 24 12
13 Lexical : Also called tokeniser, scanner, or in Spanish, morphological analyser Main task: recognise which character sequences are tokens (variables, values, operators, etc.) E.g., A := 100; A, :=, 100, ; Secondary task: tag each token by its type, e.g., identifier entifier, reserved- word, integer eger, etc. begin int A; A := 100; A := A+A; output A End How does a compiler work? (reserved-word,begin) (type, int)(<id>,a)(<symb>,;) (<id>,a)(<mult-symb>,:=) (<cons int>,100)(<symb>,;) (<id>,a)(<mult-symb>,:=) (<id>,a)(<symb>,+)(<id>,a)(<symb>,;) (reserved-word,output)(<id>,a) (reserved-word,end) 25 Parts of translators / compilers Lexical analyser The tokens recognised in lexical analysis are usually of the following types: Identifiers Reserved words (e.g. for, while ) Numeric constants (integers, real numbers, etc.) Literal (or string) constants. Simple symbols: operators (+, -, *, ), separators (;,., ) Multiple symbols: operators (+=, -=, ) These tokens, together with their types, become the atoms (terminals) of the next stage, syntactic analysis
14 Parts of translators / compilers Lexical analyser Other tasks done in lexical analysis: Remove excess blank-spaces and comments. Detect lexical errors: Badly formed symbols Badly formed identifiers Badly formed constants. Badly formed comments. 27 Parts of translators / Compilers Lexical analyser: example The figure shows an example of morphological analysis of a program correctly written in the programming language asple. The morphological analyser returns, as syntactic units, pairs with: The name of the unit (reserved-word, identifier, symbol, multiplesymbol ) The char sequence from the source that corresponds to that unit. begin int A; A := 100; A := A+A; output A end AM (reserved-word,begin) (type, int)(<id>,a)(<symb>,;) (<id>,a)(<mult-symb>,:=) (<cons int>,100)(<symb>,;) (<id>,a)(<mult-symb>,:=) (<id>,a)(<symb>,+)(<id>,a)(<symb>,;) (reserved-word,output)(<id>,a) (reserved-word,end) 28 14
15 The Syntactic FRONT END Source Lexical Syntactic Semantic 29 Syntactic Also called parser Inputs: the tokenised program produced by lexical analyser Resources: A grammar defining the structure of the language PROGRAM begin STATEMENT* end STATEMENT VAR = EXPR ; print EXPR EXPR VAR NUM EXPR + EXPR etc. Outputs: a structural representation of the program, showing, e.g., that tokens group into a statement, that statements group into a block, etc. This data structure is called a Parse Tree, or sometimes an Intermediate Representation. The parse tree is a language independent structure, which gives a great deal of flexibility to the code generator
16 Parts of translators / compilers Syntactic analyses: example <Program> begin <declrcns> ; <stmts> end <declrcn> <statement> ; <stmts> <type> <ids> <assignment> <statement> ; <stmts> int <id> <id> := <expr> <asignment> <statement> A.Sintáctico (<palabra clave>,begin) (<tipo>,int)(<id>,a)(<simb>,;) A A <const.int> <id> := <expr> <outputstmt> 100 A <expr> + <expr> output<expr> <id> <id> <id> (<id>,a)(<simbm>,:=) (<cons int>,100)(<simb>,;) (<id>,a)(<simbm>,:=) (<id>,a)(<simb>,+)(<id>,a)(<simb>,;) (<palabra clave>,output)(<id>,a) (palabra clave>,end) A A A 31 Syntactic : Syntactic Other functions: It is also responsible for identifying syntactic errors in the code. i.e. places where a sequence of tokens does not match the syntax rules of the language, e.g., Missing ; at the end of a statement in Java 32 16
17 Parts of translators / compilers Lexical vs. Syntactic analyser The distinction between lexical analyser and syntax analyser is somewhat arbitrary: It should be possible to write a context-independent grammar and implement a pushdown automata that recognises the complete language. However, some of the syntactic elements of programming languages (e.g. comments, constants, names) belong to a simpler type of languages, and are usually easy to describe with regular expressions, and thence they are recognisable with finite automatas. Therefore, it is usually a good idea to split the analysis in two steps. 33 The Semantic FRONT END Source Lexical Syntactic Semantic 34 17
18 Semantic Semantic : Can perform checks on program consistency: Operations have arguments of allowed types variables are initialised before referenced, correct number of arguments to function calls, etc. Typically a global view of the program 35 The Symbol Table FRONT END Source Lexical Syntactic Semantic Symbol Table 36 18
19 Parts of translators / compilers The symbols table is a table whose aim is to store all the information necessary to determine that the program is correct, and to generate the code: Names and types of variables. Names of procedures, and types of arguments and return values. Names of objects, packages, modules Shared between the 3 modules of the front end FRONT END Symbols table Lexical Syntactic Semantic Symbol Table 37 Parts of translators / compilers Symbols table Definition: the symbol table is a data structure which holds information on the identifiers in the program (variable names, function names, etc.). Implementation: The symbol table is usually implemented with a data structure (typically a hash table), to allow for efficient execution of: Introducing information Retrieving information 38 19
20 Parts of translators / compilers Symbols table: example The symbols table may have the following content begin int A; A := 100; A := A+A; output A endm.a Syntactic Anal. Element <id> Type int Value A 39 The Front End Summary of Front End : FRONT END Source Lexical Syntactic Semantic Symbol Table 40 20
21 The Back End The Back End typically has two stages: Generator: Generates object code from parse tree (typically machine code) Optimiser: recognises structures in the machine code which can be made more efficient, and changes them BACK END Generator Optimiser Object 41 The Back End The Back End sometimes has an initial pre-processing step, which: breaks any expressions into their simplest components. For example, the assignment: a := * 3 would be broken into: temp := 2 * 3; a := 1 + temp; Such expressions are called Binary Expressions. Such expressions facilitate the generation of assembler language code. Compilers that translate from one high level language to another often do not contain this step. This step sometimes also performs machine independent optimizations
22 The Back End A different back-end is required for each object language, Distinct code to generate Optimisation depends on target language Each target machine type has different machine code. Thus, the back end differs for each machine type BACK END 1 Generator 1 Optimiser 1 Object 1 BACK END 2 Generator 2 Optimiser 2 Object 2 43 Optimisation: Parts of translators / Compilers The Back End It is difficult for a compiler to generate the target code in a way that fully takes advantage of the resources (memory, cache, CPU ) in a efficient way. These last modules try to reorganise and rewrite portions of the code in order to mitigate this problem
23 Optimisation : EXAMPLE The translator might have generated, initially, the following version of the program in assembler. The optimiser might realise that, in this case, the management of arithmetic expressions has produced two instructions that are redundant (as the value is already in EAX) and can be removed. Parts of translators / Compilers The Back End segment.data _A dd 0 segment.codigo global _main _main: push dword 100 pop eax mov [_A], eax push dword [_A] push dword [_A] POP edx POP eax add eax,edx push eax pop eax mov [_A], eax push dword [_A] pop eax push eax call imprime_entero add esp, 4 call imprime_fin_linea ret 45 Optimisation : EXAMPLE The translator might have generated, initially, the following version of the program in assembler. The optimiser might realise that, in this case, the management of arithmetic expressions has produced two instructions that are redundant (as the value is already in EAX) and can be removed. Parts of translators / Compilers The Back End segment.data _A dd 0 segment.codigo global _main _main: push dword 100 pop eax mov [_A], eax push dword [_A] POP edx add eax,edx push eax pop eax mov [_A], eax push dword [_A] pop eax push eax call imprime_entero add esp, 4 call imprime_fin_linea ret 46 23
24 Parts of Translators / Compilers Error recovery Error recovery: Most translators are not only used for translating from a high-level programming language into other language. They are also a tool for software development, showing the programmer the bugs in their program Therefore, one of the major functions of translators is the diagnostic they provide in case of coding mistakes. Compilers should also be designed so that they don t just stop at the first bug, but can recover from the error, and locate other bugs. 47 Parts of Translators / Compilers Complete example begin int A; A := 100; A := A+A; output A end Source AM Syntactic A. Generation, Optimisation, Memory Magmt. segment.data _A dd 0 segment.codigo global _main _main: push dword 100 pop eax mov [_A], eax push dword [_A] POP edx add eax,edx push eax pop eax mov [_A], eax push dword [_A] pop eax push eax call imprime_entero add esp, 4 call imprime_fin_linea ret (<palabra clave>,begin) (<tipo>,int)(<id>,a)(<simb>,;) Object (<id>,a)(<simbm>,:=) (<cons int>,100)(<simb>,;) (<id>,a)(<simbm>,:=) (<id>,a)(<simb>,+)(<id>,a)(<simb>,;) (<palabra clave>,output)(<id>,a) (palabra clave>,end) 48 24
25 Topic 5: Interpreters 49 Compilers vs. Interpreters General concepts The back end of a compiler translates the internal representation of the program into object code in a file. An interpreter can have the same front end, but rather than converting the internal representation, it knows how to execute it directly. An interpreter thus allows for on the fly execution of lines of code provided by a programmer. Sometimes used in an interactive environment with a user But also allows for scripts (source code) to be executed as a program without intervening compilation
26 Compilers vs. Interpreters Example If a session of an interpreter received, from the user, the program statements from the previous examples Interpreter Window Input begin int A; A := 100; A := A+A; output A Session start int A := 100 A := A + A Session end Output Main parts of an interpreter: Symbols table Morphological analyser Syntax analyser Semantic analyser execution Memory management Interpreters Parts of an interpreter 52 26
27 Topic 6: Other Topics 53 Other concepts Single and multiple Pass Compilers Pass: Complete revision of the source program, for any specific purpose. One-pass compiler: Compiler that performs all the translation with just one pass over the source code. Many-passes compiler: Compiler that performed more than one pass. These usually impose less restrictions to the source language
CSCI 3136 Principles of Programming Languages
CSCI 3136 Principles of Programming Languages Faculty of Computer Science Dalhousie University Winter 2013 CSCI 3136 Principles of Programming Languages Faculty of Computer Science Dalhousie University
More informationProgramming Languages
Programming Languages Programming languages bridge the gap between people and machines; for that matter, they also bridge the gap among people who would like to share algorithms in a way that immediately
More informationCA4003 - Compiler Construction
CA4003 - Compiler Construction David Sinclair Overview This module will cover the compilation process, reading and parsing a structured language, storing it in an appropriate data structure, analysing
More informationCompiler I: Syntax Analysis Human Thought
Course map Compiler I: Syntax Analysis Human Thought Abstract design Chapters 9, 12 H.L. Language & Operating Sys. Compiler Chapters 10-11 Virtual Machine Software hierarchy Translator Chapters 7-8 Assembly
More informationCompiler Construction
Compiler Construction Lecture 1 - An Overview 2003 Robert M. Siegfried All rights reserved A few basic definitions Translate - v, a.to turn into one s own language or another. b. to transform or turn from
More information1/20/2016 INTRODUCTION
INTRODUCTION 1 Programming languages have common concepts that are seen in all languages This course will discuss and illustrate these common concepts: Syntax Names Types Semantics Memory Management We
More informationIntroduction. Compiler Design CSE 504. Overview. Programming problems are easier to solve in high-level languages
Introduction Compiler esign CSE 504 1 Overview 2 3 Phases of Translation ast modifled: Mon Jan 28 2013 at 17:19:57 EST Version: 1.5 23:45:54 2013/01/28 Compiled at 11:48 on 2015/01/28 Compiler esign Introduction
More informationn Introduction n Art of programming language design n Programming language spectrum n Why study programming languages? n Overview of compilation
Lecture Outline Programming Languages CSCI-4430 & CSCI-6430, Spring 2016 www.cs.rpi.edu/~milanova/csci4430/ Ana Milanova Lally Hall 314, 518 276-6887 milanova@cs.rpi.edu Office hours: Wednesdays Noon-2pm
More informationChapter 1. Dr. Chris Irwin Davis Email: cid021000@utdallas.edu Phone: (972) 883-3574 Office: ECSS 4.705. CS-4337 Organization of Programming Languages
Chapter 1 CS-4337 Organization of Programming Languages Dr. Chris Irwin Davis Email: cid021000@utdallas.edu Phone: (972) 883-3574 Office: ECSS 4.705 Chapter 1 Topics Reasons for Studying Concepts of Programming
More informationLanguage Processing Systems
Language Processing Systems Evaluation Active sheets 10 % Exercise reports 30 % Midterm Exam 20 % Final Exam 40 % Contact Send e-mail to hamada@u-aizu.ac.jp Course materials at www.u-aizu.ac.jp/~hamada/education.html
More informationLanguage Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages
ICOM 4036 Programming Languages Preliminaries Dr. Amirhossein Chinaei Dept. of Electrical & Computer Engineering UPRM Spring 2010 Language Evaluation Criteria Readability: the ease with which programs
More informationHow to make the computer understand? Lecture 15: Putting it all together. Example (Output assembly code) Example (input program) Anatomy of a Computer
How to make the computer understand? Fall 2005 Lecture 15: Putting it all together From parsing to code generation Write a program using a programming language Microprocessors talk in assembly language
More informationProgramming Languages CIS 443
Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception
More informationSemantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
More informationCS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08
CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 20: Stack Frames 7 March 08 CS 412/413 Spring 2008 Introduction to Compilers 1 Where We Are Source code if (b == 0) a = b; Low-level IR code
More informationChapter 6: Programming Languages
Chapter 6: Programming Languages Computer Science: An Overview Eleventh Edition by J. Glenn Brookshear Copyright 2012 Pearson Education, Inc. Chapter 6: Programming Languages 6.1 Historical Perspective
More informationLecture 9. Semantic Analysis Scoping and Symbol Table
Lecture 9. Semantic Analysis Scoping and Symbol Table Wei Le 2015.10 Outline Semantic analysis Scoping The Role of Symbol Table Implementing a Symbol Table Semantic Analysis Parser builds abstract syntax
More informationChapter 12 Programming Concepts and Languages
Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages Paradigm Publishing, Inc. 12-1 Presentation Overview Programming Concepts Problem-Solving Techniques The Evolution
More informationLecture 1: Introduction
Programming Languages Lecture 1: Introduction Benjamin J. Keller Department of Computer Science, Virginia Tech Programming Languages Lecture 1 Introduction 2 Lecture Outline Preview History of Programming
More informationProgramming Languages
Programming Languages Qing Yi Course web site: www.cs.utsa.edu/~qingyi/cs3723 cs3723 1 A little about myself Qing Yi Ph.D. Rice University, USA. Assistant Professor, Department of Computer Science Office:
More informationProgramming Languages
Programming Languages In the beginning To use a computer, you needed to know how to program it. Today People no longer need to know how to program in order to use the computer. To see how this was accomplished,
More informationComputer Programming. Course Details An Introduction to Computational Tools. Prof. Mauro Gaspari: mauro.gaspari@unibo.it
Computer Programming Course Details An Introduction to Computational Tools Prof. Mauro Gaspari: mauro.gaspari@unibo.it Road map for today The skills that we would like you to acquire: to think like a computer
More information03 - Lexical Analysis
03 - Lexical Analysis First, let s see a simplified overview of the compilation process: source code file (sequence of char) Step 2: parsing (syntax analysis) arse Tree Step 1: scanning (lexical analysis)
More informationCompiler Construction
Compiler Construction Regular expressions Scanning Görel Hedin Reviderad 2013 01 23.a 2013 Compiler Construction 2013 F02-1 Compiler overview source code lexical analysis tokens intermediate code generation
More informationThe programming language C. sws1 1
The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan
More informationHigh-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)
High-Level Programming Languages Nell Dale & John Lewis (adaptation by Michael Goldwasser) Low-Level Languages What are disadvantages of low-level languages? (e.g., machine code or assembly code) Programming
More information1 Introduction. 2 An Interpreter. 2.1 Handling Source Code
1 Introduction The purpose of this assignment is to write an interpreter for a small subset of the Lisp programming language. The interpreter should be able to perform simple arithmetic and comparisons
More informationAdvanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz 2007 03 16
Advanced compiler construction Michel Schinz 2007 03 16 General course information Teacher & assistant Course goals Teacher: Michel Schinz Michel.Schinz@epfl.ch Assistant: Iulian Dragos INR 321, 368 64
More informationCSE 130 Programming Language Principles & Paradigms
CSE 130 Programming Language Principles & Paradigms Thomas A. Powell tpowell@pint.com Housekeeping Syllabus review Direct class page link http://www.pint.com/classes/cse130 Updated syllabus, notes, homework
More informationCSE 307: Principles of Programming Languages
Course Organization Introduction CSE 307: Principles of Programming Languages Spring 2015 R. Sekar Course Organization Introduction 1 / 34 Topics 1. Course Organization Info and Support Course Description
More informationCSC 272 - Software II: Principles of Programming Languages
CSC 272 - Software II: Principles of Programming Languages Lecture 1 - An Introduction What is a Programming Language? A programming language is a notational system for describing computation in machine-readable
More informationX86-64 Architecture Guide
X86-64 Architecture Guide For the code-generation project, we shall expose you to a simplified version of the x86-64 platform. Example Consider the following Decaf program: class Program { int foo(int
More informationScoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)
Semantic Analysis Scoping (Readings 7.1,7.4,7.6) Static Dynamic Parameter passing methods (7.5) Building symbol tables (7.6) How to use them to find multiply-declared and undeclared variables Type checking
More informationLexical Analysis and Scanning. Honors Compilers Feb 5 th 2001 Robert Dewar
Lexical Analysis and Scanning Honors Compilers Feb 5 th 2001 Robert Dewar The Input Read string input Might be sequence of characters (Unix) Might be sequence of lines (VMS) Character set ASCII ISO Latin-1
More informationC Compiler Targeting the Java Virtual Machine
C Compiler Targeting the Java Virtual Machine Jack Pien Senior Honors Thesis (Advisor: Javed A. Aslam) Dartmouth College Computer Science Technical Report PCS-TR98-334 May 30, 1998 Abstract One of the
More informationProgramming Language Pragmatics
Programming Language Pragmatics THIRD EDITION Michael L. Scott Department of Computer Science University of Rochester ^ШШШШШ AMSTERDAM BOSTON HEIDELBERG LONDON, '-*i» ЩЛ< ^ ' m H NEW YORK «OXFORD «PARIS»SAN
More information3 SOFTWARE AND PROGRAMMING LANGUAGES
3 SOFTWARE AND PROGRAMMING LANGUAGES 3.1 INTRODUCTION In the previous lesson we discussed about the different parts and configurations of computer. It has been mentioned that programs or instructions have
More informationSemester Review. CSC 301, Fall 2015
Semester Review CSC 301, Fall 2015 Programming Language Classes There are many different programming language classes, but four classes or paradigms stand out:! Imperative Languages! assignment and iteration!
More informationTopics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives
Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,
More informationSources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
More information02 B The Java Virtual Machine
02 B The Java Virtual Machine CS1102S: Data Structures and Algorithms Martin Henz January 22, 2010 Generated on Friday 22 nd January, 2010, 09:46 CS1102S: Data Structures and Algorithms 02 B The Java Virtual
More informationCSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014
CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages Nicki Dell Spring 2014 What is a Programming Language? A set of symbols and associated tools that translate (if necessary) collections
More informationEmbedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
More informationOutline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage
Outline 1 Computer Architecture hardware components programming environments 2 Getting Started with Python installing Python executing Python code 3 Number Systems decimal and binary notations running
More informationName: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
More informationPython Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science Chapter 1 Computers and Programs 1 Objectives To understand the respective roles of hardware and software in a computing system. To learn what computer
More informationAQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping
AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping 3.1.1 Constants, variables and data types Understand what is mean by terms data and information Be able to describe the difference
More informationScanning and parsing. Topics. Announcements Pick a partner by Monday Makeup lecture will be on Monday August 29th at 3pm
Scanning and Parsing Announcements Pick a partner by Monday Makeup lecture will be on Monday August 29th at 3pm Today Outline of planned topics for course Overall structure of a compiler Lexical analysis
More informationLexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016
Master s Degree Course in Computer Engineering Formal Languages FORMAL LANGUAGES AND COMPILERS Lexical analysis Floriano Scioscia 1 Introductive terminological distinction Lexical string or lexeme = meaningful
More information1.1 WHAT IS A PROGRAMMING LANGUAGE?
1 INTRODUCTION 1.1 What is a Programming Language? 1.2 Abstractions in Programming Languages 1.3 Computational Paradigms 1.4 Language Definition 1.5 Language Translation 1.6 Language Design How we communicate
More informationThe previous chapter provided a definition of the semantics of a programming
Chapter 7 TRANSLATIONAL SEMANTICS The previous chapter provided a definition of the semantics of a programming language in terms of the programming language itself. The primary example was based on a Lisp
More informationCS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper
More informationMcGraw-Hill The McGraw-Hill Companies, Inc., 20 1. 01 0
1.1 McGraw-Hill The McGraw-Hill Companies, Inc., 2000 Objectives: To describe the evolution of programming languages from machine language to high-level languages. To understand how a program in a high-level
More information2) Write in detail the issues in the design of code generator.
COMPUTER SCIENCE AND ENGINEERING VI SEM CSE Principles of Compiler Design Unit-IV Question and answers UNIT IV CODE GENERATION 9 Issues in the design of code generator The target machine Runtime Storage
More informationATSBA: Advanced Technologies Supporting Business Areas. Programming with Java. 1 Overview and Introduction
ATSBA: Advanced Technologies Supporting Business Areas Programming with Java 1 Overview and Introduction 1 1 Overview and Introduction 1 Overview and Introduction 1.1 Programming and Programming Languages
More informationCSE-111 Great Ideas in Computer Science Albert Y. C. Chen University at Buffalo, SUNY
CSE-111 Great Ideas in Computer Science Albert Y. C. Chen University at Buffalo, SUNY !! Finally, putting everything all together. Also, we ll learn how complicated things are simplified by thinking in
More informationLevels of Programming Languages. Gerald Penn CSC 324
Levels of Programming Languages Gerald Penn CSC 324 Levels of Programming Language Microcode Machine code Assembly Language Low-level Programming Language High-level Programming Language Levels of Programming
More informationJonathan Worthington Scarborough Linux User Group
Jonathan Worthington Scarborough Linux User Group Introduction What does a Virtual Machine do? Hides away the details of the hardware platform and operating system. Defines a common set of instructions.
More informationCopyright 2012 Pearson Education, Inc. Chapter 1 INTRODUCTION TO COMPUTING AND ENGINEERING PROBLEM SOLVING
Chapter 1 INTRODUCTION TO COMPUTING AND ENGINEERING PROBLEM SOLVING Outline Objectives 1. Historical Perspective 2. Recent Engineering Achievements 3. Computing Systems 4. Data Representation and Storage
More informationInterpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters
Interpreters and virtual machines Michel Schinz 2007 03 23 Interpreters Interpreters Why interpreters? An interpreter is a program that executes another program, represented as some kind of data-structure.
More informationSymbol Tables. Introduction
Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The
More informationMaster of Sciences in Informatics Engineering Programming Paradigms 2005/2006. Final Examination. January 24 th, 2006
Master of Sciences in Informatics Engineering Programming Paradigms 2005/2006 Final Examination January 24 th, 2006 NAME: Please read all instructions carefully before start answering. The exam will be
More informationC++ Programming Language
C++ Programming Language Lecturer: Yuri Nefedov 7th and 8th semesters Lectures: 34 hours (7th semester); 32 hours (8th semester). Seminars: 34 hours (7th semester); 32 hours (8th semester). Course abstract
More informationPushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, 2014. School of Informatics University of Edinburgh als@inf.ed.ac.
Pushdown automata Informatics 2A: Lecture 9 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 3 October, 2014 1 / 17 Recap of lecture 8 Context-free languages are defined by context-free
More informationElena Baralis, Silvia Chiusano Politecnico di Torino. Pag. 1. Query optimization. DBMS Architecture. Query optimizer. Query optimizer.
DBMS Architecture INSTRUCTION OPTIMIZER Database Management Systems MANAGEMENT OF ACCESS METHODS BUFFER MANAGER CONCURRENCY CONTROL RELIABILITY MANAGEMENT Index Files Data Files System Catalog BASE It
More informationThe C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
More informationLecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com
CSCI-UA.0201-003 Computer Systems Organization Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted (and slightly modified)
More informationInstruction Set Architecture (ISA)
Instruction Set Architecture (ISA) * Instruction set architecture of a machine fills the semantic gap between the user and the machine. * ISA serves as the starting point for the design of a new machine
More informationPhysical Data Organization
Physical Data Organization Database design using logical model of the database - appropriate level for users to focus on - user independence from implementation details Performance - other major factor
More informationAn Introduction to Computer Science and Computer Organization Comp 150 Fall 2008
An Introduction to Computer Science and Computer Organization Comp 150 Fall 2008 Computer Science the study of algorithms, including Their formal and mathematical properties Their hardware realizations
More informationFormat string exploitation on windows Using Immunity Debugger / Python. By Abysssec Inc WwW.Abysssec.Com
Format string exploitation on windows Using Immunity Debugger / Python By Abysssec Inc WwW.Abysssec.Com For real beneficiary this post you should have few assembly knowledge and you should know about classic
More informationImage credits: http://xkcd.com/353/
Image credits: http://xkcd.com/353/ CS 354: Programming Languages Alark Joshi Copyright 2009 Addison-Wesley. All rights reserved. Contact Information Email: alarkjoshi@boisestate.edu Course Website: o
More informationDivision of Mathematical Sciences
Division of Mathematical Sciences Chair: Mohammad Ladan, Ph.D. The Division of Mathematical Sciences at Haigazian University includes Computer Science and Mathematics. The Bachelor of Science (B.S.) degree
More informationPemrograman Dasar. Basic Elements Of Java
Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle
More informationIntroduction to Java
Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high
More informationWhat is a programming language?
Overview Introduction Motivation Why study programming languages? Some key concepts What is a programming language? Artificial language" Computers" Programs" Syntax" Semantics" What is a programming language?...there
More informationCOMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing
COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing The scanner (or lexical analyzer) of a compiler processes the source program, recognizing
More information1 The Java Virtual Machine
1 The Java Virtual Machine About the Spec Format This document describes the Java virtual machine and the instruction set. In this introduction, each component of the machine is briefly described. This
More informationFirst Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
More informationChapter 13 Computer Programs and Programming Languages. Discovering Computers 2012. Your Interactive Guide to the Digital World
Chapter 13 Computer Programs and Programming Languages Discovering Computers 2012 Your Interactive Guide to the Digital World Objectives Overview Differentiate between machine and assembly languages Identify
More informationMassachusetts Institute of Technology Department of Electrical Engineering and Computer Science
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 7 Scanner Parser Project Wednesday, September 7 DUE: Wednesday, September 21 This
More informationGood FORTRAN Programs
Good FORTRAN Programs Nick West Postgraduate Computing Lectures Good Fortran 1 What is a Good FORTRAN Program? It Works May be ~ impossible to prove e.g. Operating system. Robust Can handle bad data e.g.
More informationSoftware Fingerprinting for Automated Malicious Code Analysis
Software Fingerprinting for Automated Malicious Code Analysis Philippe Charland Mission Critical Cyber Security Section October 25, 2012 Terms of Release: This document is approved for release to Defence
More informationPrinciples of Programming Languages Topic: Introduction Professor Louis Steinberg
Principles of Programming Languages Topic: Introduction Professor Louis Steinberg CS 314, LS,LTM: L1: Introduction 1 Contacts Prof. Louis Steinberg lou @ cs.rutgers.edu x5-3581 401 Hill TA: to be announced
More informationOKLAHOMA SUBJECT AREA TESTS (OSAT )
CERTIFICATION EXAMINATIONS FOR OKLAHOMA EDUCATORS (CEOE ) OKLAHOMA SUBJECT AREA TESTS (OSAT ) FIELD 081: COMPUTER SCIENCE September 2008 Subarea Range of Competencies I. Computer Use in Educational Environments
More informationHow To Write Portable Programs In C
Writing Portable Programs COS 217 1 Goals of Today s Class Writing portable programs in C Sources of heterogeneity Data types, evaluation order, byte order, char set, Reading period and final exam Important
More informationAdvanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2
Lecture Handout Computer Architecture Lecture No. 2 Reading Material Vincent P. Heuring&Harry F. Jordan Chapter 2,Chapter3 Computer Systems Design and Architecture 2.1, 2.2, 3.2 Summary 1) A taxonomy of
More informationBig Data Technology Map-Reduce Motivation: Indexing in Search Engines
Big Data Technology Map-Reduce Motivation: Indexing in Search Engines Edward Bortnikov & Ronny Lempel Yahoo Labs, Haifa Indexing in Search Engines Information Retrieval s two main stages: Indexing process
More informationHigh-speed image processing algorithms using MMX hardware
High-speed image processing algorithms using MMX hardware J. W. V. Miller and J. Wood The University of Michigan-Dearborn ABSTRACT Low-cost PC-based machine vision systems have become more common due to
More informationMoving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
More informationObjects for lexical analysis
Rochester Institute of Technology RIT Scholar Works Articles 2002 Objects for lexical analysis Bernd Kuhl Axel-Tobias Schreiner Follow this and additional works at: http://scholarworks.rit.edu/article
More informationDatavetenskapligt Program (kandidat) Computer Science Programme (master)
Datavetenskapligt Program (kandidat) Computer Science Programme (master) Wolfgang Ahrendt Director Datavetenskap (BSc), Computer Science (MSc) D&IT Göteborg University, 30/01/2009 Part I D&IT: Computer
More informationParsing Technology and its role in Legacy Modernization. A Metaware White Paper
Parsing Technology and its role in Legacy Modernization A Metaware White Paper 1 INTRODUCTION In the two last decades there has been an explosion of interest in software tools that can automate key tasks
More information7.1 Our Current Model
Chapter 7 The Stack In this chapter we examine what is arguably the most important abstract data type in computer science, the stack. We will see that the stack ADT and its implementation are very simple.
More informationHow Compilers Work. by Walter Bright. Digital Mars
How Compilers Work by Walter Bright Digital Mars Compilers I've Built D programming language C++ C Javascript Java A.B.E.L Compiler Compilers Regex Lex Yacc Spirit Do only the easiest part Not very customizable
More informationProgramming Language Inter-conversion
Programming Language Inter-conversion Dony George Priyanka Girase Mahesh Gupta Prachi Gupta Aakanksha Sharma FCRIT, Vashi Navi Mumbai ABSTRACT In this paper, we have presented a new approach of programming
More informationLecture 7: Programming for the Arduino
Lecture 7: Programming for the Arduino - The hardware - The programming environment - Binary world, from Assembler to C - - Programming C for the Arduino: more - Programming style Lect7-Page1 The hardware
More informationSoftware: Systems and. Application Software. Software and Hardware. Types of Software. Software can represent 75% or more of the total cost of an IS.
C H A P T E R 4 Software: Systems and Application Software Software and Hardware Software can represent 75% or more of the total cost of an IS. Less costly hdwr. More complex sftwr. Expensive developers
More informationRaima Database Manager Version 14.0 In-memory Database Engine
+ Raima Database Manager Version 14.0 In-memory Database Engine By Jeffrey R. Parsons, Senior Engineer January 2016 Abstract Raima Database Manager (RDM) v14.0 contains an all new data storage engine optimized
More information