Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "VIATRA2/Examples/VTCL/Terms"
(→VTCL Terms and Expressions) |
(→VTCL Terms and Expressions) |
||
Line 7: | Line 7: | ||
* Undefined value constant: '''undef''' | * Undefined value constant: '''undef''' | ||
* Boolean constants: '''true''', '''false''' | * Boolean constants: '''true''', '''false''' | ||
− | * Integer constants: '''1''', '''-1''', | + | * Integer constants: '''1''', '''-1''', |
* Double constants: '''2.32''', '''-1.9''', (as in Java) | * Double constants: '''2.32''', '''-1.9''', (as in Java) | ||
* String constants: '''"A string."''' (as in Java) | * String constants: '''"A string."''' (as in Java) | ||
− | * Model element constants: fully qualified names, e.g. '''uml.metamodel.Classifier''', local names: '''ejbEntity''', ''' 'Class' ''' (local names starting with a capital letter should be included within quotes. | + | * Model element constants: fully qualified names, e.g. '''uml.metamodel.Classifier''', local names: '''ejbEntity''', ''' 'Class' ''' (local names starting with a capital letter should be included within quotes. |
* Multiplicity constants: '''one_to_one''', '''one_to_many''', '''many_to_one''', '''many_to_many''', | * Multiplicity constants: '''one_to_one''', '''one_to_many''', '''many_to_one''', '''many_to_many''', | ||
+ | |||
+ | In case of model element constants, a corresponding element should be present in the model space (at compile time), otherwise an error message is issued. | ||
+ | |||
+ | <source lang="text"> | ||
+ | machine vtcl_constants { | ||
+ | rule main() = seq { | ||
+ | // Undefined constant | ||
+ | println(undef); | ||
+ | // Boolean constants | ||
+ | println(true); | ||
+ | println(false); | ||
+ | // String constants | ||
+ | print("Hello VIATRA2 world!"); | ||
+ | // Integer constants | ||
+ | println(4); | ||
+ | println(-4); | ||
+ | // Double constants | ||
+ | print(4.6); | ||
+ | print(-4.7); | ||
+ | print(6.6e2); | ||
+ | print(10e-2); | ||
+ | // Model elemenent constants | ||
+ | // (provided that entity testing.models.manager exists in model space) | ||
+ | print(fqn(testing.models.manager)); | ||
+ | print(fqn('testing')); | ||
+ | // Multiplicity constant | ||
+ | print(one_to_one); | ||
+ | print(one_to_many); | ||
+ | print(many_to_one); | ||
+ | print(many_to_many); | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | |||
=== Logical Terms === | === Logical Terms === |
Revision as of 10:08, 17 February 2009
VTCL Terms and Expressions
Constants
The followind types of constants are available in VTCL:
- Undefined value constant: undef
- Boolean constants: true, false
- Integer constants: 1, -1,
- Double constants: 2.32, -1.9, (as in Java)
- String constants: "A string." (as in Java)
- Model element constants: fully qualified names, e.g. uml.metamodel.Classifier, local names: ejbEntity, 'Class' (local names starting with a capital letter should be included within quotes.
- Multiplicity constants: one_to_one, one_to_many, many_to_one, many_to_many,
In case of model element constants, a corresponding element should be present in the model space (at compile time), otherwise an error message is issued.
machine vtcl_constants { rule main() = seq { // Undefined constant println(undef); // Boolean constants println(true); println(false); // String constants print("Hello VIATRA2 world!"); // Integer constants println(4); println(-4); // Double constants print(4.6); print(-4.7); print(6.6e2); print(10e-2); // Model elemenent constants // (provided that entity testing.models.manager exists in model space) print(fqn(testing.models.manager)); print(fqn('testing')); // Multiplicity constant print(one_to_one); print(one_to_many); print(many_to_one); print(many_to_many); } }
Logical Terms
Logical terms consist of usual binary Boolean operators such as "&&" (and), "||" (or), "xor" (exclusive or), and unary operator "!" (not).
The precedence of Boolean operators are as follows: "!" (highest), "&&", { "||"; "xor" } (lowest). Operator precedence can be overridden by parenthesis. All previous operators tie as usual (to the left)
Equality (and inequality) operators, namely, "==" (equal), and "!=" (not equal), are also allowed for Boolean values.
There are two logical constants: "true" and "false".
machine logical_operators{ rule main() = seq { print(!true); print(!false); print(true && false); print(true || false); print(true xor false); print(true == true); print(false != true); // The internal pairs of parenthesis are not needed print((true && false) || (true && true)); print((true == true) != false)); // The internal pairs of parenthesis are needed print((true || false) && (true || false)); print(true == (true != false)); } }