CSC 124: MiniJava+ Compiler Stage 2: In the first weeks of the class you wrote a lexical tokenizer for the MiniJava language described in the text. We will be implementing a version of this language, which we shall call MiniJava+. It differs from MiniJava in the following ways: 1. The String type will be allowed (minijava only allowed int and boolean). Also, System.out.println should accept either integer or string parameters. 2. Both forms of if, with or without the else, are allowed (minijava only allows version with the else). 3. We allow statements of the form: int x = 10; where a variable is both declared and given an initial value. ***************** 4 is nolonger required **************** 4. Standalone function calls are allowed. That is, minijava did not allow statements of the form A.f(); except for System.out.println. Function calls are only allowed as part of expressions. In MiniJava+, however, we allow such kinds of statements, which simply discards the return value. **************** 5. In minijava, all instance variables are implicitly private since there is no expression of the form A.x where x is a variable (all functions are public, however). In MiniJava+, however, everything will be public. So expressions of the form A.x are allowed. 6. Our compiler will eventually rely on gcc as the assembler/linker. One benefit of this is that we will be able to call any C function from within MiniJava+ as well. We add a special kind of statement (and expression) of the form Clib.f(..), where "Clib" is a new reserved word. 7. In addition to the operators &&, <, +, -, and * we will also allow /, ==, ||, and !. These operators were left out because it would have been difficult to write an unambiguous grammar for them all, especially if you wanted to argue for LL over LR. But with Yacc/Cup it's not a problem, so we should include them. No programming language can be without them. ============================================================================== The next few stages of your assignment will consist of the following. 2a. Write a .cup grammar file that can parse Minijava+ and distinguish between the different kinds of language constructs. This grammar file need not contain semantic actions except print statements for tracing. 2b. Choose an abstract syntax representation for MiniJava+ 2c. Rewrite the .cup file to generate abstract syntax tree structures. 2d. Practice using the visitor pattern on the abstract syntax. Write a visitor class that "prettyprints" MiniJava+ in C++ syntax, effectively creating a MiniJava+ to C++ translator. In all, part 2 will require approxmately 1000 lines of relatively sophisticated code, though in many cases there will be a lot of repetition. It took me about 3 days to complete this much.