0
$\begingroup$

I am trying to understand ambiguous grammar in programming languages. I was given this ruleset and told it was ambiguous. If my understanding is correct, this means that it is possible to create the same sentence using different parse trees. After looking at it for a while, I can't find the sentence/parse trees that show the ambiguity.

s ::= a

a ::= a a | A | B | C

$\endgroup$
  • 2
    $\begingroup$ Your understanding of ambiguity meaning that you can create different abstract syntax trees to represent them is correct. What have you tried? You need to show some work. $\endgroup$ – code_dredd Oct 8 '15 at 8:35
  • 3
    $\begingroup$ Hint: consider the string "AAA". $\endgroup$ – David Richerby Oct 8 '15 at 10:53
1
$\begingroup$

More a tip than an answer, but it should get you to the solution:

Try to produce a word with 3 terminal symbols. Can you find more than one syntax tree for the same word?

$\endgroup$
  • $\begingroup$ So, i think this is more a comment than an answer.. :) $\endgroup$ – Danny Oct 8 '15 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.