search
Log In
1 vote
68 views

Repeat Question $4.2.1$ for each of the following grammars and strings: 

  1. $S\rightarrow 0S1\mid 01$ with string $000111$.
  2. $S\rightarrow +SS\mid \ast SS\mid a$ with string $+\ast aaa$.
  3. $S\rightarrow S(S)S\mid \epsilon$ with string $(()())$.
  4. $S\rightarrow S+S\mid SS\mid (S)\mid S\ast\mid a$ with string $(a+a)\ast a$.
  5. $S\rightarrow (L)\mid a$ and $L\rightarrow L,S\mid S$ with string $((a,a),a,(a))$.
  6. $S\rightarrow aSbS\mid bSaS\mid\epsilon$ with string $aabbab$.
  7. The following grammar for boolean expressions:
  • $bexpr\:\rightarrow\:bexpr\:or\:bterm\mid bterm$
  • $bterm\:\rightarrow\:bterm\:and\:bfactor\mid bfactor$
  • $bfactor\:\rightarrow\:not\:bfactor\mid (bexpr)\mid true\mid false$
in Compiler Design 68 views

Please log in or register to answer this question.

Related questions

0 votes
1 answer
1
413 views
Consider the context-free grammar:$S\rightarrow SS + \mid SS {\ast} \mid a$and the string $aa + a{\ast}$. Give a leftmost derivation for the string. Give a rightmost derivation for the string. Give a parse tree for the string. Is the grammar ambiguous or unambiguous? Justify your answer. Describe the language generated by this grammar.
asked Aug 7, 2019 in Compiler Design Lakshman Patel RJIT 413 views
0 votes
0 answers
2
39 views
Design grammars for the following languages: The set of all strings of $0's$ and $1's$ such that every $0$ is immediately followed by at least one $1$. The set of all strings of $0's$ and $1's$ that are palindromes; that is, the string reads the same backward as forward. The set of all ... of all strings of $0's$ and $1's$ of the form $xy$, where $x\neq y$ and $x$ and $y$ are of the same length.
asked Aug 17, 2019 in Compiler Design Lakshman Patel RJIT 39 views
1 vote
2 answers
3
213 views
Which of the grammars are ambiguous? $S\rightarrow 0S1 \mid 01$ $S\rightarrow +SS \mid -SS \mid a$ $S\rightarrow S(S)S \mid \epsilon$ $S\rightarrow aSbS \mid bSaS \mid \epsilon$ $S\rightarrow a \mid S+S \mid SS \mid S^{\ast} \mid (S)$
asked Jul 26, 2019 in Compiler Design Lakshman Patel RJIT 213 views
0 votes
0 answers
4
100 views
The following grammar is proposed to remove the "danglingelse ambiguity" discussed in Section $4.3.2$: $stmt\rightarrow if\: expr\: then\: stmt\mid matchedstmt$ $matchedstmt \rightarrow if \:expr \:then \:matchedstmt\: else\: stmt\mid other$ Show that this grammar is still ambiguous.
asked Aug 20, 2019 in Compiler Design Lakshman Patel RJIT 100 views
...