Expressions can be constructed from operands and operators.
Prefix operations are written using one of PLUS(tree), MINUS(tree), NOT(tree), or TILDE(tree):
PLUS(LIT(1)) // +(1)
MINUS(LIT(1)) // -(1)
NOT(FALSE) // !(false)
TILDE(LIT(1)) // ~(1)
Postfix operations are written by calling POSFIX(sym|"x") on a tree or a symbol:
LIT(1) POSTFIX(Any_toString) // 1 toString
Infix operations are written using INFIX(sym|"op") as follows:
LIT(1) INFIX("+") APPLY(LIT(2))
This prints as:
1 + 2
Alternatively, INFIX(sym|"op", arg, ...) can be called with righ-hand side arguments:
LIT(1) INFIX("+", LIT(2)) // 1 + 2
Finally, for commonly used operations treehugger DSL defines some built-in operators, which will be covered later:
LIT(1) INT_+ LIT(2) // 1 + 2