in Compiler Design retagged by
991 views
2 votes
2 votes

Make this grammer into unambiguous

in Compiler Design retagged by
991 views

1 comment

These 2 are the main points when convert a grammar from ambiguous to unambiguous :

  • The operator '*'  have higher precedence than the operator '+'
  • Both the operators '*' and '+' are left associative.

Read this :

http://www.iitg.ernet.in/gkd/ma513/sep/sep27/note-0.pdf

0
0

1 Answer

0 votes
0 votes
$$L(G) = x^nx^+xx^n, n\geq 0$$

If we take n = 0, then the language becomes $x^+x = xxx^*$ which generates all the strings produced by G.

A simple unamibigous grammar producing the same language will be,

$$S\rightarrow Sx|xx$$
edited by