/* (c) https://github.com/MontiCore/monticore */ package de.monticore.types; /* This is a MontiCore stable grammar. * Adaptations -- if any -- are conservative. */ import de.monticore.types.*; /** * This grammar defines four generics: List<>, Map<,>, Set<> * and Optional<> on top of basic types. * * These four generics correspond to a typical predefined set of generic * types for example used in connection with UML class diagrams or the * OCL. * UML associations typically have those association multiplicities and * therefore these types are of interest. * * This eases the reuse of type structures in languages similar to Java, * that are somewhat simplified, e.g. without general generics. * * This grammar is part of a hierarchy of types, namely * * types.MCBasicTypes.mc4 * * types/MCArrayTypes.mc4 * * types/MCCollectionTypes.mc4 * * types/MCSimpleGenericTypes.mc4 * * types/MCFullGenericTypes.mc4 * */ component grammar MCCollectionTypes extends MCBasicTypes { /*=================================================================*/ /** * MCGenericType covers the following four forms of generics. * E.g. in visitors it can also be used to restrict to these * forms of generics even if further generics would be available. */ interface MCGenericType extends MCObjectType; /*=================================================================*/ /* The following definitions use the next-Command and thus * avoid "List" etc. to become keywords */ MCListType implements MCGenericType <200> = key("List") "<" MCTypeArgument ">"; MCOptionalType implements MCGenericType <200> = key("Optional") "<" MCTypeArgument ">"; MCMapType implements MCGenericType <200> = key("Map") "<" key:MCTypeArgument "," value:MCTypeArgument ">"; MCSetType implements MCGenericType <200> = key("Set") "<" MCTypeArgument ">"; /*=================================================================*/ /** * ASTMCTypeArgument interface describes arguments of generic types. * Eg. such as qualified or primitive types. * * This is also an extension point for more general type arguments. */ interface MCTypeArgument; MCBasicTypeArgument implements MCTypeArgument <200> = MCQualifiedType; MCPrimitiveTypeArgument implements MCTypeArgument <190> = MCPrimitiveType; }