2.1.6. Pattern Variable

[Tip]Description

Pattern variable is a variable that appears in a graph pattern, i.e. (i) in the formal parameter list of a graph pattern definition, (ii) in the definition of a (local) model element in a pattern body, (iii) in a pattern variable assignment or (iv) in the actual parameters of (positive or negative) pattern composition.

[Important]Syntax
PatternVariableDefAST ::= UpperCaseLiteral
PatternVariableRefAST ::= UpperCaseLiteral
PatternVariableDefRefAST ::= UpperCaseLiteral

Syntactically, a pattern variable is (an ASM) Variable , i.e. begins with an uppercase letter that can be followed by an arbitrary number of alphanumerical characters. A pattern variable can be a pattern variable definition or pattern variable reference (or something both at the same time).

[Note]Semantics

The binding of a pattern variable is more restrictive compared to that of a ASM Variable.

Unless being an input parameter of the pattern, a pattern variable should always be bound to a model element. Furthermore, if a graph pattern is flattened along pattern composition (i.e. by composing the subpatterns into a complex flat pattern), then all output pattern variable definitions are required to appear in the definition of a model element, i.e. as the first parameter of an entity or a relation.

Moreover, if each pattern variable reference should be resolved to pattern variable definitions within the same pattern body

Note, that input parameters of a pattern may still be bound to arbitrary ASM terms. However, this binding is already carried out before pattern matching is initiated.

[Warning]Exceptions

When binding an output a pattern variable to anything else but model element during pattern matching, a run-time exception is thrown: "Invalid pattern variable binding: Pattern variable X should be bound to a model element and not to term Y."

Used By:  pattern composition

See Also:  Variable