Preparation
Always make sure to pull/clone/download the latest 101simplejava repo.
See the instructions here:
https://github.com/101companies/101simplejava/blob/master/README.md
Starting point
Either of the following contributions:
- http://101companies.org/wiki/Contribution:antlrAcceptor (An ANTLR-based acceptor)
- http://101companies.org/wiki/Contribution:antlrParser (As before but with semantic actions to compute salary total along parsing)
- http://101companies.org/wiki/Contribution:antlrObjects (As before but with the use of an extra object model)
Task
The task consists of two milestones. First, revise the chosen contribution to use a flat (denormalized) representation of companies, as described in the previous assignment. Second, revise the chosen contribution to implement Feature:Depth.
Hint
Invoking ANTLR
Whenever you change Company.g, you need to invoke ANTLR to get up-to-date files CompanyParser.java and CompanyLexer.java. Note that you need to "refresh" in Eclipse if you have generated code outside Eclipse.
There are two major ways as to how you can invoke ANTLR. One option is to run "gradle build" on the revised project. Another option is to invoke ANTLR on the command line:
java -cp ".:antlr-3.2.jar" org.antlr.Tool Company.g
This command line generates CompanyParser.java and CompanyLexer.java in the same directory. Here is assumed that the ANTLR jar iand Company.g are in the current directory. If you ran gradle, you do have ANTLR already on your system (somewhere), but it may be tricky to find it. (Also, you make need to add more jars to the classpath, as ANTLR may be split up.) You can download a "complete" ANTLR jar from here: http://www.antlr3.org/download/antlr-3.2.jar
Picking the right starting point
Any of the three projects is sort of equally suitable, but consider the following tradeoffs. If you pick antlrAcceptor, then it is easy to just focus initially on changing the grammar to model the flat representation. If you pick antlrParser, then it is easy to revise the semantic actions for Feature:Total to do Feature:Depth instead. If you pick antlrObjects then it is easy to just do Feature:Depth in plain Java code, but you still need to revise semantic actions for AST construction.
Testing
A test is needed to parse some input and compute the nesting depth of departments. Other tests (be it for Feature:Total or Feature:Cut or others, depending on the chosen starting point), do not need to be preserved.