SlideServe
Menu
Préférences
© SlideServe · v2026

SLR Parser

saeran avatar
4 diapositives · 553 Views · Sep 25, 2013

SLR Parser. Problems. • Problems with SLR parser: The SLR parser discussed in the earlier class has certain flaws. 1. A state may include a final item (one in which the position marker is at the end) and a non- final item. This may result in a shift-reduce conflict .

SLR Parser - slide 1
01 / 4SLR Parser
1 / 17

Télécharger la présentation

SLR Parser
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. SLR Parser Problems

  2. • Problems with SLR parser: The SLR parser discussed in the earlier class has certain flaws. 1. A state may include a final item (one in which the position marker is at the end) and a non- final item. This may result in a shift-reduce conflict . 2. A state may include two different final items. This might result in a reduce-reduce conflict . • Can we have reduce-reduce conflicts in unambiguous grammars? • Can we have a shift-shift conflict ? However SLR reduces only when the next token is in Follow of the left-hand side of the production. Proper choices may help to resolve reduce-reduce conflicts.However, still similar conflicts exist: ->Shift-reduce conflicts include the case in which Follow of the lhs nonterminal of any final item overlaps with first token after the dot in any of the remaining items in that item set. Reduce-reduce conflicts include the case Follow of left-hand-sides of more than one final items in an item set overlap. This grammar is called LR(0.5) or SLR.This is because when we reduce,we do not really consider the lookahead.The production is placed in the table corresponding to the entire follow set of the nonterminal.Hence this cannot strictly be referred to as LR(1).

  3. Let us consider the grammar. 0. S’->S 1. S->E 2. E->L=R 3. E->R 4. L->*R 5. L->id 6. R->L Construcing the item set: Io={S’->.S, S->.E, E->.L=R, E->.R, L->.*R, L->.id, R->.L} I1= {S’->S.} I2 = {S  .E} I3 = {E L.=R , RL.} I4 = { E L=.R , R.L ,L  .*R , L.id} I5 = {E  L=R.} I6 = {E  R.} I7 = { L  *.R , R.L ,L  .*R , L.id} I8 = { L  *R. } I9 = {L id.}

  4. So in the Parsing table we have the following conflict when the follow ‘=’ appears. |.…..…………………………………… | …. ….. ‘=’ ….. …… I3 …. ….. s4/r6 ….. ……. -> shift reduce conflict Hence our next approach is to try LR(1) parser. Ridhima Kedia 04CS1021