Upload
hema-sundar
View
41
Download
3
Embed Size (px)
DESCRIPTION
MLRIT 3rd year CSE
Citation preview
CONSTRUCTINGPREDICTIVE LL(1) PARSER TABLEBy, S.Nandini(12R21A05A8)Sweta Panwar(12R21A05A9)A.Sirisha(12R21A0562)
INTRODUCTION What is a parser? In computer technology, a parser is a
program, usually part of a compiler, that receives input in the form of sequential source program instructions and breaks them up into parts.
PREDICTIVE LL(1): A predictive parser is a recursive
descent parser that does not require backtracking.
L – Reading from left to right L – Leftmost Derivation 1- Indicates that parser takes one input
at a time.
REQUIREMENTS OF CONSTRUCTING PARSING TABLE
REQUIREMENTS OF CONSTRUCTING PARSING TABLE
Input buffer to take the input string. A Stack is used to hold two functions: Shift: It is to replace non terminal by terminal
at the time of pushing on to the stack. Reducing: It is used for popping the input terms
by replacing the starting symbols. In stack ‘$’ indicates that initially stack is
empty.
REQUIREMENTS OF CONSTRUCTING PARSING TABLE
A table is basically of two dimensional array on given input by predictive parser.
Constructing of table requires the two functions: FIRST() FOLLOW()
RULES FOR CONSTRUCTING FIRST() FUNCTION VALUES:
Suppose that A is a non-terminal ,‘’ is a terminal and X1,X2,…Xn are the terminals.
If A-> then FIRST(A)={}If A-> then FIRST(A)={}If A->X1/X2/../Xn then
FIRST(A)=FIRST(X1)=FIRST(X2)=…=FIRST(XN).
RULES FOR CONSTRUCTING FOLLOW() FUNCTION VALUES:
If A is a starting symbol,then FOLLOW(A)={$}.o If A->Bβ then FIRST(β) to be placed
in the FOLLOW(B) without .o If A->Bβ (or) A->B where β->
(FIRST(β)={} then FOLLOW(A)=FOLLOW(B).
RULES FOR CONSTRUCTION OF PREDICTIVE LL(1) PARSING TABLE:
Based on FIRST() function we fill the table.
If occurs in given production,then go for FOLLOW() and fill the table of corresponding cell with production Nt-> .
Thus, the predictive parser table can be constructed.
PREDICTIVE PARSING TABLE
E -> TE’E -> TE’|εT -> FT’T’ -> *FT’|εF -> (E)|id
PREDICTIVE LL(1)PARSER TABLE BY COMPUTER SIMULATION:
Thank you ….