| Lab | Assigned | Lab Due (Start of class) |
||
|---|---|---|---|---|
| 20 | Feb | 19 | Mar | |
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.
Make the appropriate modifications to the build file, and try building and running the project (see ant tasks' descriptions, below) as distributed, as soon as possible, to avoid any infrastructure issues.
Browse through the file and familiarize yourself with the structure of this grammar. It is the only file you should modify, and it is the only file you are allowed to turn in.
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 |
| testClassSolution | Runs my solution on all of the test files |
| testMySolution | Runs your solution on all of the test files |
| clean | Deletes the class files and all automatically generated files. Use this if things are behaving weirdly. |
| java main file | Runs your parser on file |
| 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.
For example
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.
For example
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.
|
Be sure to fill in the header of the jmm.cup file with your name and the email address from which you are submitting your work.