CSC 124/258: MiniJava+ Compiler Overview We shall now begin implementing a java-like programming language similar to the one described in your textbook. We call it MiniJava+. Java usually runs on the Java virtual machine but it doesn't have to. We shall compile it to x86 assembly language using the Gnu assembly (gcc) format. This will also allow us to borrow the runtime of the C programming language and call C system routines such as printf and malloc. The textbook describes Minijava in the appendix (page 484). Our MiniJava+ language also differs from the textbook's MiniJava in the following ways: 1. The String type will be allowed (minijava only allowed int and boolean). However, only integer arrays will be supported (int[]). Also, we shall implement System.out.printf (instead of the .println). 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. 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. 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 LR/SLR it's not a problem, so we should include them. No programming language can be without them. (NOTE CHANGE: % added, > deleted) /////////////// The following is a sample MiniJava+ program: class factorials { public static void main(String[] args) { int a = 1; fact A = new fact(); System.out.printf("\nthe factorial of 6 is "); a = A.f1(6); System.out.printf( a ); System.out.printf("with tail-recursion it's also "); a = A.f2(6,1); System.out.printf( a ); System.out.printf("without recursion it's still "); a = A.f3(6); System.out.printf( a ); } //main } class fact { int a; public int f1(int n) { if (n<2) a=1; else a = n * (this.f1(n-1)); return a; } public int f2(int n, int accum) // accum must be initially 1 { int a; if (n<2) a = accum; else a = this.f2(n-1,accum*n); return a; } public int f3(int n) { int accum = 1; while (1