Question

Solve the following questions. All questions are mandatory. Q1: What’s wrong in the following grammar? S...

Solve the following questions. All questions are mandatory.

Q1: What’s wrong in the following grammar?

S → ABC

A → aA|aa

B → bB|B

C → cC|cccc

Q2: Describe the strings generated by the following grammar

S → aSa

S → bSb

S → aa

S → bb

Q3: Consider the following grammar:

S → ABC

A → aA|a

B → bB|b

C → cC|c

Change the above grammar such that it generates L1={anbmck; n>=3,m>=3,k>=4}


Q4: Use the following grammar to show a rightmost derivation for the following statement: A = A * ( B + ( C ) )

<assign> → <id> = <expr>

<expr> → <id> + <expr> | <id> * <expr> | ( <expr> ) | <id>

<id> → A | B | C

Q5: Prove that the following grammars are ambiguous:

G1:

<stmt> → X|Y|e|<stmt><stmt>

G2: <start> → <first>

<first> → <first> + <first> | <second>

<second> → A | B | C

Q6: Rewrite the following BNF to give + precedence over * and force + to be left associative.

<assign> → <id> = <expr>

<expr> → <term> + <expr> | <term>

<term> → <id> * <term> | <id>

<id> → A | B | C

0 0
Add a comment Improve this question Transcribed image text
Answer #1

5) any grammar that produces more than treone parse tree for any input then it is ambiguous.

Add a comment
Know the answer?
Add Answer to:
Solve the following questions. All questions are mandatory. Q1: What’s wrong in the following grammar? S...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT