Skip to content

MontiCore - Types

Type systems are available in a variety of (programming) languages and facilitate programming because they allow for detecting typing errors already at compile time. To express type usages in MontiCore-based languages a language component hierarchy for type modeling was developed. The hierarchy consists of the following language components:


MCBasicTypes is the most basic language component. It provides the central interface nonterminal MCType. Additionally, it defines nonterminals that enable modeling primitive types as well as qualified and non-qualified types. Furthermore, the component comprises a rule that covers return types which can be MCTypes or voids. In general, the component represents a relativity small, yet useful, collection of rules for type modeling that supports statements such as int, Person, and java.lang.String.


This language component builds upon MCBasicTypes and enables to model four kinds of generics:

  • Set
  • List
  • Map
  • Optional

These generics cannot be nested as the purpose of the MCCollectionTypes language component is the provisioning of some commonly used collection types whose functionality is limited to support the construction of high-level models. With the language component types such as List<Integer>, Set<char>, or Map<java.lang.String, Person> become expressible.


This language component extends the MCCollectionTypes component to allow the expression of types with custom generics of arbitrary classes with arbitrary arguments. When using the component, types such as Person<String> or Map<Person<String>, Integer> are expressible. Please note that these types still do not cover all possible Java types as Java additionally supports inner types of generic types. Specifically, types such as a.b.C<D>.E.F<G>.H are not expressible by MCSimpleGenericTypes.


This language component extends the MCSimpleGenericTypes component to allow the expression of inner generic types of arbitrary classes with arbitrary arguments including wild card types. When using this language component, types such as Person<?>, Map<Person<String>, ? extends Person>, and a.b.C<D>.E.F<G>.H are expressible.


This language component provides rules to express array types like Person[] or int[][]. As array types are orthogonal to generic types, MCArrayTypes can be combined with any of the above language components.

Further Information