blob: 681fee50caaa8f77d35c18e918239f98705c6541 [file] [log] [blame]
<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>4.3.5.&nbsp;Let Rule</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_ASMCompoundRules.html" title="4.3.&nbsp;Compound ASM Rules"><link rel="prev" href="def_RandomRule.html" title="4.3.4.&nbsp;Random Rule"><link rel="next" href="def_ChooseRule.html" title="4.3.6.&nbsp;Choose Rule"></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">4.3.5.&nbsp;Let Rule</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="def_RandomRule.html">Prev</a>&nbsp;</td><th align="center" width="60%">4.3.&nbsp;Compound ASM Rules</th><td align="right" width="20%">&nbsp;<a accesskey="n" href="def_ChooseRule.html">Next</a></td></tr></table><hr></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="def_LetRule"></a>4.3.5.&nbsp;Let Rule</h4></div><div><h5 class="subtitle">Variable Definition Rule</h5></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_LetRule_Description"></a>Description</th></tr><tr><td valign="top" align="left"><p>
The <span class="strong"><strong>let rule (variable definition rule)</strong></span><a name="N1169C" class="indexterm"></a> is used for defining
<a href="def_Variable.html" title="5.7.2.&nbsp;Variable">variable</a>for a given rule, typically
for a <a href="def_SequentialRule.html" title="4.3.2.&nbsp;Sequential Rule">sequential rule</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_LetRule_Syntax"></a>Syntax</th></tr><tr><td valign="top" align="left"><pre class="programlisting">
LetRuleAST ::= <span class="token">let</span> VariableDefinitionsAST <span class="token">in</span> <a href="def_AsmRuleInvoc.html" title="4.1.2.&nbsp;ASM Rule Invocation">AsmRuleAST</a>
VariableDefinitionsAST ::= VariableDefinitionAST
| VariableDefinitionsAST <span class="token">,</span> VariableDefinitionAST
VariableDefinitionAST ::= <a href="def_Variable.html" title="5.7.2.&nbsp;Variable">VariableDefAST</a> TypeOptAST <span class="token">=</span> <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">ArithmeticTermAST</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_LetRule_Semantics"></a>Semantics</th></tr><tr><td valign="top" align="left"><p>
An ASM variable needs to be defined explicitly prior to its first use. A
possible way of it is using the <span class="strong"><strong>let rule</strong></span>.
</p><p>
The <span class="strong"><strong>let rule</strong></span> defines a variable, initializes it with the value resulting
from the evaluation of the ASM <a href="def_Term.html" title="5.1.1.&nbsp;ASM Term">term</a> and then calls its internal
<a href="def_AsmRuleInvoc.html" title="4.1.2.&nbsp;ASM Rule Invocation">ASM rule</a>. The variable is accessible inside the scope of the
rule, i.e. only in its body <a href="def_AsmRuleInvoc.html" title="4.1.2.&nbsp;ASM Rule Invocation">ASM rule</a>.
</p></td></tr></table></div><div class="highlights"><a name="def_LetRule_DefinedIn"></a><p><b>Defined In:&nbsp;</b>
<a href="def_CompoundRule.html" title="4.3.1.&nbsp;Compound Rule">compound rule</a>
</p></div><div class="highlights"><a name="def_LetRule_SeeAlso"></a><p><b>See Also:&nbsp;</b>
A variable can be defined also with
the <a href="def_ForallRule.html" title="4.3.7.&nbsp;Forall Rule">forall rule</a> and the <a href="def_ChooseRule.html" title="4.3.6.&nbsp;Choose Rule">choose rule</a> or as a
parameter of an ASM rule.
</p></div></div><div class="navfooter"><hr><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="def_RandomRule.html">Prev</a>&nbsp;</td><td align="center" width="20%"><a accesskey="u" href="sec_ASMCompoundRules.html">Up</a></td><td align="right" width="40%">&nbsp;<a accesskey="n" href="def_ChooseRule.html">Next</a></td></tr><tr><td valign="top" align="left" width="40%">4.3.4.&nbsp;Random Rule&nbsp;</td><td align="center" width="20%"><a accesskey="h" href="index.html">Home</a></td><td valign="top" align="right" width="40%">&nbsp;4.3.6.&nbsp;Choose Rule</td></tr></table></div></body></html>