![]() | Description |
---|---|
A ASM variable can be defined and used in ASM programs. It is a run-time placeholder for an ASM term. A variable always have to be defined prior to its first use. |
![]() | Syntax |
---|---|
VariableRefAST ::= UpperCaseLiteral VariableDefAST ::= UpperCaseLiteral A variable is an upper case literal, i.e. it begins with an uppercase letter that can be followed by an arbitrary number of alphanumeric characters. |
![]() | Semantics |
---|---|
A variable always has to defined prior to its first use. A new ASM variable can be defined by a let rule, a choose rule, a forall rule, or as a formal parameter of an ASM rule. ASM variables are untyped at compile-time, i.e. we cannot assign types at compile-time. Thus the type of a variable is induced at run-time, and this run-time type may change during execution, i.e. the same variable may store once an integer value and then a string, for instance, but, of course, it is not a good practice for writing transformations. Variables can contain constants of the following types: string, integer, float, boolean, and model elements. The scope of an ASM variable can be defined according to the place where the variable was defined first, thus it can be rule-scopeor block-scope. ASM rules that define variables with block-scope are the let rule, the forall ruleand the choose rule. Each variable is visible and accessible anywhere inside its scope including sub-blocks at arbitrary depth, but it becomes undefined outside its scope. As a result, ASM variables that are undefined within a certain scope cause compilation errors. A variable can be defined only by the let rule, choose ruleand forall ruleor in a formal parameter list ( formal params, directed formal params). |