blob: a99ca7d9e0b69164cd38c7d34f15395ea07c6b0b [file] [log] [blame]
<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>2.1.6.&nbsp;Pattern Variable</title><link href="style.css" rel="stylesheet" type="text/css"><meta content="DocBook XSL Stylesheets V1.72.0" name="generator"><link rel="start" href="index.html" title="The VIATRA2 Model Transformation Framework"><link rel="up" href="sec_PatternDefinition.html" title="2.1.&nbsp;Pattern Definition"><link rel="prev" href="def_PatternComposition.html" title="2.1.5.&nbsp;Pattern Composition"><link rel="next" href="def_PatternVariableAssignment.html" title="2.1.7.&nbsp;Pattern Variable Assignment"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table summary="Navigation header" width="100%"><tr><th align="center" colspan="3">2.1.6.&nbsp;Pattern Variable</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="def_PatternComposition.html">Prev</a>&nbsp;</td><th align="center" width="60%">2.1.&nbsp;Pattern Definition</th><td align="right" width="20%">&nbsp;<a accesskey="n" href="def_PatternVariableAssignment.html">Next</a></td></tr></table><hr></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="def_PatternVariable"></a>2.1.6.&nbsp;Pattern Variable</h4></div></div></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip: Description"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left"><a name="def_PatternVariable_Description"></a>Description</th></tr><tr><td valign="top" align="left"><p>
<span class="strong"><strong>Pattern variable</strong></span>
<a name="N10706" class="indexterm"></a>
<a name="N1070B" class="indexterm"></a>
is a variable that appears in a graph pattern, i.e. (i) in the formal parameter list of a
<a href="def_GraphPatternDef.html" title="2.1.1.&nbsp;Graph Pattern Definition">graph pattern definition</a>,
(ii) in the definition of a (local) model element in a
<a href="def_PatternBody.html" title="2.1.2.&nbsp;Pattern Body">pattern body</a>, (iii) in a
<a href="def_PatternVariableAssignment.html" title="2.1.7.&nbsp;Pattern Variable Assignment">pattern variable assignment</a>
or (iv) in the
<a href="def_ActualParameter.html" title="5.8.3.&nbsp;Actual Parameters">actual parameters</a>
of (positive or negative)
<a href="def_PatternComposition.html" title="2.1.5.&nbsp;Pattern Composition">pattern composition</a>.
</p></td></tr></table></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important: Syntax"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"><a name="def_PatternVariable_Syntax"></a>Syntax</th></tr><tr><td valign="top" align="left"><pre class="programlisting">
PatternVariableDefAST ::= <a href="def_UpperCaseLiteral.html" title="6.2.3.&nbsp;UpperCase Literal">UpperCaseLiteral</a>
PatternVariableRefAST ::= <a href="def_UpperCaseLiteral.html" title="6.2.3.&nbsp;UpperCase Literal">UpperCaseLiteral</a>
PatternVariableDefRefAST ::= <a href="def_UpperCaseLiteral.html" title="6.2.3.&nbsp;UpperCase Literal">UpperCaseLiteral</a>
</pre><p>
Syntactically, a <span class="strong"><strong>pattern variable</strong></span>
<a name="N1073F" class="indexterm"></a>
is (an ASM)
<span class="strong"><strong>Variable</strong></span>
<a name="N10748" class="indexterm"></a>, i.e.
begins with an uppercase letter that can be followed by an arbitrary number
of alphanumerical characters. A pattern variable can be a
<span class="strong"><strong>pattern variable definition</strong></span>
<a name="N10751" class="indexterm"></a> or
<span class="strong"><strong>pattern variable reference</strong></span>
<a name="N1075C" class="indexterm"></a>
(or something both at the same time).
</p></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note: Semantics"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"><a name="def_PatternVariable_Semantics"></a>Semantics</th></tr><tr><td valign="top" align="left"><p>
The binding of a
<span class="strong"><strong>pattern variable</strong></span>
is more restrictive compared to that of a ASM
<a href="def_Variable.html" title="5.7.2.&nbsp;Variable">Variable</a>.
</p><p>
Unless being an input parameter of the pattern, a
<span class="strong"><strong>pattern variable</strong></span>
should always be bound to a model element. Furthermore, if a graph pattern is flattened along
<a href="def_PatternComposition.html" title="2.1.5.&nbsp;Pattern Composition">pattern composition</a>
(i.e. by composing the subpatterns into a complex flat pattern), then all output
<span class="strong"><strong>pattern variable definitions</strong></span>
are required to appear in the definition of a model element, i.e. as the
first parameter of an
<a href="def_Entity.html" title="2.2.1.&nbsp;Entity">entity</a> or a
<a href="def_Relation.html" title="2.2.2.&nbsp;Relation">relation</a>.
</p><p>
Moreover, if each <span class="strong"><strong>pattern variable reference</strong></span> should be
resolved to <span class="strong"><strong>pattern variable definitions</strong></span> within the same
pattern body
</p><p>
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.
</p></td></tr></table></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning: Exceptions"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Warning]" src="images/warning.png"></td><th align="left"><a name="def_PatternVariable_Exception"></a>Exceptions</th></tr><tr><td valign="top" align="left"><p>
When binding an output a pattern variable to anything else but model element during pattern matching, a run-time
exception is thrown:
<span class="emphasis"><em>"Invalid pattern variable binding: Pattern variable X should be bound
to a model element and not to term Y."</em></span>
</p></td></tr></table></div><div class="highlights"><a name="def_PatternVariable_UsedBy"></a><p><b>Used By:&nbsp;</b>
<a href="def_PatternComposition.html" title="2.1.5.&nbsp;Pattern Composition">pattern composition</a>
</p></div><div class="highlights"><a name="def_PatternVariable_SeeAlso"></a><p><b>See Also:&nbsp;</b>
<a href="def_Variable.html" title="5.7.2.&nbsp;Variable">Variable</a>
</p></div></div><div class="navfooter"><hr><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="def_PatternComposition.html">Prev</a>&nbsp;</td><td align="center" width="20%"><a accesskey="u" href="sec_PatternDefinition.html">Up</a></td><td align="right" width="40%">&nbsp;<a accesskey="n" href="def_PatternVariableAssignment.html">Next</a></td></tr><tr><td valign="top" align="left" width="40%">2.1.5.&nbsp;Pattern Composition&nbsp;</td><td align="center" width="20%"><a accesskey="h" href="index.html">Home</a></td><td valign="top" align="right" width="40%">&nbsp;2.1.7.&nbsp;Pattern Variable Assignment</td></tr></table></div></body></html>