Our implementation of SmallJava does not yet allow us to make references to types such as
Integer, and so on. These types would allow us to declare variables initialized with constant expressions. In this section we show how to create a library with predefined types.
One might be tempted to hardcode these classes/types directly in the grammar, but this is not the best approach. There are many reasons for not doing that; mostly, that the grammar should deal with syntax only. Moreover, if we hardcoded, for example,
Object in the grammar, we would only be able to use it as a type, but what if we wanted
Object to have some methods? We would not be able to express that in the grammar.
Instead, we will follow the