search
Log In
1 vote
108 views
An unambiguous grammar has same leftmost and rightmost derivation.

True or False

and how??
in Compiler Design
edited by
108 views
1
Ambiguity has no relation with left most and right most derivation.It is true.Every grammer if it has some string then it will have both left and right deravation

1 Answer

0 votes

"An unambiguous grammar has same leftmost and rightmost derivation"

This statement is false, let me take an example, suppose given gammer is (which is certainly unambiguous)

S -> AB
A -> a
B -> b

Suppose our input string is ab

Left Most Derivation
S -> AB -> aB -> ab

Right Most Derivation
S -> AB -> Ab -> ab

Notice Left Most derivation and Right most derivation are not same, still gammer is unambiguous.

Here is the Derivation Tree


edited by

Related questions

0 votes
0 answers
1
156 views
why do first sets can have epsilon symbol but follow sets don’t? P.S: I’ve a silly doubt :P
asked May 12, 2019 in Compiler Design aditi19 156 views
0 votes
0 answers
2
203 views
Implement Algorithm $3.23$, which converts a regular expression into a nondeterministic finite automaton, by an L-attributed SDD on a top-down parsable grammar. Assume that there is a token char representing any character, and that char.$lexval$ is the character it ... that is, a state never before returned by this function. Use any convenient notation to specify the transitions of the $NFA$.
asked Sep 6, 2019 in Compiler Design Lakshman Patel RJIT 203 views
1 vote
0 answers
3
119 views
In Fig. $4.56$ is a grammar for certain statements, similar to that discussed in Question $4.4.12$. Again, $e$ and $s$ are terminals standing for conditional expressions and "other statements," respectively. Build an LR parsing table for this grammar, resolving conflicts in the usual way ... your parser on the following inputs: if e then s ; if e then s end while e do begin s ; if e then s ; end
asked Aug 20, 2019 in Compiler Design Lakshman Patel RJIT 119 views
0 votes
0 answers
4
194 views
The following is an ambiguous grammar for expressions with $n$ binary, infix operators, at $n$ different levels of precedence: $E\rightarrow E\theta_{1}E\mid E\theta_{2}E\mid \cdot\cdot\cdot E\theta_{n}E\mid(E)\mid id$ ... of the tables for the two (ambiguous and unambiguous) grammars compare? What does that comparison tell you about the use of ambiguous expression grammars?
asked Aug 20, 2019 in Compiler Design Lakshman Patel RJIT 194 views
...