PTG Assignment 3: Attribute Grammars with JastAdd
Create a table formatting application using JastAdd. It should output a formatted table where each column has a fixed width. The input table may be specified using basic HTML tags. An example input can be the following: The expected output for this table is: Proceed according to the following plan: A basic JastAdd data structure should be designed for the table, tr, and td tags that exist in this table language. Implement this in the abstract grammar formalism that can be used as input to Jastadd and generate conforming Java files. Rather than parsing the input, for this exercise it is sufficient to use hard-coded tables constructed using the data structure you designed in the previous step. Define a series of JUnit unit tests to confirm your application is working. Using attributes, compute the maximum width of all cells in a column. One approach may be to parametrize attributes with the index of the column they apply to (e.g., widthOf(int i)). Define a print() method for each of the elements of the language, that prints the table to System.out. JastAdd, which is available from www.jastadd.org. Ant and Java, which are available from the Apache and Sun websites. The course literature includes examples of the table formatting problem in Eli. Submit your complete solution and unit tests by April 20th. <table>
<tr>
<td>Top-left</td> <td>Top-middle</td> <td>Top-right</td>
</tr>
<tr>
<td>Another cell on the left</td> <td>Table center</td> <td></td>
</tr>
<tr>
<td>1</td> <td>2</td> <td>3</td>
</tr>
</table>
Top-left Top-middle Top-right
Another cell on the left Table center
1 2 3
Steps
Designing the AST
Unit Testing
Attributes
Print the table
Required software
Additional information
Submission
Contributions by SanderVermolen LennartKats