A compiler is a program that translates source code written in one programming language into another language. It performs two main tasks: analysis of the source program and synthesis of a machine-language program. The structure of a compiler typically includes a scanner, parser, semantic routines, code generator, and optimizer. The scanner reads the source code and groups characters into tokens. The parser checks the syntax against a grammar. Semantic routines perform static checking and translation. The code generator produces target code, which may then be optimized. An example compiler output is shown translating a sample program into assembly code.
In this PPT we covered all the points like..Introduction to compilers - Design issues, passes, phases, symbol table
Preliminaries - Memory management, Operating system support for compiler, Compiler support for garbage collection ,Lexical Analysis - Tokens, Regular Expressions, Process of Lexical analysis, Block Schematic, Automatic construction of lexical analyzer using LEX, LEX features and specification.
In this PPT we covered all the points like..Introduction to compilers - Design issues, passes, phases, symbol table
Preliminaries - Memory management, Operating system support for compiler, Compiler support for garbage collection ,Lexical Analysis - Tokens, Regular Expressions, Process of Lexical analysis, Block Schematic, Automatic construction of lexical analyzer using LEX, LEX features and specification.
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
2. COMPILER
A compiler is a computer program that transforms
source code written in a programming language (the
source language) into another computer language (the
target language), with the latter takes binary form
known as object code
It create an executable program
2
3. Cause
Software for early computers was written in
assembly language
The benefits of reusing software on
different CPUs started to become
significantly greater than the cost of writing
a compiler
The first real compiler
FORTRAN compilers of the late 1950s
18 person-years to build
3
4. Any compiler must perform two major tasks
Analysis of the source program
Synthesis of a machine-language program
Structure of Compiler
4
5. THE STRUCTURE OF A COMPILER (2)
5
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
6. THE STRUCTURE OF A COMPILER (3)
6
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
7. THE STRUCTURE OF A COMPILER (4)
7
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 [CFG] ),
the parse reads tokens and groups them icontext-free
grammar nto 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
8. THE STRUCTURE OF A COMPILER (5)
8
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
9. THE STRUCTURE OF A COMPILER (6)
9
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
10. THE STRUCTURE OF A COMPILER (7)
10
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
11. THE STRUCTURE OF A COMPILER (8)
11
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 Cod
Optimized Intermediate Code
Code Optimizer
Target machine code
12. Language Description
Identifier Rules
•Identifier can be of maximum length 6.
•Identifiers are not case sensitive.
•An Indetifier can only have alphanumeric characters( a-z
, A-Z , 0-9 ) and underscore(_).
•The first character of an identifier can only contain
alphabet( a-z , A-Z ).
•Keywords are not allowed to be used as Identifiers.
•No special characters, such as semicolon, period,
whitespaces, slash or comma are permitted to be used in
or as Identifier.
12
13. Data Types:
Our language supports only 3 datatypes
•Integer
•String
•Character
Expressions
1.Arithmetic operators (+, -, *, /, %)
2.Uniray operator
3.Paranthesis
4.Only Integer supported
5.Relational expression to be supported (>, <, >=, <=, ==, !=)
6. Character string and integer constants
13
14. Statements
•Declaration statement : int a;
•Declaration and Initialisation : int a=5;
•Assingment Statement : a=6;
Conditional statement
Simple if (nesting not allowed)
if then
Endif
Switch Statement (nesting not allowed)
Switch()
Cases
Value 1:
Break;
Value n:
break;
Endcase
14
15. Repetition Statement (nesting not allowed)
a.Repeat
Until ()
a.While (relational expression)
Endwhile
a.For = start value, end value, inc/dec
………
Endfor
4
I/O Statement
•Input ;
•Output ;
Program Structure
Decleration:
Start
End 15
16. 1.Sample Program I
#mode 10
declaration
int r
int c
int in
int flg
start
r = 0
flg = 1
while( flg == 1 )
if( c == 0) then
flg = 0
endif
c = c-1
endwhile
end
16
18. Sample Program II
#mode 10
declaration
int a ; b
int i
int k
string mes1
start
k=k*1
if(i<9 )then
i=i+9
k=k*1
endif
i=i-45
repeat
i=i+9*k+b
k=k*1
output "Hello World"
input k
until(i<2 )
while(k>3 )
i=i+9
k=k*1 endwhile
end
18
19. OUTPUT
START:
MOV AX, @DATA
MOV DS, AX
MOV AX, k
MUL 1
MOV k, AX
MOV AX, i
CMP AX, 9
JGE LB01
MOV AX, i
ADD AX, 9
MOV i, AX
MOV AX, k
MUL 1
MOV k, AX
LB01:
MOV AX, i
SUB AX, 45
MOV i, AX
LB02:
MOV AX, i
ADD AX, 9
MUL k
ADD AX, b
MOV i, AX
MOV AX, k
MUL 1
MOV k, AX 19
20. OUTPUT
LEA DX, "Hello World"
CALL MESSAGE
CALL INDEC
MOV k, AX
MOV AX, i
CMP AX, 2
JGE LB01
LB03:
MOV AX,
CMP AX, 3
JLE LB01
MOV AX, i
ADD AX, 9
MOV i, AX
MOV AX, k
MUL 1
MOV k, AX
JMP LB01
MOV AX, i
ADD AX, 9
MOV i, AX
MOV AX, k
MUL 1
MOV k, AX
JMP LB01
LB04:
MOV AX, 4C00H
INT 21H
END START
20
24. Feasibility and future scope
With the growth of technology ease of working is given
priority.
We have emerged from C , C++ to python ,ruby , etc. which
require less lines of code .
Our project can be extended to form a new language which is
easy to learn, faster , has more inbuilt features and has many
more qualities of a good programming language.
24
25. Conclusion
In a compiler the process of Intermediate code generation is
independent of machine and the process of conversion of
Intermediate code to target code is independent of language
used.
Thus we have done the front end of compilation process.
It includes 3 phases of compilation
lexical analysis
syntax analysis
semantic analysis
Followed by intermediate code generation.
25
26. References
•Salomaa, Arto [1973]. Formal Languages. Academic Press,
New York
•Schulz, Waldean A. [1976]. Semantic Analysis and Target
Language Synthesis in a Translator.Ph.D. thesis, University of
Colorado, Boulder, CO.
•https://www.cs.vt.edu/undergraduate/courses/CS4304
26