This document discusses different types of language processors: assemblers, interpreters, and compilers. It provides details on each type and their functions. The document also describes the compilation process, which occurs in two phases: analysis and code generation. Analysis includes lexical analysis, syntax analysis, and producing symbol tables and parse trees. Code generation takes the intermediate code from analysis and produces the object program code. Optimization aims to improve the efficiency of the generated code.
The document provides an introduction to compiler design, including:
- A compiler converts a program written in a high-level language into machine code. It can run on a different machine than the target.
- Language processing systems like compilers transform high-level code into a form usable by machines through a series of translations.
- A compiler analyzes source code in two main phases - analysis and synthesis. The analysis phase creates an intermediate representation, and the synthesis phase generates target code from that.
The document discusses the phases of a compiler:
- Lexical analysis breaks the source code into tokens by grouping characters into lexemes. Each lexeme is mapped to a token with an abstract symbol and attribute value.
- Syntax analysis (parsing) uses the tokens to build a syntax tree that represents the grammatical structure.
- Semantic analysis checks the syntax tree and symbol table for semantic consistency with the language definition and gathers type information.
- Later phases include intermediate code generation, optimization, and code generation to produce the target code.
The document provides an introduction to compilers, including definitions of key terms like compiler, interpreter, assembler, translator, and phases of compilation like lexical analysis, syntax analysis, semantic analysis, code generation, and optimization. It also discusses compiler types like native compilers, cross compilers, source-to-source compilers, and just-in-time compilers. The phases of a compiler include breaking down a program, generating intermediate code, optimizing, and creating target code.
A compiler acts as a translator that converts programs written in high-level human-readable languages into machine-readable low-level languages. Compilers are needed because computers can only understand machine languages, not human languages. A compiler performs analysis and synthesis on a program, breaking the process into phases like scanning, parsing, code generation, and optimization to translate the high-level code into an executable form. The phases include lexical analysis, syntax analysis, semantic analysis, code generation, and optimization.
This document provides an overview of compiler design and its various phases. It discusses the different phases of a compiler including lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, and code generation. It also describes the structure of a compiler and how it translates a source program through various representations and analyses until generating target code. Key concepts covered include context-free grammars, parsing techniques, symbol tables, intermediate representations, and code optimization.
The document discusses compiler design options and the differences between compilers and interpreters. It states that a compiler converts a high-level language program into machine code all at once, while an interpreter converts the program line-by-line at runtime. Compilers generally execute programs faster but take longer to compile, while interpreters execute more slowly but can compile incrementally and debug line-by-line. The document also covers pure and impure interpreters, p-code compilers, and the roles of compilers and interpreters.
The document discusses compilers and their design. It explains that compilers translate human-oriented programming languages into machine languages. It describes the typical structure of a compiler, which includes phases like scanning, parsing, semantic analysis, code generation and optimization. The document also discusses how programming language design and computer architecture influence compiler design considerations.
This document provides an introduction to compiler design, including definitions of key terms and an overview of the compiler construction process. It discusses what a compiler is, the differences between compilers and interpreters, and the advantages and disadvantages of each. The document then covers the major phases of compiler design: analysis, intermediate code generation, optimization, and code generation. It describes the roles of lexical analysis, parsing, semantic analysis, and code generation. Finally, it lists some common tools used in compiler construction.
This document provides lecture notes on compiler design. It discusses the structure of a compiler including phases like lexical analysis, syntax analysis, intermediate code generation, code optimization, code generation, table management and error handling. It also discusses different types of translators like compilers, interpreters and preprocessors. Finally, it discusses the evolution of programming languages, classification of languages and applications of compiler technology.
The document discusses the basics of compiler construction. It begins by defining key terms like compilers, source and target languages. It then describes the main phases of compilation as lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization and machine code generation. It also discusses symbol tables, compiler tools and generations of programming languages.
Language translators convert programming source code into machine language understood by computer processors. The three major types are compilers, assemblers, and interpreters. Compilers translate high-level languages into machine code in one or more passes, assemblers assemble assembly language into machine code, and interpreters analyze and execute each line of source code as the program runs without pre-translation.
COMPILER DESIGN IS A COURSE IN THE COMPUTER SCIENCE DEPARTMENT THAT DEALS WITH THE CONVERSION OF PROGRAMMING WRITTEN IN HIGH-LEVEL LANGUAGE INTO MACHINE LANGUAGE, IT INVOLVES MANY PHASES
The document summarizes the key phases of a compiler:
1. The compiler takes source code as input and goes through several phases including lexical analysis, syntax analysis, semantic analysis, code optimization, and code generation to produce machine code as output.
2. Lexical analysis converts the source code into tokens, syntax analysis checks the grammar and produces a parse tree, and semantic analysis validates meanings.
3. Code optimization improves the intermediate code before code generation translates it into machine instructions.
This document provides an introduction to compilers, including definitions of key terms like translator, compiler, interpreter, and assembler. It describes the main phases of compilation as lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, and code generation. It also discusses related concepts like the front-end and back-end of a compiler, multi-pass compilation, and different types of compilers.
An assembler translates assembly language instructions into machine code through a one-to-one mapping. An interpreter directly executes program source code line by line without compiling. A compiler translates high-level language source code into an executable machine code program.
This document provides an overview of compiler design and the different phases involved in compiling a program. It begins with defining a compiler as a program that translates code written in one programming language into another target language to be executed by a computer. The major phases of a compiler are then described as the analysis phase (front-end) which breaks down and analyzes the source code, and the synthesis phase (back-end) which generates the target code. Key phases in the front-end include lexical analysis, syntax analysis, and semantic analysis, while the back-end includes code optimization and code generation. Different types of compilers such as single-pass, two-pass, and multi-pass compilers are also introduced based on how many times
This document provides an overview of compiler design and the phases of a compiler. It discusses how compilers translate programs written in high-level languages into machine-executable code. The main phases of a compiler are lexical analysis, syntax analysis, code generation, and optional optimization phases. Lexical analysis breaks the source code into tokens. Syntax analysis checks for errors and determines the program structure. Code generation translates the program into machine code. Optimization aims to improve efficiency. Interpreters execute programs line-by-line rather than generating machine code.
The document discusses compilers and their role in translating high-level programming languages into machine-readable code. It notes that compilers perform several key functions: lexical analysis, syntax analysis, generation of an intermediate representation, optimization of the intermediate code, and finally generation of assembly or machine code. The compiler allows programmers to write code in a high-level language that is easier for humans while still producing efficient low-level code that computers can execute.
The compiler is software that converts source code written in a high-level language into machine code. It works in two major phases - analysis and synthesis. The analysis phase performs lexical analysis, syntax analysis, and semantic analysis to generate an intermediate representation from the source code. The synthesis phase performs code optimization and code generation to create the target machine code from the intermediate representation. The compiler uses various components like a symbol table, parser, and code generator to perform this translation.
This document provides an overview of the key components and phases of a compiler. It discusses that a compiler translates a program written in a source language into an equivalent program in a target language. The main phases of a compiler are lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, code generation, and symbol table management. Each phase performs important processing that ultimately results in a program in the target language that is equivalent to the original source program.
This document provides an overview of compilers and their various phases. It begins by introducing compilers and their importance for increasing programmer productivity and enabling reverse engineering. It then covers the classification of programming languages and the history of compilers. The rest of the document details each phase of the compiler process, including lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, code generation, and the role of the symbol table. It provides definitions and examples for each phase to explain how a source program is translated from a high-level language into executable machine code.
PREPARE FOR AN ALL-INDIA ODYSSEY!
THE QUIZ CLUB OF PSGCAS BRINGS YOU A QUIZ FROM THE PEAKS OF KASHMIR TO THE SHORES OF KUMARI AND FROM THE DHOKLAS OF KATHIAWAR TO THE TIGERS OF BENGAL.
QM: EIRAIEZHIL R K, THE QUIZ CLUB OF PSGCAS
As of 5/14/25, the Southwestern outbreak has 860 cases, including confirmed and pending cases across Texas, New Mexico, Oklahoma, and Kansas. Experts warn this is likely a severe undercount. The situation remains fluid, with case numbers expected to rise. Experts project the outbreak could last up to a year.
CURRENT CASE COUNT: 860 (As of 5/14/2025)
Texas: 718 (+6) (62% of cases are in Gaines County)
New Mexico: 71 (92.4% of cases are from Lea County)
Oklahoma: 17
Kansas: 54 (+6) (38.89% of the cases are from Gray County)
HOSPITALIZATIONS: 102 (+2)
Texas: 93 (+1) - This accounts for 13% of all cases in Texas.
New Mexico: 7 – This accounts for 9.86% of all cases in New Mexico.
Kansas: 2 (+1) - This accounts for 3.7% of all cases in Kansas.
DEATHS: 3
Texas: 2 – This is 0.28% of all cases
New Mexico: 1 – This is 1.41% of all cases
US NATIONAL CASE COUNT: 1,033 (Confirmed and suspected)
INTERNATIONAL SPREAD (As of 5/14/2025)
Mexico: 1,220 (+155)
Chihuahua, Mexico: 1,192 (+151) cases, 1 fatality
Canada: 1,960 (+93) (Includes Ontario’s outbreak, which began November 2024)
Ontario, Canada – 1,440 cases, 101 hospitalizations
Ad
More Related Content
Similar to Introduction to Compiler Design Structutre, Phases (20)
This document provides an overview of compiler design and its various phases. It discusses the different phases of a compiler including lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, and code generation. It also describes the structure of a compiler and how it translates a source program through various representations and analyses until generating target code. Key concepts covered include context-free grammars, parsing techniques, symbol tables, intermediate representations, and code optimization.
The document discusses compiler design options and the differences between compilers and interpreters. It states that a compiler converts a high-level language program into machine code all at once, while an interpreter converts the program line-by-line at runtime. Compilers generally execute programs faster but take longer to compile, while interpreters execute more slowly but can compile incrementally and debug line-by-line. The document also covers pure and impure interpreters, p-code compilers, and the roles of compilers and interpreters.
The document discusses compilers and their design. It explains that compilers translate human-oriented programming languages into machine languages. It describes the typical structure of a compiler, which includes phases like scanning, parsing, semantic analysis, code generation and optimization. The document also discusses how programming language design and computer architecture influence compiler design considerations.
This document provides an introduction to compiler design, including definitions of key terms and an overview of the compiler construction process. It discusses what a compiler is, the differences between compilers and interpreters, and the advantages and disadvantages of each. The document then covers the major phases of compiler design: analysis, intermediate code generation, optimization, and code generation. It describes the roles of lexical analysis, parsing, semantic analysis, and code generation. Finally, it lists some common tools used in compiler construction.
This document provides lecture notes on compiler design. It discusses the structure of a compiler including phases like lexical analysis, syntax analysis, intermediate code generation, code optimization, code generation, table management and error handling. It also discusses different types of translators like compilers, interpreters and preprocessors. Finally, it discusses the evolution of programming languages, classification of languages and applications of compiler technology.
The document discusses the basics of compiler construction. It begins by defining key terms like compilers, source and target languages. It then describes the main phases of compilation as lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization and machine code generation. It also discusses symbol tables, compiler tools and generations of programming languages.
Language translators convert programming source code into machine language understood by computer processors. The three major types are compilers, assemblers, and interpreters. Compilers translate high-level languages into machine code in one or more passes, assemblers assemble assembly language into machine code, and interpreters analyze and execute each line of source code as the program runs without pre-translation.
COMPILER DESIGN IS A COURSE IN THE COMPUTER SCIENCE DEPARTMENT THAT DEALS WITH THE CONVERSION OF PROGRAMMING WRITTEN IN HIGH-LEVEL LANGUAGE INTO MACHINE LANGUAGE, IT INVOLVES MANY PHASES
The document summarizes the key phases of a compiler:
1. The compiler takes source code as input and goes through several phases including lexical analysis, syntax analysis, semantic analysis, code optimization, and code generation to produce machine code as output.
2. Lexical analysis converts the source code into tokens, syntax analysis checks the grammar and produces a parse tree, and semantic analysis validates meanings.
3. Code optimization improves the intermediate code before code generation translates it into machine instructions.
This document provides an introduction to compilers, including definitions of key terms like translator, compiler, interpreter, and assembler. It describes the main phases of compilation as lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, and code generation. It also discusses related concepts like the front-end and back-end of a compiler, multi-pass compilation, and different types of compilers.
An assembler translates assembly language instructions into machine code through a one-to-one mapping. An interpreter directly executes program source code line by line without compiling. A compiler translates high-level language source code into an executable machine code program.
This document provides an overview of compiler design and the different phases involved in compiling a program. It begins with defining a compiler as a program that translates code written in one programming language into another target language to be executed by a computer. The major phases of a compiler are then described as the analysis phase (front-end) which breaks down and analyzes the source code, and the synthesis phase (back-end) which generates the target code. Key phases in the front-end include lexical analysis, syntax analysis, and semantic analysis, while the back-end includes code optimization and code generation. Different types of compilers such as single-pass, two-pass, and multi-pass compilers are also introduced based on how many times
This document provides an overview of compiler design and the phases of a compiler. It discusses how compilers translate programs written in high-level languages into machine-executable code. The main phases of a compiler are lexical analysis, syntax analysis, code generation, and optional optimization phases. Lexical analysis breaks the source code into tokens. Syntax analysis checks for errors and determines the program structure. Code generation translates the program into machine code. Optimization aims to improve efficiency. Interpreters execute programs line-by-line rather than generating machine code.
The document discusses compilers and their role in translating high-level programming languages into machine-readable code. It notes that compilers perform several key functions: lexical analysis, syntax analysis, generation of an intermediate representation, optimization of the intermediate code, and finally generation of assembly or machine code. The compiler allows programmers to write code in a high-level language that is easier for humans while still producing efficient low-level code that computers can execute.
The compiler is software that converts source code written in a high-level language into machine code. It works in two major phases - analysis and synthesis. The analysis phase performs lexical analysis, syntax analysis, and semantic analysis to generate an intermediate representation from the source code. The synthesis phase performs code optimization and code generation to create the target machine code from the intermediate representation. The compiler uses various components like a symbol table, parser, and code generator to perform this translation.
This document provides an overview of the key components and phases of a compiler. It discusses that a compiler translates a program written in a source language into an equivalent program in a target language. The main phases of a compiler are lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, code generation, and symbol table management. Each phase performs important processing that ultimately results in a program in the target language that is equivalent to the original source program.
This document provides an overview of compilers and their various phases. It begins by introducing compilers and their importance for increasing programmer productivity and enabling reverse engineering. It then covers the classification of programming languages and the history of compilers. The rest of the document details each phase of the compiler process, including lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, code generation, and the role of the symbol table. It provides definitions and examples for each phase to explain how a source program is translated from a high-level language into executable machine code.
PREPARE FOR AN ALL-INDIA ODYSSEY!
THE QUIZ CLUB OF PSGCAS BRINGS YOU A QUIZ FROM THE PEAKS OF KASHMIR TO THE SHORES OF KUMARI AND FROM THE DHOKLAS OF KATHIAWAR TO THE TIGERS OF BENGAL.
QM: EIRAIEZHIL R K, THE QUIZ CLUB OF PSGCAS
As of 5/14/25, the Southwestern outbreak has 860 cases, including confirmed and pending cases across Texas, New Mexico, Oklahoma, and Kansas. Experts warn this is likely a severe undercount. The situation remains fluid, with case numbers expected to rise. Experts project the outbreak could last up to a year.
CURRENT CASE COUNT: 860 (As of 5/14/2025)
Texas: 718 (+6) (62% of cases are in Gaines County)
New Mexico: 71 (92.4% of cases are from Lea County)
Oklahoma: 17
Kansas: 54 (+6) (38.89% of the cases are from Gray County)
HOSPITALIZATIONS: 102 (+2)
Texas: 93 (+1) - This accounts for 13% of all cases in Texas.
New Mexico: 7 – This accounts for 9.86% of all cases in New Mexico.
Kansas: 2 (+1) - This accounts for 3.7% of all cases in Kansas.
DEATHS: 3
Texas: 2 – This is 0.28% of all cases
New Mexico: 1 – This is 1.41% of all cases
US NATIONAL CASE COUNT: 1,033 (Confirmed and suspected)
INTERNATIONAL SPREAD (As of 5/14/2025)
Mexico: 1,220 (+155)
Chihuahua, Mexico: 1,192 (+151) cases, 1 fatality
Canada: 1,960 (+93) (Includes Ontario’s outbreak, which began November 2024)
Ontario, Canada – 1,440 cases, 101 hospitalizations
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleCeline George
One of the key aspects contributing to efficient sales management is the variety of views available in the Odoo 18 Sales module. In this slide, we'll explore how Odoo 18 enables businesses to maximize sales insights through its Kanban, List, Pivot, Graphical, and Calendar views.
How to Share Accounts Between Companies in Odoo 18Celine George
In this slide we’ll discuss on how to share Accounts between companies in odoo 18. Sharing accounts between companies in Odoo is a feature that can be beneficial in certain scenarios, particularly when dealing with Consolidated Financial Reporting, Shared Services, Intercompany Transactions etc.
How to Manage Amounts in Local Currency in Odoo 18 PurchaseCeline George
In this slide, we’ll discuss on how to manage amounts in local currency in Odoo 18 Purchase. Odoo 18 allows us to manage purchase orders and invoices in our local currency.
This presentation has been made keeping in mind the students of undergraduate and postgraduate level. To keep the facts in a natural form and to display the material in more detail, the help of various books, websites and online medium has been taken. Whatever medium the material or facts have been taken from, an attempt has been made by the presenter to give their reference at the end.
The Lohar dynasty of Kashmir is a new chapter in the history of ancient India. We get to see an ancient example of a woman ruling a dynasty in the Lohar dynasty.
INSULIN.pptx by Arka Das (Bsc. Critical care technology)ArkaDas54
insulin resistance are known to be involved.Type 2 diabetes is characterized by increased glucagon secretion which is unaffected by, and unresponsive to the concentration of blood glucose. But insulin is still secreted into the blood in response to the blood glucose. As a result, glucose accumulates in the blood.
The human insulin protein is composed of 51 amino acids, and has a molecular mass of 5808 Da. It is a heterodimer of an A-chain and a B-chain, which are linked together by disulfide bonds. Insulin's structure varies slightly between species of animals. Insulin from non-human animal sources differs somewhat in effectiveness (in carbohydrate metabolism effects) from human insulin because of these variations. Porcine insulin is especially close to the human version, and was widely used to treat type 1 diabetics before human insulin could be produced in large quantities by recombinant DNA technologies.
How to Add Button in Chatter in Odoo 18 - Odoo SlidesCeline George
Improving user experience in Odoo often involves customizing the chatter, a central hub for communication and updates on specific records. Adding custom buttons can streamline operations, enabling users to trigger workflows or generate reports directly.
How to Manage Manual Reordering Rule in Odoo 18 InventoryCeline George
Reordering rules in Odoo 18 help businesses maintain optimal stock levels by automatically generating purchase or manufacturing orders when stock falls below a defined threshold. Manual reordering rules allow users to control stock replenishment based on demand.
How to Use Upgrade Code Command in Odoo 18Celine George
In this slide, we’ll discuss on how to use upgrade code Command in Odoo 18. Odoo 18 introduced a new command-line tool, upgrade_code, designed to streamline the migration process from older Odoo versions. One of its primary functions is to automatically replace deprecated tree views with the newer list views.
2. Syllabus:
Translator – Compilation and Interpretation, language processors; The phase of compiler – Errors
Encountered in Different Phases, The Grouping of phases; Compiler Construction Tools; Programming
Language Basics.
SYLLABUS
3. TRANSLATOR
Translator is a program that takes as input a program written in one
programming language (the source language) and produces as output a program
in another language (the object or target language).
4. COMPILER
A compiler is a program that can read a program in one language, the
source language, and translate it into an equivalent program in another
language - the target language
5. If the target program is an executable machine-
language program, it can then be called by the
user to process inputs and produce outputs;
Note:An important role of the
compiler is to report any
errors in the source program
that it detects during the
translation process.
6. INTERPRETER
An interpreter is another common kind of language processor.
Instead of producing a target program as a translation, an interpreter
appears to directly execute the operations specified in the source
program on inputs supplied by the user.
7. The machine-language target program produced by a compiler is usually
much faster than an interpreter at mapping inputs to outputs .
An interpreter, however, can usually give better error diagnostics than a
compiler, because it executes the source program statement by statement
8. • Java language processors combine compilation and interpretation.
• A Java source program may first be compiled into an intermediate form called
bytecodes interpreted by virtual machine.
compiled on one machine can be
interpreted on another machine
across a network
Achieve faster processing of inputs to outputs:
Java compilers, called just-in-time compilers, translate
the bytecodes into machine language immediately before
they run the intermediate program to process the input
11. • A source program may be divided into modules stored in separate files.
• The task of collecting the source program is sometimes entrusted to a
separate program, called a preprocessor.
• The preprocessor may also expand shorthand's, called macros, into
source language statements.
12. • The modified source program is then fed to a compiler.
• The compiler may produce an assembly-language program as its output,
because assembly language is easier to produce as output and is easier to
debug.
13. • The assembly language is then processed by a program called an assembler that
produces relocatable machine code as its output.
• Large programs are often compiled in pieces, so the relocatable machine code may
have to be linked together with other relocatable object files and library files into
the code that actually runs on the machine.
14. • The linker resolves external memory addresses, where the code in one file may refer
to a location in another file.
• The loader then puts together all of the executable object files into memory for
execution.
15. THE STRUCTURE OF A COMPILER
• A compiler is treated as a single box that maps a source program into a semantically
equivalent target program.
• There are two parts to this mapping: analysis part and synthesis part
• The analysis part is often called the front end of the compiler; the synthesis part is the
back end of the compiler.
16. ANALYSIS
It breaks up the source program into constituent pieces and imposes a grammatical structure
on them.
It detects that the source program is either syntactically ill formed or semantically unsound, then it must
provide informative messages, so the user can take corrective action
This structure to create an intermediate representation of the source program
It also collects information about the source program and stores it in a data structure called a
symbol table, which is passed along with the intermediate representation to the synthesis part
17. SYNTHESIS
• In this part, it constructs the desired target program from the
intermediate representation and the information in the symbol table
18. THE PHASES OF A COMPILER
The symbol table, which
stores information about
the entire source
program, is used by all
phases of the compiler
The purpose of this optimization phase
is to perform transformations on the
intermediate representation, the
backend can produce a better target
program
19. HOW DOES ITWORKING
19
Scanner Parser
Semantic
Routines
Code
Generator
Optimizer
Source
Program Tokens Syntactic
Structure
Symbol and
Attribute
Tables
(Used by all Phases of The Compiler)
(Character Stream)
Intermediate
Representation
Target machine code
20. 20
THE STRUCTURE OF A COMPILER (3)
Scanner Parser
Semantic
Routines
Code
Generator
Optimizer
Source
Program Tokens Syntactic
Structure
Symbol and
Attribute
Tables
(Used by all
Phases of
The Compiler)
Scanner
The scanner begins the analysis of the source program by reading the input,
character by character, and grouping characters into individual words and
symbols (tokens)
RE ( Regular expression )
NFA ( Non-deterministic Finite Automata )
DFA ( Deterministic Finite Automata )
LEX
(Character Stream)
Intermediate
Representation
Target machine code
21. 21
THE STRUCTURE OF A COMPILER (4)
Scanner Parser
Semantic
Routines
Code
Generator
Optimizer
Source
Program Tokens Syntactic
Structure
Symbol and
Attribute
Tables
(Used by all
Phases of
The Compiler)
Parser
Given a formal syntax specification (typically as a context-free grammar
[CFG] ), the parse reads tokens and groups them into units as specified by the
productions of the CFG being used.
As syntactic structure is recognized, the parser either calls corresponding
semantic routines directly or builds a syntax tree.
CFG ( Context-Free Grammar )
BNF ( Backus-Naur Form )
GAA ( Grammar Analysis Algorithms )
LL, LR, SLR, LALR Parsers
YACC
(Character Stream)
Intermediate
Representation
Target machine code
22. 22
THE STRUCTURE OF A COMPILER (5)
Scanner Parser
Semantic
Routines
Code
Generator
Optimizer
Source
Program
(Character Stream)
Tokens Syntactic
Structure
Intermediate
Representation
Symbol and
Attribute
Tables
(Used by all
Phases of
The Compiler)
Semantic Routines
Perform two functions
Check the static semantics of each construct
Do the actual translation
The heart of a compiler
Syntax Directed Translation
Semantic Processing Techniques
IR (Intermediate Representation)
Target machine code
23. 23
THE STRUCTURE OF A COMPILER (6)
Scanner Parser
Semantic
Routines
Code
Generator
Optimizer
Source
Program Tokens Syntactic
Structure
Symbol and
Attribute
Tables
(Used by all
Phases of
The Compiler)
Optimizer
The IR code generated by the semantic routines is analyzed and transformed
into functionally equivalent but improved IR code
This phase can be very complex and slow
Peephole optimization
loop optimization, register allocation, code scheduling
Register and Temporary Management
Peephole Optimization
(Character Stream)
Intermediate
Representation
Target machine code
24. 24
THE STRUCTURE OF A COMPILER (7)
Source
Program
(Character Stream)
Scanner
Tokens
Parser
Syntactic
Structure
Semantic
Routines
Intermediate
Representation
Optimizer
Code
Generator
Code Generator
Interpretive Code Generation
Generating Code from Tree/Dag
Grammar-Based Code Generator
Target machine code
25. 25
THE STRUCTURE OF A COMPILER (8)
Scanner
[Lexical Analyzer]
Parser
[Syntax Analyzer]
Semantic Process
[Semantic analyzer]
Code Generator
[Intermediate Code Generator]
Code Optimizer
Tokens
Parse tree
Abstract Syntax Tree w/ Attributes
Non-optimized Intermediate Code
Optimized Intermediate Code
Code Optimizer
Target machine code