Assignment No. 2 PTT 2011

(C) 2011 — Software Languages Team, University of Koblenz-Landau

Navigation

The PTT course

Check-in deadline

May 13, 2011 (End Of Day, Koblenz timezone)

Variation 1

Title

Cut all salaries with the Parser Generation Pattern

Instructions

In the lecture, it was demonstrated how to use the "Parser Generation Pattern" (with the help of ANTLR) to total all salaries in a company. See 101implementation:antlrParser. We also briefly discussed how one could go about cutting salaries in half within the bounds of the pattern. Please go ahead, and implement the cut operation indeed in terms of semantic actions within the company grammar. You need to use a Writer and take care of pretty printing as we did for some of the other implementations such as 101implementation:javaParser.

Variation 2

Title

Total salaries selectively with the Parser Pattern

Instructions

In the lecture, it was demonstrated how to use the "Parser Pattern" (based on recursive descent parsing, say manual parser coding) to total all salaries in a company. See 101implementation:javaParser. We also briefly discussed how the parser-based approach may be superior in helping with more complicated problems, when compared to the lexer-based approach. Please go ahead, and implement the total operation in a way that it only applies to managers of top-level departments. You need to implement the handlers of the parser class so that you maintain state in a way that it allows you to determine all managers of interest. As an additional challenge, try to propose a revised set of handlers for the parser class so that the task at hand and related tasks would be arguably more straightforward. You could either change the signatures of the handler methods or use an extra subclass of the parser class to enrich the behavior of the existing handler methods in a general manner.