The basic expressions are the fundamental building blocks of all programs and include the following:
Constant literals represent values of the basic types string, integer, real, and Boolean and values of the type regexp.
These expressions simply evaluate to their corresponding values.
Strings are enclosed in quotation marks ("). . Examples:
"abc"
"a\"bc\tdef\n"
2
100
-2.0
3.4
This constant can be either true or false.
For the syntax of regular expressions, see Lexical elements. Regular expressions are enclosed in back quotes (`), as in this example:
`[a-zA-Z]+`
Tuples represent ordered collections of values. These expressions take the form of a parenthesized list of components separated by commas, as in these examples:
(1, true)
("abc", true, -2.0)
Arithmetic operations on primitive values are basic expressions. The arithmetic operators +, -, *, and / have the typical meanings over integers and reals. The arguments to an arithmetic operator must be of the same type, either integer or real.
Relational operations on primitive values are basic expressions. The relational operators =, <>, <, <=, >, and >= have the typical meanings over integers and reals, with <> representing the inequality operator. The arguments to a relational operator must agree in type.
Logical operations on primitive values are basic expressions over Boolean. The logical operators are as follows:
not
and
οr
implies (p implies q ≡ not p or q)
String concatenation, comparison, and pattern matching are basic expressions in the form of an infix operator.
The operator + concatenates two strings, as in this example:
"abc" + "def" ⇒ abcdef
The relational operators (=,<> ,<, <=, >, >=) implement lexicographical comparisons of strings, as in these examples:
"abc" = "abd" ⇒ false
"abc" <> "abd" ⇒ true
"abc" < "abd" ⇒ true
The operators ~= and ~<> compare a string on the left side against a regular expression on the right side for a match or a mismatch. The right side argument to ~= and ~<> must be a string literal rather than a regular expression literal, as in these examples:
"abc" ~= "a*" ⇒ true
"abc" ~<> "a*" ⇒ false
"10111010110101" ~= "[01]+" ⇒ true
"abcdefghijkl" ~= "[^01]+" ⇒ true