(Start of class)
More so than usual, you are advised to begin this assignment right away. There are design decisions to be made as well as expertise to be developed in the grammar development cycle. For many students, beginning early on this lab can improve their final grade in this course by a letter! In student reviews of this course, the advice of beginning assignments early is often given.
|jmm.cup||The CUP grammar specification file.|
|TestFiles||The directory of test files for this project|
First, make sure you are using java_1.2.3 on the cec machines. It might be a good idea to pkgaddperm java_1.2.3 and log out and in again. That version of the JVM is better about reporting line numbers than are prevous versions. If you still get exceptions reported without line numbers, then run java by:
java -Xint main inputfilewhich disables the JVM's just-in-time (JIT) compiler. That option is nonstandard but is available in the java_1.2.3 platform. Other platforms have other ways of dealing with this.
Next, go to the error line in the jmm.java file, and look up (the file, not the ceiling) to find the case statement that shows the relevant production in your .cup file.
|make||Brings your work up-to-date by compiling modified files.|
|java main file||Runs your parser on file|
|java traceLR file||Runs your parser on file, but also outputs a trace of the shift/reduce parser activity.|
| cd ~cs431/hw3/Solved
followed by the above commands
|Runs my solution for you|
|fulljava.cup||is the java grammar file as it was originally disseminated. This file may be useful for doing extra credit.|
|makeNode(Symbol)|| Constructs an AST node, labeled by the Symbol supplied as input.
This is useful where you want to take a rule such as:
SelStmt ::= IF:ifterm LP Expr RP Stmtand make an AbstractNode out of it by:
AbstractNode ifnode = makeNode(ifterm);
|makeNode(String)||This is the recommended way to put nodes in the AST to show us the structure you want. In future labs, you'll want more refined subclasses of AbstractNode so you can put in specialized code for each node type, but for now, this kind of node is very useful.|
|makeSibling(AbstractNode)|| is a method for class AbstractNodethat appends one or
more sibling nodes.
AbstractNode n1 = makeNode("SomeKindofNode"); AbstractNode n2 = makeNode("AnotherKindofNode"); n1.makeSibling(n2);makes n2 a sibling of n1.
In general, if n1 is a node in the middle of sibling list1, and n2 is a node in the middle of sibling list2, then the above code would have the effect of appending list2 to list1.
This method returns the rightmost sibling in the resulting sibling list.
|adoptChildren(AbstractNode)|| is a method for class AbstractNodethat brings a set of siblings
under a parent.
AbstractNode n1 = makeNode("Sib 1"); AbstractNode n2 = makeNode("Sib 2"); AbstractNode p = makeNode("Boss"); p.adoptChildren(n1.makeSibling(n2));makes p the parent of the siblings n1 and n2.