Question

Recursive Descent Parsing Consider the following BNF grammar: A -> I = E E -> P...

Recursive Descent Parsing

Consider the following BNF grammar:

A -> I = E
E -> P O P | P
O -> + | - | * | / | **
P -> I | L | UI | UL | (E)
U -> + | - | !
I -> C | CI
C -> a | b | ... | y | z
L -> D | DL
D -> 0 | 1 | ... | 8 | 9
        

Using the technique described in class implement a recursive descent parser that recognizes strings in this language. Input should be from a file called input.txt and output should be to a file called output.txt. An example session might look like this (these strings are not necessarily in the language):

The string "a=a+b-c*d" is in the language.
The string "a=a//b++c" is not in the language.
        

You must implement the project in C++ Implementations that do not include a solution in language will, at best, receive half credit. To simplify things you will not have to handle whitespace when parsing the string, i.e. " " and similiar are illegal characters in this language. All strings should read from a file called "input.txt" and written to a file called "output.txt".

input.txt file will be

a=+0
a=!b
a=b+0
a=b++c
a=b**c
a=(((b)))
a=((b+c)*(d+e))
a=b+
a=b+c*d
a=b+c*d^e
a=(b+c)*(d+e))
a=((b+c)*(d+e)

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Recursive Descent Parsing Consider the following BNF grammar: A -> I = E E -> P...
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