Home    Reference > A Syntax > <exp>
prev next
Syntax
<exp> ::= <qualified>
<exp> ::= <prefix op> S? {'#' S? <primary> S?}? <exp>
<exp> ::= <exp> S? <infix op> S? {'#' S? <primary> S?}? <exp>

Description

Expressions can include both <prefix op>s and <infix op>s. The relative grouping of operators is controlled by Precedence and the rule that all infix operators are left associative. Parenthesis (see <primary>) can be used to modify that grouping.

The semantics of operators in the simple case is controlled by the type of their operands It is also possible to explicitly select an alternative semantics by specifying a type or view following a sharp.

Semantics

See the individual <prefix op>s and <infix op>s.

Parsing

Every operator has a corresponding function name (see the Precedence table). When parsed, infix and prefix operator expressions are represented by xdom:call nodes whose kind is set to "op". For example, each operator expression in the first column and call expression in the second column are represented by identical xdom:call nodes, except the first has kind "op" and the second has kind "normal".

- b Minus(a)
a + b Add(a,b)
-#t b t.sys:Minus(a)
a +#t b t.sys:Add(a,b)

Examples

In the expression
   a * b + c / d
the multiply and divide are done before the add. In the expression
   a - b - c
the left subtract is done before the right subtract.

The expression
   ~"abc" != "ABC"
uses the string sys:Eq function, but
   ~"abc" ==#fold "ABC"
uses the fold sys:Eq function that ignores case of letters.