conflicts in parsing n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
CONFLICTS IN PARSING PowerPoint Presentation
Download Presentation
CONFLICTS IN PARSING

Loading in 2 Seconds...

play fullscreen
1 / 10

CONFLICTS IN PARSING - PowerPoint PPT Presentation


  • 106 Views
  • Uploaded on

CONFLICTS IN PARSING. In the process of Parsing,a stage where there is a problem in deciding the production to be used is referred to as CONFLICT. There are two kinds of conflicts possible a) Shift-Reduce Conflict. b) Reduce-Reduce Conflict. SHIFT REDUCE CONFLICT.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'CONFLICTS IN PARSING' - aquene


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
conflicts in parsing
CONFLICTS IN PARSING
  • In the process of Parsing,a stage where there is a problem in deciding the production to be used is referred to as CONFLICT.
  • There are two kinds of conflicts possible

a) Shift-Reduce Conflict.

b) Reduce-Reduce Conflict.

shift reduce conflict
SHIFT REDUCE CONFLICT
  • Consider the symbol-stack in process of parsing as X = $F
  • Now,there input string,w points to *
  • There also exists a production T->F.
  • We can either SHIFT,thereby X = $F*
  • We can REDUCE,thereby X = $T.
  • This condition is referred to as shift reduce conflict.
reduce reduce conflict
REDUCE REDUCE CONFLICT
  • Consider the symbol-stack in process of parsing as X = $MaAB
  • Let's say there exists two productions which give rise to Aab.
  • Y->Aab and X->Aab.
  • Now,which production to be chosen for reduction is again a question.
  • This is called Reduce Reduce Conflict.
resolution of conflicts
RESOLUTION OF CONFLICTS
  • These conflicts depend on the implementation and can be removed by using the following parsers.

a)Operator Precedence Parser

b)LR Parser :

i)SLR Parser

ii)CLR Parser

iii)LALR Parser

operator precedence parser
OPERATOR PRECEDENCE PARSER
  • This is a very primitive parser
  • This works only for Mathematical/Arithmetic expressions.
  • It consists of a Precedence Table,which serves as information when the stack top and the current input symbol is known and we want to shift or reduce.This is valid for a specific set of grammar.
operator grammar
OPERATOR GRAMMAR
  • The operator grammar produces all the strings that can be parsed using an operator precedence parser.No other strings will be parsed.Hence,the language follows certain restrictions.
  • No ϵ-Transitions are allowed.
  • No 2 or more consecutive Non terminal symbols allowed in the body of any production.
precedence information
PRECEDENCE INFORMATION
  • To design a Precedence Table,we need to store the precedence information.So,whenever two terminals A,B occur,we can define few precedence operators
  • .>
  • .=
  • <.
definition of operators
DEFINITION OF OPERATORS
  • A .> B implies that A has higher precedence than B.
  • A <. B implies that A has lesser

precedence than B.

  • A .= B implies that A has equal precedence as B.
precednce table
PRECEDNCE TABLE
  • Consider 3 sample terminals id,+,*,$
  • The precedence order is id > * >+ >$
  • Wherever 2 operators have same precedence,like a = '+' and b = '+'.where a occurs before b in an expression.Now,we check for associativity of the operator.As '+' is left associative,a .> b will be assigned in the table.
precedence table
PRECEDENCE TABLE
  • The terminal a is on the Row and the terminal b is on the column and here is the final precedence table
  • In this way,Precedence table can be made for any grammar which will be used in Parsing.