/* (c) https://github.com/MontiCore/monticore */ package de.monticore; /* This is a MontiCore stable grammar. * Adaptations -- if any -- are conservative. */ import de.monticore.literals.*; import de.monticore.*; /** * Grammar to describe Cardinalities * * This grammar defines UML Cardinalities of forms "*", "[n..m]" "[n..*]" * or also with spaces: "[ 3 .. * ]". */ component grammar Cardinality extends de.monticore.MCBasics, MCCommonLiterals { /** ASTCardinality represents a Cardinality in the UML/P @attribute many True if "*" is set as Cardinality @attribute lowerBound Minimum number of associated Classes/Objects @attribute upperBound Maximum number of associated Classes/Objects; zero denotes that there is no upper bound set. @attribute lowerBoundLit Lower bound as Literal @attribute upperBoundLit Upper bound as Literal @attribute noUpperLimit True if a lower, but no upper bound exists "[n..*]" */ Cardinality = "[" ( many:["*"] {_builder.setLowerBound(0);_builder.setUpperBound(0);} | lowerBoundLit:NatLiteral { _builder.setLowerBound( _builder.getLowerBoundLit().getValue()); _builder.setUpperBound(_builder.getLowerBound()); } ( ".." ( upperBoundLit:NatLiteral ( {_builder.setUpperBound( _builder.getUpperBoundLit().getValue());}) | noUpperLimit:["*"] {_builder.setUpperBound(0);} ) )? ) "]"; /** A Cardinality Object stores the bounds as integers. */ astrule Cardinality = lowerBound:int upperBound:int; }