Question

the following grammar generates all regular expressions over the alphabet of letters (we have used quotes...

the following grammar generates all regular expressions over the alphabet of letters (we have used quotes to surround operators, since the vertical bar is an operator as well as a metasymbol):

rexp->rexp “|” rexp

| rexp rexp

| rexp “*”

| “(” rexp “)”

| letter

a. give a derivation for the regular expression (ab|b)* using this grammar.

b. show this grammar is ambiguous

c. Rewrite this grammar to establish the correct precendences for the operators.

d. What associativity does your answer in part (c) give to the binary operators? Why?

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

rexp--> rexp*

--> (rexp)*

-->(rexp | rexp)*

-->(rexp rexp | b)*

--> (ab | b)*

b) this grammar is ambiguous because it generates 2 different parse trees for the expression ab|c

c)

rexp--> rexp” |” rterm | rterm

rterm--> rterm rend | rend

rend--> rend “*” | (rexp) | letter

d) left associativity because a series of operators with same precedence will be evaluated from left to right

Add a comment
Know the answer?
Add Answer to:
the following grammar generates all regular expressions over the alphabet of letters (we have used quotes...
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
ADVERTISEMENT