# Expressions

The Encodo base library includes a simple query language with which an application can construct queries.

## Constructs

- Integers:
`6`

- Real numbers:
`45.678`

or`45.678f`

- Money:
`45.678m`

- Constant null:
`null`

- Boolean constants:
`true`

,`false`

- Single-quoted strings:
`'A ''quoted'' string'`

- Double-quoted strings:
`"A \"quoted\" string"`

- Function calls:
`A.B.C(2).D("B", "C")`

- Indexed calls:
`A[2, "four"]`

- Sets:
`[A, B, 2, "three"]`

- Array operators:
`[+::1,1,2,3]`

## Operators

Operator | Description | Parameter Types | Usage |
---|---|---|---|

`==` |
Equal | Number | infix |

`!=` |
Not equal | Number | infix |

`>` |
Greater than | Number | infix |

`<` |
Less than | Number | infix |

`>=` |
Greater than or equal | Number | infix |

`<=` |
Less than or equal | Number | infix |

`*` |
Multiply | Number | infix |

`/` |
Divide | Number | infix |

`+` |
Add | Number | infix |

`-` |
Subtract | Number | infix |

`%=` |
begins with | String | infix |

`=%` |
ends with | String | infix |

`%=%` |
contains | String | infix |

`=@` |
matches regular expression | String | infix |

`~~` |
equals Case-Insensitive (CI) | String | infix |

`%~` |
begins with CI | String | infix |

`~%` |
ends with CI | String | infix |

`%~%` |
contains CI | String | infix |

`~@` |
matches regular expression CI | String | infix |

`&&` |
logical AND | Boolean | infix |

`\|\|` |
logical OR | Boolean | infix |

`!` |
logical NOT | Boolean | prefix |

`?` |
unary IS NULL | Any | prefix |

`#` |
Concatenate | String | infix |

`in` |
Containment | Any | Array |

`^` |
Exponent | Number | infix |

`??` |
Null-coalescing | Any | Any |

`=>` |
Formatting | String | infix |

### Precedence

Operator precedence is enforced with staggered productions in the grammar and consists of five precedence levels (from most-binding to least):

Level | Operators |
---|---|

1 | `^` , `#` , `=>` |

2 | `*` , `/` , `%` , `&&` |

3 | `+` , `-` , ` |

4 | `==` , `!=` , `~~` , `!~` , `<` , `>` , `<=` , `>=` , `in` , `%=` , `=%` , `%=%` , `%~` , `~%` , `%~%` , `~@` , `=@` |

5 | `??` |