Browse through the file and familiarize yourself with the structure of this grammar. It is the only file you should modify for this assignment.
You are advised to follow the following strategy as you develop your solution. Failure to follow this advice will increase your development time and could cause anxiety, confusion, and dry flaky skin.
|build||Default target, runs appropriate tools and compiles your project to bring it up-to-date. This does not run your parser on any inputs!|
|runYourParser||Runs your parser on all files in the TestFiles directory|
|runYourParserTrace||Runs your parser in trace mode on all files in the TestFiles directory. The trace shows the actions of the shift-reduce parser so that you can determine where and why the parser detects an error in a test file.|
|runReferenceParser||Runs the reference parser on all files in the TestFiles directory, showing the resulting ASTs.|
|clean||Deletes the class files and all automatically generated files. Use this if things are behaving weirdly.|
|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.
Important examples of this are IntegerNode and TemporaryNode which are included in the jmm.cup file in the action code block.