edited by
1,240 views
3 votes
3 votes
Consider the following operator grammar

E->AaBcD

A->bA|e

B->bB|e

D->eD|g

Which of the following precedence relation is incorrect from the above grammar? Assume x<•y is used to represent x is having less precedence than y and in the expression x appears first and y appears next.

a) a<•b b) c<•g c) a<•e d) c<•b
edited by

1 Answer

2 votes
2 votes

In Operator Grammar we are looking next token forward only but not backward.

In SLR(1) and LR(1) we look one token advance according to that actions(Shift or Reduce) actions performed.

In LR(K) lookahead K symbols.

One more is bottom level tokens having higher precedence that top level in parse tree. 

Remember these two key points ,now first draw parse tre for any one string

 In above prase tree a and c are at same level and having equall precedence.

a<.b ---b is bottom level and a is top level so it is correct.

c<.g---g is bottom level and c is top level.

a<.e---it is also correct.

c<.b---b is bottom level and c is top level but b is backward to c,so c may not look b.it is incorrect.

Hence Option should be D

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
4
saumya mishra asked Jun 15, 2018
2,132 views
What is the difference between operator grammar and operator precedence grammar?