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
COMPILER CONSTRUCTION WEEK- 4: INTRODUCTION TO COMPILER & INTERPRETER.
Copyright © 2009 Elsevier Chapter 3:: Names, Scopes, and Bindings Programming Language Pragmatics Michael L. Scott.
Sub: : Fundamental of Programming(FOP) Chap: 1 : Introduction to Programming: Algorithms and Flowcharts Presented By Tejas Modi Asst. Professor,
Operating Systems Part IV: Memory Management. Main Memory Large array of words or bytes each having its own address Several processes must be kept in.
Chapter 11 Introduction to Programming in C. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display C: A High-Level.
Programming Domains 1.Scientific Applications Typically, scientific applications have simple data structures but require large numbers of floating-point.
Unit-V -SOFTWARE QUALITY. To develop and deliver robust system, we need a high level of confidence that Each component will behave correctly Collective.
SISTEMA EMBEBIDO. OPERATING SYSTEMS TYPES The Linux OS is monolithic. Generally operating systems come in three flavors: real-time executive, monolithic,
MT311 (Oct 2007) Java Application Development Concepts of Programming Languages, Language Evaluation Tutorial 5.
Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The Intel Pentium.
Names, Scope, Memory, and Binding. Name, Scope, and Binding A name is exactly what you think it is – Usually think of identifiers but can be more general.
Construction process lasts until coding and testing is completed consists of design and implementation reasons for this phase –analysis model is not sufficiently.
Xeno Kovah – 2012 xkovah at gmail 1 BINARIES Part 1 See notes for citation.
9.1 9 Programmin g Languages Foundations of Computer Science Cengage Learning.
Automata Theory November 2002 Introduction & NFAPart 1:
Chapter 7 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice, FL.
MT311 (Oct 2007) Java Application Development Variables – binding, type, and scope Expression Tutorial 6.
RISC Instruction Pipelines and Register Windows By: Andy Le CS147 – Dr. Sin-Min Lee San Jose State University, Fall 2003.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 12: Query Processing.
©Ian Sommerville 2000Software Engineering, 6th edition. Chapter 29Slide 1 Chapter 29 Configuration Management.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 10Slide 1 Chapter 10 Architectural Design.
Tools and techniques that support user interface development Design support is needed because designing software is typically very complex and requires.
Copyright © 2003 Pearson Education, Inc. Slide 1.
Chapter 13 Instruction-Level Parallelism and Superscalar Processors.
CSE-105 – Structured Programming CSE, BUET Introduction CSE 105 Structured Programming Language (C)
Chapter 6 Architectural Design Slide 1 Chapter 6 Architectural Design.
Case Study: A Recursive Descent Interpreter Implementation in C++ (Source Code Courtesy of Dr. Adam Drozdek) Payap University ICS220 - Data Structures.
BIOMEDICAL DATA INTEGRATION BASED ON METAQUERIER ARCHITECTURE GROUP MEMBERS -NAIEEM KHAN -EUSUF ABDULLAH MIM -M SAMIULLAH CHOWDHURY ADVISOR : KHONDKER.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 2: Operating-System Structures.
IOS103 OPERATING SYSTEM VIRTUAL MEMORY. Objectives At the end of the course, the student should be able to: Define virtual memory; Discuss the demand.
© 2016 SlidePlayer.com Inc. All rights reserved.