Ptt14 Assignment2


1. Pick a simple text-based language. (See some candidate languages for inspiration below.)
2. Implement a parser for the language. (Use recursive descent, ANTLR, or something else.)
3. Implement an unparser (pretty-printer) for the language. (Use StringTemplate or something else.)
4. Implement a simple transformation for your language. (See some candidate transformations for inspiration below.)
5. Implement at least one testcase that composes parsing, transformation, and unparsing.
6. Describe your language processing scenario and its implementation. (Especially, for the lab presentation.)

Since this assignment is underconstrained in terms of languages, technologies, and transformations involved, you need to make an extra effort to help others with understanding and reproducing your development setup, your language, your transformation, your technology choices, and not just your implementation. To this end, your project should run as a test case. Also, your lab presentation should be prepared to contain enough details and illustrations. For instance, describe your language and your transformation by means of a simple example; also, describe a step-by-step procedure for setting up a system for your development and for running your code and assessing the results. You may use screenshots or even a screencast, if you like.

Candidate languages

Please feel encouraged to pick any other textual notation that comes to your mind. For example, you may also pick your favorite programming language (Java, Pascal, …) and cover a small subset thereof. Also, you may deal with a simplified format language (XML, JSON, …) in your assignment.

Don't strive for completeness. It is totally acceptable that you pick a small subset of some language. Implementing the language completely would cause too much work. So again, pick a nice and small example and then cover such limited expressiveness in your implementation. That's good enough!

Reuse and citation

If you use existing code or other resource, make sure to cite them in a transparent way. There is nothing wrong with reusing code and other resources for this assignment, but you must cite them properly. However, you are not supposed to simply find a big grammar (parser) somewhere on the web and include it, as is, into your solution. If you want to start from a bigger example somewhere out there, you must edit it down to a manageable subset (10-20 productions) that covers exactly your focused examples.

Candidate transformations

Candidate transformations are listed here to match candidate languages (see above).

  • SVN access: Remove all access for a given user.
  • Expressions in RPN: Eliminate trivial expressions related to law "x * 1 = x".
  • make: Insert an empty "none:" target at the beginning of the file.
  • C Preprocessing: Rename a given macro.
  • INI files: Rename a section in the file.
  • Bibtex: Replace "Software Language Engineering" in strings by "SLE".

Related 101 contributions

These contributions demonstrate parsing and/or unparsing and/or transformation, as discussed in the lecture:

Demonstrations for ANTLR V4 instead of V3 are forthcoming.