in Compiler Design retagged by
1,047 views
0 votes
0 votes

Associativity and precedence of operators is defined by grammar. So C should be right.

Please help

in Compiler Design retagged by
by
1.0k views

1 comment

is it possible for shift-reduce parser to construct a parse tree for ambiguous grammar ??
0
0

5 Answers

3 votes
3 votes
Best answer

Actually here u have to draw the tree and associate semantic rule and work accordingly..

However as the grammar is ambiguous as clear from the grammar , so we can construct the parse tree in other way too i.e. taking E --> E ↑ E at the topmost level so in that case we will get A) as correct option..Hence both are true..

Hence option C) is correct answer..

selected by

4 Comments

Take 1st derivation first and derive.

A) also possible

As associativity not matter.

So, I too think C) should be answer
0
0
Ok I got ur point..Ya it should be C)..Since the grammar is ambiguous..:)
1
1
Corrected..:)
0
0
ACE test series sucks.

got many questions wrong, just because of their wrong answers.

Habib, we always take precedence and associativity from grammar, not what is defined by default in C.
1
1
0 votes
0 votes
Option b cannot be the answer because * is having higher precedence than | symbol.So * should be evaluated first.

Hence the answer is option a.
0 votes
0 votes
A is correct answer , travel the tree from bottom to up , first (a) will be printed then (b) then (*) then (c) and at last (!)

4 Comments

why not b ... first use E*E then on rightmost E Use E!E .... then traverse bottom to up
0
0
You are given a sequence already to make parse tree, so why to use other way?
0
0
That is just a grammer.....  And it is ambiguoous....  i think we can use both way
1
1
Yes option c) is correct we can have two derivation tree for the grammar

Since two trees therefore SDT can give any of the output .
0
0
0 votes
0 votes
it is ambigous grammar. So we can have two different parse tree

so we can have both the print sequence

C is correct answer here

ona funny note: it is ACEE question.. so be sure that the answer marked is always incorrect

1 comment

hahahahaah ... i totally Agree.........
0
0

Related questions