Expression Reference

From Creation Kit
Jump to: navigation, search
<expression>       ::= <and expression> ('||' <and expression>)*
<and expression>   ::= <bool expression> ('&&' <bool expression>)*
<bool expression>  ::= <add expression> (<comparison operator> <add expression>)*
<add expression>   ::= <mult expression> (('+' | '-') <mult expression>)*
<mult expression>  ::= <unary expression> (('*' | '/' | '%') <unary expression>)*
<unary expression> ::= ['-' | '!'] <cast atom>
<cast atom>        ::= <dot atom> ['as' <type>]
<dot atom>         ::= (<array atom> ('.' <array func or id>)*) | <constant>
<array atom>       ::= <atom> ['[' <expression> ']']
<atom>             ::= ('(' <expression> ')') | ('new' <type> '[' <int> ']') | <func or id>
<array func or id> ::= <func or id> ['[' <expression> ']']
<func or id>       ::= <function call> | <identifier> | 'length'

The basic expression is an arrangement of operators, function calls, and variables chained together in such a way to do some work. These operations follow the rules of precedence to determine which gets executed first.

Examples

; Add 2 to the value of 4 times 10 (result is 42)
2 + 4 * 10


; Add 2 to 4, and multiply by 10 (result is 60)
(2 + 4) * 10


; Call a function and get a property from the results
MyFunction().MyProperty


; Get the first element in the array returned by the function after a cast
(MyVariable as MyObject).MyFunction()[0]