Sie sind auf Seite 1von 29

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
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 3
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 4
OBJECTIVE OF THE
PROJECT
LEXICAL ANALYSIS
SYNTAX ANALYSIS
SYMBOL TABLE

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
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 8
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

GROUP 2 DESIGN BY 9
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

TOKEN LEXEME PATTERN


EXAMPLE OF

GROUP 2 DESIGN BY 10
Example of token pattern and lexeme
TOKEN PATTREN LEXEME

IF Character if
else Character else
e,l,s,e
comparisin <or. Or <= !=
<=or>=
id Letter Pi,score,d2
followed
letter and
digit
GROUP 2 DESIGN BY 11
HOW MANY TOKEN ARE THRE?CAN
ANYONE SAY PLEASE

DOUBLE SALARY=BASIC SALARY +


‘HOUSE RENT +BONUS*30%’;

GROUP 2 DESIGN BY 12
HOW MANY LEXEME ARE THERE?

E=M*C**2;

GROUP 2 DESIGN BY 13
SYNTAX ANALYSIS

GROUP 2 DESIGN BY 14
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
Float position, initial, rate
Position =initial +rate*60

LA

ID1=ID2+ID3*60
grammer

S=>ID=E
E=>E+T/T
SYNTAX ANALYZER T=>T*T/F
E=>ID/NUM
PARSE TREE /SYNTAX TREE

GROUP 2 DESIGN BY 16
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 17
GROUP 2 DESIGN BY 18
SYNTAX TREE

GROUP 2 DESIGN BY 19
SYMBOL TABLE
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.

GROUP 2 DESIGN BY 20
FLOAT POSITION,INITIAL,RATE
POSITION = INITIAL +RATE * 60

S/N V/N V/TYPE

01 POSITION FLOAT

02 INITIAL FLOAT

03 RATE FLOAT

GROUP 2 DESIGN BY
<TOKEN NAME,ATTRIBUTE VALUE>
<ID1,1><=><ID2,2><+><ID3,3><*><60>

GROUP 2 DESIGN BY 22
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 23
THANKS ALL

GROUP 2 DESIGN BY 24
GOOD BYE

GROUP 2 DESIGN BY 25
GROUP 2 DESIGN BY 26
GROUP 2 DESIGN BY 27
GROUP 2 DESIGN BY 28
GROUP 2 DESIGN BY 29

Das könnte Ihnen auch gefallen