Need help starting a Parsing Code Generator for C++ : <p>So I'm working through my CS degree and currently taking a Programming Language concept class. The first assignment is to create a program that generates a random syntactically correct but does not have to be semantically correct. This assignment came after going over the BNF gramner. I have never even seen a program that creates a parse tree or uses one. I'm going from 0 to 4000 with this assignment and to be honest doubting my abilities a little. I'm not looking for a free ride but Just some help even starting the program. I'm not even sure what the Main program is suppose to look like or how it would work. Any guides or references for C++ parse programs would be great. Or some sample source code of a parser in c++.</p>

<p>This is the assignment...</p>

<p>The purpose of this exercise is to write a syntax generator for a subset of the C++ programming
language that will write “random” C++ programs to a file. By writing these random syntactically
correct programs, you will further develop your understanding of the difference between syntax
and semantics.</p>

<p>Consider the following set of productions that define a subset of the C++ programming
language:</p>

<p>(prog) ::= "int main() { (stat_list) return 0; }"</p>

<p>(stat_list) ::= (stat)
            | (stat_list) (stat)</p>

<p>(stat)      ::= (cmpd_stat)
            | (if_stat)
            | (iter_stat)
            | (assgn_stat)
            | (decl_stat)</p>

<p>The above in only a few of the 16 production rules for the assignment.</p>

<p>Problem 1.​ Write a program in C, C++, C#, Java, or Python (your choice) that starts with the
root non-terminal  and generates a random syntactically correct C++ program using the
productions defined above. You should follow the examples we saw in class where we expand
non-terminals recursively until we obtain a sentence consisting of terminal tokens only. In the
case where a production contains more than one expansion (i.e., right-hand-side expressions),
your program should select one randomly (preferably with non-uniform weighting based on
which expansions are more likely to occur in C++). Your program should write the random C++
code to an output file.</p>

<p>I'm have to use C++ for the assignment because that is the only language that I how after taking the intro classes to CS classes.</p>

<p>Any help would be much appreciated.</p>
