| Types and values | |
| Simple | |
| String | "string" |
| Boolean | true |
| Integer | 1 -100 |
| Decimal | 24.86 |
| Date | d'yyyy-MM-dd HH:mm:ss.SSS' |
| LocalDate | ld'yyyy-MM-dd' |
| Object | any expression |
| Null | null |
| Containers | |
| Set<T> | { element1,… } |
| List<T> | [ element1,… ] |
| List<Integer> | -5..81 |
| Map<K,V> | [ key1 -> value1,… ] empty map: [ -> ] |
| Other | |
| Record | new record_name() |
| Reference<T> | &variable |
| Closure {T,…: U} | { -> expression } |
| Type | type(type_definition) record_name |
| Operators | |
| Assignment | |
| Assignment | variable := expression |
| Arithmetic | |
| Addition | + |
| Subtraction | - |
| Increment | ++var var++ |
| Decrement | --var var-- |
| Multiplication | * |
| Division | / |
| Modulo | % |
| Exponentiation | ** |
| Boolean | |
| Equality | == != <> |
| Comparison | < <= > >= <=> instanceof |
| Negation | not ! |
| Conjunction | and && |
| Disjunction | or || |
| Exclusive disjunction | xor |
| Pattern matching | string like pattern |
| Collection containment | item in collection |
| Other | |
| String concatenation | + |
| Parenthetical grouping (precedence) | ( ) |
| Compound Assignment | |
| Addition | += |
| Subtraction | -= |
| Multiplication | *= |
| Division | /= |
| Modulo | %= |
| Access | |
| Set element | set[index] |
| List element | list[index] |
| Map element | map[key] |
| Record field | record.field |
| Record safe field | record?.field |
| Record reference field | reference.field |
| Record ref. safe field | reference?.field |
| Enumeration literal | enum.literal |
| Dereferencing | *reference |
| Namespace separator | :: |
| Function call | function|T1,…|(argument1, argument2,…) |
| Closure invocation | closure(argument1, argument2,…) |
| Method call | object.method(argument1, argument2,…) |
| Special constructs | |
| Local variable | def type namewith assignment: |
| Comments | // single-line comment |
| Assignment | variable := expression |
| Expression variable | def type namefinal variable: with assignment: |
| Expression chaining | expr1 ; expr2 ; expr3 ; … |
| Block | begin expression end |
| Error throw | error(string_expression) |
| Try-catch | try expression |
| Cast | expression as type |
Control flow If-then
If-then-else
If-then-elsif-then
If-then-elsif-then-else if condition1 then
expression1
elsif condition2 then
expression2
…
else
expressionN
end Ternary conditional condition ? expression1 : expression2Null-coalescing expression1 ?? expression2Switch switch arg_expression
case c1, c2,… -> expression1
…
default -> defaultExpression
end While looping while condition do
expression
end For looping for(init; condition; update) do
expression
end Collection iteration foreach type iterator in collection do
expression
end Looping break
(in while,for and foreach) break Looping iteration skipping
(in while, for and foreach) continue
Function definition file Function /** description */
annotations
visibility <T,…> ReturnType function(Type1 param1,…)
body Function body expression: { expression } native:
native java_method_path Annotations @SideEffect
@Deprecated
@Disabled
@Status(statusName)
@Meta(key1->value1, key2->value2,…) Visibility public
private Function parameter optional: Type name mandatory:
Type name* variadic:
Type... name default value:
Type name = defaultValueExpression
Method definition file Record methods Record {
methods
} Method /** description */ Note: Annotations and parameters follow syntax of function.
annotations
visibility modifiers <T,…> ReturnType function(Type1 param1, Type2 param2*,…)
body
Constructor /** description */ Note: Annotations, parameters and body follow syntax of function; visibility follows syntax of method.
annotations
visibility Record(Type1 param1, Type2 param2*,…)
body
Method body expression: { expression } native:
native java_method_path abstract:
; Visibility public
private
protected Modifiers abstract
static Access (only in method) This instance this Super-type members super.method(argument,…) Access (only as first statement of constructor) Calling constructor of this record this(argument,…) Calling constructor of supertype super(argument,…)