Skip to content

1.3 Expressions

Studio 42 GmbH edited this page Dec 27, 2022 · 1 revision

In attribute assignments you can use expressions like 3 + 4 etc. You can concatenate strings, do boolean and numeric terms.

Here is excerpt of the parser definition in ANTLR4 grammar:

expression : 
	PARENTHESES_OPEN expression PARENTHESES_CLOSE
	| expression POW expression
	| expression ( MUL | DIV ) expression
	| expression ( PLUS | MINUS ) expression
	| expression ( AND | OR | XOR | EQUALS ) expression
	| NOT expression
	| MINUS? atom ;

atom : FLOAT_LITERAL | INTEGER_LITERAL | BOOLEAN_LITERAL | STRING_LITERAL | SYMBOL | REF ;

This allows you to create complex nested expressions consisting of doubles, ints and references like:

Double v : 1.33; Double t : (6.5 * (7.12 + -$v) - 5.3E2 * (5 - 3)) / 3.0;

For further details on the possibilites read the unit tests test package

Clone this wiki locally