(10 points) The following is a BNF description of the C/C++ pointer and array declarations: <Declaration> -> <Type> <Declarator>; <Type> -> int | char <Declarator> -> * <Declarator> | <Declarator> [ number ] | name Prove that this grammar is ambiguous. Hint: Find a sentence that can be generated using two different parse trees. Write down the sentence and then draw the two trees that generate this sentence.
Added by Ernest S.
Step 1
Step 1: Identify the components of the BNF grammar: - `<Declaration> -> <Type> <Declarator>;` - `<Type> -> int | char` - `<Declarator> -> * <Declarator> | <Declarator> [ number ] | name` Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 59 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Construct phrase-structure grammars to generate each of these sets. $\begin{array}{ll}{\text { a) }\left\{1^{n} | n \geq 0\right\}} & {\text { b) }\left\{10^{n} | n \geq 0\right\}} \\ {\text { c) }\left\{(11)^{n} | n \geq 0\right\}}\end{array}$
Modeling Computation
Languages and Grammars
Let $G$ be the grammar with $V=\{a, b, c, S\} ; T=$ $\{a, b, c\} ;$ starting symbol $S ;$ and productions $S \rightarrow$ $a b S, S \rightarrow b c S, S \rightarrow b b S, S \rightarrow a,$ and $S \rightarrow c b .$ Construct derivation trees for $$ \begin{array}{l}{\text { a) bcbba. } \quad \text { b) bbbcbba. }} \\ {\text { c) } b c a b b b b b c b \text { . }}\end{array} $$
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD