Constraints are a more general way of expressing the intention of Value-checking logic and can be extended to apply to practically any Model element. Constraints can be represented by expressions which are a powerful and formal means of specifying the value checking. Value-checking logic (constraints) are parsed and stored in an Abstract Syntax Table (AST) in the same way as logic is stored.
Value-checking logic is defined as:
valuelogic = ConditionalExpression | ( ’this’, [’NOT’], ’in’, valuesetexpression)) ;
In narrative form – "the value is valid if the ConditionalExpression returns true or this (the actual variable or attribute instance) is valid if its value is in the set defined by valuesetexpression".
Note: Use of the identifier this for the current object makes it possible to use more generalized expression syntax.
Examples
Conditional expression – is not equal to 45 and twice this value is less than 80:
this NOT= 45 && this * 2 < 80
Conditional expression – is greater than zero:
this > 0
In set specified:
this in {"A", "C", "Z"}
Not in set specified:
this NOT in {"A","B"}
Is an uppercase letter but not 'M', 'N', or 'O':
this in {"A" .. "Z"} - {"M" .. "O"}
Is an uppercase letter or a single digit number:
this in {"A" .. "Z"} + {0 .. 9}