A
PROJECT PRESENTATION
ON
BY
GROUP2:
ILIAS AHMED
ARIFUL ISLAM
TASNIA ISLAM
MD.ABDUR RAHIM
KHAN
GROUP 2 DESIGN BY 1
Project presentation submitted to
 Taneja Ane
 Lecturer Of
 Peoples university
of Bangladesh
GROUP 2 DESIGN BY 2
OBJECTIVE OF THE
PROJECT
LEXICAL ANALYSIS
SYNTAX ANALYSIS
SYMBOL TABLE
PARSE TREE
GROUP 2 DESIGN BY 3
WHAT IS A
COMPILER?
A Compiler is a SYSTEM
Software to convert Higher level
code to Machine level code
without changing the purpose of
the HLL code.
GROUP 2 DESIGN BY 4
NEED OF A
COMPILER
A Compiler allows a
Programmer to
write a program in
HLL irrespective of
the underlying
Hardware
configuration.GROUP 2 DESIGN BY 5
GROUP 2 DESIGN BY 6
Lexical Analysis or Linear Analysis or
Scanning, in which the stream
of characters making up the source
program is read from left-to-right and
grouped in to tokens, sequence of
characters having a collective meaning.
The
blanks separating the characters of the
tokens and the comments statements
appearing within the program would be
eliminated during lexical analysis.
GROUP 2 DESIGN BY 7
GROUP 2 DESIGN BY 8
FUNCTION OF LEXICAL ANALYSIS
1) CONVERT THE SOURCE CODE INTO STREAM OF
TOKENS
2) REMOVING WHILE SPACES
3) REMOVING COMMENTS
4) RECOGNIZE KEYWORD AND IDENTIFER
5) RECOGNIZEING OF CONSTANT
6) SHOW ERROR WHEN THE LEXEME DOES NOT
MAKE PATTREN
GROUP 2 DESIGN BY 9
ROLE OF LEXICAL ANALYSIS
1:1ST PHASE OF COMPILER
2: READ I/P CHRACTER AND PRODUCE
O/P SEQUENCE OF TOKENS THAT
THE PARSER
3:USES FOR SYNTAX ANALYSIS
4:LA ELEMINATING COMMENTS AND WHITE
SPACES
5:GENRATING ERROR MESSAGE AND
CORECTING IT WITH SOURCE PROGRAM
TOKEN LEXEME AND STRING
 A lexeme is a sequence of characters in the source
program that matches the pattern for a token and is
identified by the lexical analyzer as an instance of
that token. A token is a pair consisting of
a token name and an optional attribute value. ...
The token names are the input symbols that the
parser processes .String within double quote some
LEXEME PATTERNTOKEN
EXAMPLE OF
GROUP 2 DESIGN BY 10
TOKEN PATTREN LEXEME
IF Character if
else Character
e,l,s,e
else
comparisin <or. Or
<=or>=
<= !=
id Letter
followed
letter and
digit
Pi,score,d2
Example of token pattern and lexeme
GROUP 2 DESIGN BY 11
GROUP 2 DESIGN BY 12
HOW MANY TOKEN ARE THRE?CAN
ANYONE SAY PLEASE
DOUBLE SALARY=BASIC SALARY +
‘HOUSE RENT +BONUS*30%’;
GROUP 2 DESIGN BY 13
HOW MANY LEXEME ARE THERE?
E=M*C**2;
GROUP 2 DESIGN BY 14
SYNTAX ANALYSIS
Syntax Analysis or Hierarchical
Analysis, in which characters or tokens
are grouped hierarchically into nested
collections with collective meaning.
Hierarchical analysis also termed as
Parsing, involves grouping the tokens of
the source program into grammatical
phrases that are used by the compiler
to synthesize output. Usually, the
grammatical phrases of the source
program are represented by a Parse
tree.GROUP 2 DESIGN BY 15
GROUP 2 DESIGN BY 16
Float position, initial, rate
Position =initial +rate*60
LA
SYNTAX ANALYZER
ID1=ID2+ID3*60
PARSE TREE /SYNTAX TREE
S=>ID=E
E=>E+T/T
T=>T*T/F
E=>ID/NUM
grammer
GROUP 2 DESIGN BY 17
WHEN WE COMPRESS PARSE TREE
OPERATION WILL BE INTERNAL NODE
AND OPERAND WILL BE LEAVE NODE
INTERNAL NODE=OPERATOR
LEAVE NODE=OPERAND
GROUP 2 DESIGN BY 18
GROUP 2 DESIGN BY 19
SYNTAX TREE
GROUP 2 DESIGN BY 20
A symbol table is a data structure
containing a record for each
identifier, with fields for the
attributes of the identifier. The data
structure allows us to find the
record for each identifier quickly and
to store or retrieve data from that
record quickly.
SYMBOL TABLE
GROUP 2 DESIGN BY
S/N V/N V/TYPE
01 POSITION FLOAT
02 INITIAL FLOAT
03 RATE FLOAT
FLOAT POSITION,INITIAL,RATE
POSITION = INITIAL +RATE * 60
<TOKEN NAME,ATTRIBUTE VALUE>
<ID1,1><=><ID2,2><+><ID3,3><*><60>
GROUP 2 DESIGN BY 22
GROUP 2 DESIGN BY 23
Requirements for symbol table management
• quick insertion of an identifier
• quick search for an identifier
• efficient insertion of information (attributes)
about an id
• quick access to information about a certain id
• Space- and time- efficiency
GROUP 2 DESIGN BY 24
THANKS ALL
GROUP 2 DESIGN BY 25
GOOD BYE
GROUP 2 DESIGN BY 26
GROUP 2 DESIGN BY 27
GROUP 2 DESIGN BY 28
GROUP 2 DESIGN BY 29

Compiler designs presentation final

  • 1.
    A PROJECT PRESENTATION ON BY GROUP2: ILIAS AHMED ARIFULISLAM TASNIA ISLAM MD.ABDUR RAHIM KHAN GROUP 2 DESIGN BY 1
  • 2.
    Project presentation submittedto  Taneja Ane  Lecturer Of  Peoples university of Bangladesh GROUP 2 DESIGN BY 2
  • 3.
    OBJECTIVE OF THE PROJECT LEXICALANALYSIS SYNTAX ANALYSIS SYMBOL TABLE PARSE TREE GROUP 2 DESIGN BY 3
  • 4.
    WHAT IS A COMPILER? ACompiler is a SYSTEM Software to convert Higher level code to Machine level code without changing the purpose of the HLL code. GROUP 2 DESIGN BY 4
  • 5.
    NEED OF A COMPILER ACompiler allows a Programmer to write a program in HLL irrespective of the underlying Hardware configuration.GROUP 2 DESIGN BY 5
  • 6.
  • 7.
    Lexical Analysis orLinear Analysis or Scanning, in which the stream of characters making up the source program is read from left-to-right and grouped in to tokens, sequence of characters having a collective meaning. The blanks separating the characters of the tokens and the comments statements appearing within the program would be eliminated during lexical analysis. GROUP 2 DESIGN BY 7
  • 8.
    GROUP 2 DESIGNBY 8 FUNCTION OF LEXICAL ANALYSIS 1) CONVERT THE SOURCE CODE INTO STREAM OF TOKENS 2) REMOVING WHILE SPACES 3) REMOVING COMMENTS 4) RECOGNIZE KEYWORD AND IDENTIFER 5) RECOGNIZEING OF CONSTANT 6) SHOW ERROR WHEN THE LEXEME DOES NOT MAKE PATTREN
  • 9.
    GROUP 2 DESIGNBY 9 ROLE OF LEXICAL ANALYSIS 1:1ST PHASE OF COMPILER 2: READ I/P CHRACTER AND PRODUCE O/P SEQUENCE OF TOKENS THAT THE PARSER 3:USES FOR SYNTAX ANALYSIS 4:LA ELEMINATING COMMENTS AND WHITE SPACES 5:GENRATING ERROR MESSAGE AND CORECTING IT WITH SOURCE PROGRAM
  • 10.
    TOKEN LEXEME ANDSTRING  A lexeme is a sequence of characters in the source program that matches the pattern for a token and is identified by the lexical analyzer as an instance of that token. A token is a pair consisting of a token name and an optional attribute value. ... The token names are the input symbols that the parser processes .String within double quote some LEXEME PATTERNTOKEN EXAMPLE OF GROUP 2 DESIGN BY 10
  • 11.
    TOKEN PATTREN LEXEME IFCharacter if else Character e,l,s,e else comparisin <or. Or <=or>= <= != id Letter followed letter and digit Pi,score,d2 Example of token pattern and lexeme GROUP 2 DESIGN BY 11
  • 12.
    GROUP 2 DESIGNBY 12 HOW MANY TOKEN ARE THRE?CAN ANYONE SAY PLEASE DOUBLE SALARY=BASIC SALARY + ‘HOUSE RENT +BONUS*30%’;
  • 13.
    GROUP 2 DESIGNBY 13 HOW MANY LEXEME ARE THERE? E=M*C**2;
  • 14.
    GROUP 2 DESIGNBY 14 SYNTAX ANALYSIS
  • 15.
    Syntax Analysis orHierarchical Analysis, in which characters or tokens are grouped hierarchically into nested collections with collective meaning. Hierarchical analysis also termed as Parsing, involves grouping the tokens of the source program into grammatical phrases that are used by the compiler to synthesize output. Usually, the grammatical phrases of the source program are represented by a Parse tree.GROUP 2 DESIGN BY 15
  • 16.
    GROUP 2 DESIGNBY 16 Float position, initial, rate Position =initial +rate*60 LA SYNTAX ANALYZER ID1=ID2+ID3*60 PARSE TREE /SYNTAX TREE S=>ID=E E=>E+T/T T=>T*T/F E=>ID/NUM grammer
  • 17.
    GROUP 2 DESIGNBY 17 WHEN WE COMPRESS PARSE TREE OPERATION WILL BE INTERNAL NODE AND OPERAND WILL BE LEAVE NODE INTERNAL NODE=OPERATOR LEAVE NODE=OPERAND
  • 18.
  • 19.
    GROUP 2 DESIGNBY 19 SYNTAX TREE
  • 20.
    GROUP 2 DESIGNBY 20 A symbol table is a data structure containing a record for each identifier, with fields for the attributes of the identifier. The data structure allows us to find the record for each identifier quickly and to store or retrieve data from that record quickly. SYMBOL TABLE
  • 21.
    GROUP 2 DESIGNBY S/N V/N V/TYPE 01 POSITION FLOAT 02 INITIAL FLOAT 03 RATE FLOAT FLOAT POSITION,INITIAL,RATE POSITION = INITIAL +RATE * 60
  • 22.
  • 23.
    GROUP 2 DESIGNBY 23 Requirements for symbol table management • quick insertion of an identifier • quick search for an identifier • efficient insertion of information (attributes) about an id • quick access to information about a certain id • Space- and time- efficiency
  • 24.
    GROUP 2 DESIGNBY 24 THANKS ALL
  • 25.
    GROUP 2 DESIGNBY 25 GOOD BYE
  • 26.
  • 27.
  • 28.
  • 29.