Recursive Descent Parsing Consider the following BNF grammar: A -> I = E E -> POP | P 0 -> +1 -11/ P -> I | L | UI | UL | (E) U -> +|-|! I -> C | CI c -> a | b | ... | y | z L-> D | DL D-> | 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 the screen. An example session might look like this (these strings are not necessarily in the language): Input file: a=1 a=a+b-c*d a=a//b++c Output: The string "a-1" is in the language. The string "a=a+b-cad" is in the language. The string "a=a//b++c" is not in the language. You must implement the project in BOTH Java and C++! Implementations that do not include a solution in both languages 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 the screen.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

According to the question, both language codes are required. In two languages, C++ and JAVA, write the following code. 

Please do not copy and paste from other similar questions. Also, the name of the C++ file should be "main.cc" and the name of the Java file should be "Main.java".

### Recursive Descent Parsing 

#### Consider the following BNF grammar:

```
A -> I = E
E -> P O P | P
O -> + | - | * | / | ** 
P -> T | I | (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 the screen. An example session might look like this (these strings are not necessarily in the language):

##### Input file:
```
a=1
a=a+b-c*d
a=a//b++c
```

##### Output:
```
The string "a=1" is 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 **BOTH** Java and C++! Implementations that do not include a solution in both languages will, at best, receive half credit. 

To simplify things, you will not have to handle whitespace when parsing the string, i.e., `" "` and similar are illegal characters in this language. All strings should be read from a file called `"input.txt"` and written to the screen.
Transcribed Image Text:### Recursive Descent Parsing #### Consider the following BNF grammar: ``` A -> I = E E -> P O P | P O -> + | - | * | / | ** P -> T | I | (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 the screen. An example session might look like this (these strings are not necessarily in the language): ##### Input file: ``` a=1 a=a+b-c*d a=a//b++c ``` ##### Output: ``` The string "a=1" is 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 **BOTH** Java and C++! Implementations that do not include a solution in both languages will, at best, receive half credit. To simplify things, you will not have to handle whitespace when parsing the string, i.e., `" "` and similar are illegal characters in this language. All strings should be read from a file called `"input.txt"` and written to the screen.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY