Download presentation
Presentation is loading. Please wait.
Published byMaurice Singleton Modified over 9 years ago
1
Chapter 1 Introduction
2
Chapter 1 - Introduction 2 The Goal of Chapter 1 Introduce different forms of language translators Give a high level overview of the structure of a typical compiler Discuss trends in programming languages and machine architecture that are shaping compilers.
3
Chapter 1 - Introduction 3 What is a Compiler? Def: Compiler -- –a program that translates a program written in a language like Pascal, C, PL/I, FORTRAN, or COBOL into another language. An important role of the compiler is to report any errors that it detects.
4
Chapter 1 - Introduction 4 What is an Interpreter? Def: Interpreter -- –Instead of producing a target program at translation, it appears to directly execute the operations specified in the source program on the inputs specified by the user.
5
Chapter 1 - Introduction 5 What are the Differences? Compiler is usually much faster. Interpreter usually gives better diagnostics.
6
Chapter 1 - Introduction 6 2. Structure of a Compiler So far we have viewed the compiler as a single black box.
7
Chapter 1 - Introduction 7 2. Structure of a Compiler Now we want to open that box.
8
Chapter 1 - Introduction 8
9
9 2. Structure of a Compiler 1. The Lexical Analyzer reads the stream of characters and groups them into meaningful sequences called lexemes. 2. The Syntax Analyzer depicts the grammatical structure of the lexemes in a syntax tree 3. The Semantic Analyzer checks the tree for semantic consistency (type checking)
10
Chapter 1 - Introduction 10 2. Structure of a Compiler 4. Intermediate Code Generation – produces assembly like instructions (three address code) 5. Code Optimization – seeks to improve intermediate code so better target code can be generated 6. Code Generation – takes the intermediate code and maps to the target code.
11
Chapter 1 - Introduction 11 2. Structure of a Compiler 7. Symbol Table Management - An essential function of the compiler is to record the variable names used in the source program and collect attributes of each name. (type, scope,…)
12
Chapter 1 - Introduction 12 2.8 The Grouping of the Phases into Passes Pass – several phases may be grouped together into a pass that reads an input file and writes an output file. –Front End Lexical Analysis, Syntax Analysis, Semantic Analysis, and Intermediate Code Generation –Code Optimization Might be an optional pass. –Back End Code Generation for a specific target machine.
13
Chapter 1 - Introduction 13 2.9 Compiler-Construction Tools The compiler writer, like any software developer, can profitably use modern software development environments containing tools –Editor, debugger, version managers, profilers, test harnesses, … There are also tools to help implement various phases of a compiler. –Scanner Generator, Parser generator, …
14
Chapter 1 - Introduction 14
15
Chapter 1 - Introduction 15 3. The Evolution of Programming Languages
16
Chapter 1 - Introduction 16 3.1 The Move to Higher-Level Languages
17
Chapter 1 - Introduction 17 3.2 Impacts on Compilers
18
Chapter 1 - Introduction 18 4. The Science of Building a Compiler
19
Chapter 1 - Introduction 19 4.1 Modeling in Compiler Design and Implementation
20
Chapter 1 - Introduction 20 4.2 The Science of Code Optimization
21
Chapter 1 - Introduction 21 5. Applications of Compiler Technology
22
Chapter 1 - Introduction 22 5.1 Implementation of High Level Programming Languages
23
Chapter 1 - Introduction 23 5.2 Optimizations for Computer Architectures
24
Chapter 1 - Introduction 24 5.3 Design of New Computer Architectures
25
Chapter 1 - Introduction 25 5.4 Program Translations
26
Chapter 1 - Introduction 26 5.5 Software Productivity Tools
27
Chapter 1 - Introduction 27 6. Programming Language Basics
28
Chapter 1 - Introduction 28 6.1 The Static/Dynamic Distinction
29
Chapter 1 - Introduction 29 6.2 Environments and States
30
Chapter 1 - Introduction 30 6.3 Static Scope andBlock Structure
31
Chapter 1 - Introduction 31 6.4 Explicit Access Control
32
Chapter 1 - Introduction 32 6.5 Dynamic Scope
33
Chapter 1 - Introduction 33 6.6 Parameter Passing Mechanisms
34
Chapter 1 - Introduction 34 6.7 Aliasing
35
Chapter 1 - Introduction 35 7. Summary
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.