All programming assignments after the first (warm-up) one will be dealing with MiniJava.
Note: All assignments should be submitted via the turnin system. The turnin program always keeps the most recent version of the program submitted.
class Table { String id; int value; Table tail; Table(String i, int v, Table t) { id=i; value=v; tail=t; } }This class is used to store the values that are assigned to variable names by AssignStm's. It has two methods update and lookup. update does not search for a variable name and updates its value content rather it returns a new Table, where the first node contains the value of the most recent update. lookup is the method that returns the most recent value assigned to a variable.
class IntAndTable { int i; Table t; IntAndTable(int ii, Table tt) { i = ii; t = tt; } }This class is used to return the integer value of an interpreted expression together with the most recent state of the table following the interpretation of the expression. The table has to be returned, since this language has expression types, which not only returns an integer value but also contains a statement, which may change the state of the table.
class Interpreter { /* Comment on what this is */ static Table interpStm(Stm s, Table t){ /* your code goes here */ } /* Comment on what this is */ static IntAndTable interpExp(Exp e, Table t){ /* your code goes here */ } /* Comment on what this is */ static void interp(Stm s){ /* your code goes here */ } /* Comment on what this is */ static int countExpsInExpLists(Stm s){ /* your code goes here */ } /* Comment on what this is */ public static void main(String[] Args){ /* your code goes here */ } }This class is where bulk of your code for this project goes. It includes five methods as shown above. interp(Stm s) is the method you call to start interpreting your straight-line programs. It makes a call to interpStm(Stm s, Table t). interpStm(Stm s, Table t) and interpExp(Exp e, Table t) are used to interpret instances of Stm and Exp classes respectively.
/usr/csshare/pkgs/jdk1.5.0_05/bin/javac -classpath /usr/csshare/pkgs/jdk1.5.0_05/jre/lib/ext/java-cup-v11a.jar:. Lexer.java
/usr/csshare/pkgs/jdk1.5.0_05/bin/java -classpath /usr/csshare/pkgs/jdk1.5.0_05/jre/lib/ext/java-cup-v11a.jar:. Lexer <MINIJAVA FILE>Because of the %debug directive in the MiniJava.jflex file, no actions will get executed; instead, the lexer will output the token and line and column where the token was found.
./compile <your jflex file> MiniJava.cup
./run-parser <minijava input file>
Error in line <line # of the error>, column <column # of the error> : Syntax error
javac -classpath syntaxtree.jar:visitor.jar:. YourFile.javabut ultimately, you would like to avoid typing altogether by automating your builds with an appropriately written Makefile (needless to say, feel free to modify it as you please, but from now on include one Makefile with every assignment submission).
import syntaxtree.*; import visitor.*;Those two lines will probably go to the header of your MiniJava.cup file, among other places.
java -classpath ./syntaxtree.jar:./visitor.jar:. Main <MiniJava Input File>You may as well place the above line in a script file to avoid the typing. Possible input files are MiniJava samples used in previous assignments.
java -classpath ./syntaxtree.jar:./visitor.jar:. Main <MiniJava Input File>You may as well place the above line in a script file to avoid the typing. Possible input files are MiniJava samples used in previous assignments.
MiniJava.jflex MiniJava.cup BuildSymbolTableVisitor.java TypeCheckVisitor.java, along with your updated Makefile. No compressed files, nor any test or other script files should be submitted. We will be taking off points if your submission fails to follow this guideline.
MiniJava.jflex MiniJava.cup BuildSymbolTableVisitor.java TypeCheckVisitor.java InterpreterVisitor.java Environment.java (Only and only if you implemented inheritance) MakefileNo compressed files, nor any test or other script files should be turned in. We will be taking off points if your submission fails to follow this guideline.