انااااااااااااا

11
PREDICTIVE PARSING RAWAN ALOMRANI AMAL IBRAHEM MZOON MOHMMED SAHAR AHMED AHLAM AHMED

description

 

Transcript of انااااااااااااا

Page 1: انااااااااااااا

PREDICTIVE PARSINGRAWAN ALOMRANI

AMAL IBRAHEMMZOON MOHMMED

SAHAR AHMEDAHLAM AHMED

Page 2: انااااااااااااا

Predictive Parsing

Recursive-descent parsing is a top-down method of syntax analysis in which

a set of recursive procedures is used to process the input. One procedure is

associated with each nonterminal of a grammar. Here, we consider a simple form

of recursive-descent parsing, called predictive parsing, in which the lookahead

symbol unambiguously determines the flow of control through the procedure

body for each nonterminal. The sequence of procedure calls during the analysis

of an input string implicitly defines a parse tree for the input, and can be used

to build an explicit parse tree, if desired.

Page 3: انااااااااااااا

Predictive Parsing

The goal of predictive parsing is to construct a top-down parser that never backtracks. To do so, we must transform a grammar in two ways :eliminate left recursion, and perform left factoring .

These rules eliminate most common causes for backtracking although they do not guarantee a completely backtrack-free parsing (called LL(1) as we will see later) .

Page 4: انااااااااااااا

Predictive Parsing

•no backtracking •efficient

•needs a special form of grammars (LL(1) grammars).

•Recursive Predictive Parsing is a special form of Recursive Descent parsingwithout backtracking.

•Non-Recursive (Table Driven) Predictive Parser is also known as LL(1)parser.

Page 5: انااااااااااااا

Predictive Parsing

A special case of recursive-descent parsing that doesnot require backtracking

•Must always know which production to use based oncurrent input symbol

•Can often create appropriate grammar: –removing left-recursion

–left factoring the resulting grammar

Page 6: انااااااااااااا
Page 7: انااااااااااااا
Page 8: انااااااااااااا
Page 9: انااااااااااااا
Page 10: انااااااااااااا
Page 11: انااااااااااااا