Question
Consider the following set of productions that define a subset of the C++ programming language: ::= int main() { return 0; } ::= | ::=
Consider the following set of productions that define a subset of the C++ programming language:
|
| if (
| if (
| if (
| if (
| while (
|
| double
|
|
|
Problem 1. Write a program in C, C++, C#, Java, or Python (your choice) that starts with the root non-terminal
Problem 2. Run your generator (possibly a few times) to generate a random syntactically correct C++ program. You will observe that, despite the correct syntax, there are other issues that prevent this program from being correct. Please discuss some of these errors. Suppose you wish to implement a checker for detecting these errors. What sort of approach or algorithm would you use to accomplish this? There is no need to write any code for this problem.
Hint 1: The following is a sample random program that was generated by my solution. I added some white spaces to make it more readable:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started