CRNL (carriage return, newline) pairs are in all important cases converted to newlines during scanning.
The characters ``#'', ``!'', ``,'', ``;'', ``:'', ``$'', ``~'', ``['', ``]'', ``{'', ``}'', ``('', ``)'', `` ` '', `` ' '', ``<'', and ``>'' are special. In most cases, any of the special characters and whitespace (space, tab, newline, formfeed, null) terminate any preceding token. All other characters including non-printing characters are considered regular characters.
A comment starts with a ``#'' character outside of a string context and extends to the next newline or formfeed.
Procedures are actually executable arrays, but Onyx provides special syntax for declaring procedures. Procedures are delimited by ``{'' and ``}'', and can be nested. Normally, the interpreter executes code as it is scanned, but inside of procedure declarations, execution is deferred. Instead of executing a procedure body as it is encountered, the tokens of the procedure body are pushed onto the operand stack until the closing ``}'' is encountered, at which time an executable array is constructed from the tokens in the procedure body and pushed onto the operand stack.
A partial grammar specification, using BNF notation (where convenient) is as follows:
foo # executable 4noth3r # executable !bar # evaluable :method # callable ;method # invokable ,data # fetchable $biz # literal ~baz # immediately evaluated
If the result of an immediately evaluated name is an executable array, the evaluable attribute is set for the array so that when the array is interpreted, it is executed. This allows immediate evaluation to be indiscriminately used without concern for whether the result is an executable array or, say, an executable operator.
``\'' has no special meaning unless followed by a character in the above list. This is especially convenient when specifying regular expressions.
Examples include:
`' `A string.' `An embedded \n newline.' `Another embedded newline.' `An ignored \ newline.' `Balanced ` and ' are allowed.' `Manually escaped \` tick.' `Manually escaped \` tick and `balanced unescaped ticks'.' `An actual \\ backslash.' `Another actual \ backslash.'
0 42 -365 +17
2@101 16@ff 16@Ff 16@FF -10@42 10@42 +10@42 9@18 35@7r3x 35@7R3x
0. .0 3. .141 3.141 42.75 +3.50 -5.0
6.022e23 60.22e22 6.022e+23 1.661e-24 1.661E-24
Arrays do not have explicit syntactic support, but the [ and ] operators support their construction. Examples of array construction include:
[] [0 `A string' `Another string.' true] [5 42 false]
Dictionaries do not have explicit syntactic support, but the < and > operators support their construction. Examples of dictionary construction include:
<> <$answer 42 $question `Who knows' $translate {babelfish} >
Stacks do not have explicit syntactic support, but the ( and ) operators support their construction. Examples of stack contstruction include:
() (1 2 mark `a')