<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>2.1.7. Pattern Variable Assignment</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. Pattern Definition"><link rel="prev" href="def_PatternVariable.html" title="2.1.6. Pattern Variable"><link rel="next" href="def_CheckCondition.html" title="2.1.8. Check Condition"></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.7. Pattern Variable Assignment</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="def_PatternVariable.html">Prev</a> </td><th align="center" width="60%">2.1. Pattern Definition</th><td align="right" width="20%"> <a accesskey="n" href="def_CheckCondition.html">Next</a></td></tr></table><hr></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="def_PatternVariableAssignment"></a>2.1.7. Pattern Variable Assignment</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_PatternVariableAssignment_Description"></a>Description</th></tr><tr><td valign="top" align="left"><p> | |
A | |
<span class="strong"><strong>pattern variable assignment</strong></span> | |
<a name="N107C1" class="indexterm"></a> | |
is part of a | |
<a href="def_PatternBody.html" title="2.1.2. Pattern Body">pattern body</a>. | |
It defines the equality of two locally visible variable. | |
</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_PatternVariableAssignment_Syntax"></a>Syntax</th></tr><tr><td valign="top" align="left"><pre class="programlisting"> | |
PatternVariableAssignmentAST ::= <a href="def_PatternVariable.html" title="2.1.6. Pattern Variable">PatternVariableRefAST</a> <span class="token">=</span> <a href="def_PatternVariable.html" title="2.1.6. Pattern Variable">PatternVariableRefAST</a> | |
</pre></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_PatternVariableAssignment_Semantics"></a>Semantics</th></tr><tr><td valign="top" align="left"><p> | |
By default, two pattern variables are bound to different model elements according to the injective pattern | |
matching principle. By | |
<span class="strong"><strong>pattern variable assignment</strong></span>, | |
two pattern variables are declared to be equal, i.e. to store (share) the same | |
model element. | |
</p><p> | |
The effect of a | |
<span class="strong"><strong>pattern variable assignment</strong></span> | |
<a name="N107EC" class="indexterm"></a> | |
$X = Y $depends on the bindings of pattern variables as follows: | |
</p><div class="itemizedlist"><ul type="disc"><li><p> | |
If both <code class="computeroutput">X</code> | |
and <code class="computeroutput">Y</code> | |
are bound (input) pattern variables, or both of them are free variables, then the pattern matcher | |
treats <code class="computeroutput">X = Y</code> | |
as a constraint. Furthermore, it obviously removes injectivity checks for the pair | |
<code class="computeroutput">X</code> | |
and <code class="computeroutput">Y</code>. | |
</p></li><li><p> | |
If exactly one of pattern variables | |
<code class="computeroutput">X</code> | |
and <code class="computeroutput">Y</code> | |
are free (e.g. let it be <code class="computeroutput">X</code>), | |
then the value of the bound variable | |
<code class="computeroutput">Y</code> | |
is assigned to the free variable | |
<code class="computeroutput">X</code>. | |
</p></li></ul></div></td></tr></table></div><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Caution: Constraints"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Caution]" src="images/caution.png"></td><th align="left"><a name="def_PatternVariableAssignment_Constraints"></a>Constraints</th></tr><tr><td valign="top" align="left"><p> | |
At least one of the variables in the assignment have to appear in the pattern body either as | |
<a href="def_PatternBody.html" title="2.1.2. Pattern Body">locally defined body element</a> | |
or in a (positive) | |
<a href="def_PatternComposition.html" title="2.1.5. Pattern Composition">pattern composition</a>, | |
otherwise a compile-time error is generated. | |
</p></td></tr></table></div><div class="highlights"><a name="def_PatternVariableAssignment_DefinedIn"></a><p><b>Defined In: </b> | |
<a href="def_PatternBody.html" title="2.1.2. Pattern Body">pattern body</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_PatternVariable.html">Prev</a> </td><td align="center" width="20%"><a accesskey="u" href="sec_PatternDefinition.html">Up</a></td><td align="right" width="40%"> <a accesskey="n" href="def_CheckCondition.html">Next</a></td></tr><tr><td valign="top" align="left" width="40%">2.1.6. Pattern Variable </td><td align="center" width="20%"><a accesskey="h" href="index.html">Home</a></td><td valign="top" align="right" width="40%"> 2.1.8. Check Condition</td></tr></table></div></body></html> |