Identifiers in Wrapl begin with a letter or underscore _ followed by any number of letters, underscores and/or digits. Wrapl is case-sensitive, two identifiers differing only in case are considered as distinct identifiers. A number of identifiers are reserved as keywords, these are all written in upper case:
VAR, DEF, REP, EXIT, STEP, YIELD, WHILE, UNTIL, ALL, EVERY, DO IS, RET, SUSP, NIL, BACK, FAIL, IMP, USE, AS, IN, OF, MOD, TO, RECV, SEND, NOT, WHEN, END, SKIP, WITH, UNIQ, SUM, PROD, COUNT.
Integers in Wrapl can be written in decimal as a sequence of digits, or in a different base as base_digits where base is in decimal and digits can contain both digits and letters (depending on base). When base > 10, A and a both represent 10, B and b represent 11 and so on. Negative integers are preceeded by - with no space separating - and the rest of the integer. Integers in Wrapl can have arbitrary size, limited only by available memory.
Real numbers in Wrapl are written in decimal using scientific notation and must contain either a decimal point . or an exponent e/E or both. The power can begin with a - for negative exponents. Negative mantissas begin with - with no space separating - and the rest of the number.
There are 3 methods of writing strings in Wrapl, however all strings have the same type.
Simple strings are written in Wrapl between quotes "" and can not span more than one line. To include carriage return character, or other control character, use escape sequences as in C, for example: "\tTab and new line.\n". Arbitrary characters can be written as \xHH where HH is a two digit hexadecimal number.
Large blocks of text can be written in Wrapl using block strings. These start using >>EndMarker followed directly by a carriage return, where EndMarker is any text. They end with a line beginning with EndMarker. The string consists of all text between these two lines, including all whitespace such as tabs and carriage returns. Any code after EndMarker is parsed normally. For example:
Since Wrapl does not automatically convert values to strings, creating strings from a number of values using concatentation + is tedious. Instead, complex strings can be written between single quotes, ''. At runtime, the text between the quotes is copied with any expressions between braces {} being replaced by its value after converting to a string. For example:
will output x = 100. Complex strings can also span several lines and can contain escape sequences. They are implemented as a runtime function call to Std.String.Create and so will only produce a value if all the expressions in braces succeed.
Wrapl provides several high level data types, including lists and tables. Lists are written between brackets [], for example [1, "a", NIL, [10], x] is a list containing 5 values. Lists can also be constructed using ALL expressions: ALL expression will return a list consisting of the value produced by expression in the order they were produced. If expression fails to produce any value, the result will be an empty list []. For example: ALL 1:to(10) will give the list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].
Tables are key-value pairs written using braces {}, for example: {1 IS "one", "apple" IS [23]} is a table that maps 1 to "one" and "apple" to the list [23]. The IS value part may be omitted, in which the value defaults to NIL allowing tables to be used as sets, for example: {2, 3, 5, 7, 11}. Note that the keys can have any type, by default tables use :# to generate a hash value for each key and :? to compare keys, but tables with differing behaviour can be constructed using the Std.Table module directly.