Compilers

  • Uploaded by: Jenny Rose G. Sison
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Compilers as PDF for free.

More details

  • Words: 489
  • Pages: 11
Compilers

Why Study Compilers? 

Compilers enable programming at a high level language instead of machine instructions.  Portability,

Modularity, Simplicity, Programmer Productivity  Also Efficiency and Performance

Compilers Construction touches many topics in Computer Science 

Theory 



Algorithms 



Graph manipulation, dynamic programming

Data structures 



Finite State Automata, Grammars and Parsing, data-flow

Symbol tables, abstract syntax trees

Systems 

Allocation and naming, multi-pass systems, compiler construction

Compilers Construction touches many topics in Computer Science... 

Computer Architecture 



Security 



Detection of and Protection against vulnerabilities

Software Engineering 



Memory hierarchy, instruction selection, interlocks and latencies

Software development environments, debugging

Artificial Intelligence 

Heuristic based search

How to instruct the computer • Write a program using a programming language – High-level Abstract Description

• Microprocessors talk in assembly language – Low-level Implementation Details Program written in a Programming Languages

Compiler

Assembly Language Translation

How to instruct the computer Input: High-level programming language  Output: Low-level assembly instructions 



Compiler does the translation:  Read

and understand the program  Precisely determine what actions it require  Figure-out how to faithfully carry-out those actions  Instruct the computer to carry out those actions

Input to the Compiler 

Standard imperative language(Java,C,C++)  State

Variables,  Structures,  Arrays 

 Computation

Expressions (arithmetic, logical, etc.)  Assignment statements  Control flow (conditionals, loops)  Procedures 

Output of the Compiler 

State  Registers  Memory



with Flat Address Space

Machine code – load/store architecture  Load,

store instructions  Arithmetic, logical operations on registers  Branch instructions

Compilers 



 



A compiler is a program that reads a program in one language, the source language and translates into an equivalent program in another language, the target language. The translation process should also report the presence of errors in the source program. Source Program→ Compiler→Target Program ↓ Error Messages There are two parts of compilation. The analysis part breaks up the source program into constant piece and creates an intermediate representation of the source program. The synthesis part constructs the desired target program from the intermediate representation.

Phases of Compiler 

The compiler has a number of phases plus symbol table manager and an error handler. Input Source Program ↓ Lexical Analyzer ↓ Syntax Analyzer ↓ Symbol Table Manager Semantic Analyzer ↓ Intermediate Code Generator ↓ Code Optimizer ↓ Code Generator ↓ Out Target Program

Error Handler

Compilers 

The cousins of the compiler are 1. 2. 3.

   

Preprocessor. Assembler. Loader and Link-editor.

Lexical analyzer takes the source program as an input and produces a long string of tokens. Syntax Analyzer takes an out of lexical analyzer and produces a large tree. Semantic analyzer takes the output of syntax analyzer and produces another tree. Similarly, intermediate code generator takes a tree as an input produced by semantic analyzer and produces intermediate code.

Related Documents


More Documents from ""

Color Codes
May 2020 24
Systems Development Life 2
October 2019 36
Kinematics
May 2020 27
Webdev Lesson3
November 2019 28
Data Gathering
October 2019 27