Given grammar ambiguous or not?

sparta93

Consider the grammar below...

bexp -> bterm | bterm ‘||’ bexp
bterm -> bfact | bfact ‘&&’ bterm
bfact -> true | false | id | ‘(‘ bexp ‘)’

Suppose we extend BEXP with the '!' operator for negation by changing the bfact rule as follows:-

bfact -> true | false | id | '(' bexp ')' | '!' bexp

Lets call this extended grammar BEXP2. How can I prove that it is ambiguous?

rici

You can prove that it is ambiguous by finding a string with two parses :)

In this case, try !id&&id. Is that (!id)&&id or !(id&&id)

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事