Whitespace can be a space character, a tab character, a newline character, or a comment. Implementations can define additional whitespace characters.
A comment can be single-line or delimited. Although comments count as whitespace, the beginning of a comment can blend with a preceding token, so in general comments should be surrounded by genuine whitespace.
A single-line comment consists of two slash characters in a row, followed by any number of characters up to and including the first newline character or the end of the source record. For example,
// This line is a kludge!.
A delimited comment consists of a slash character immediately followed by a star character, any number of characters including balanced slash-star / star-slash pairs, and finally a star character immediately followed by a slash character. For example,
/* set x to 3 */.
A single-line comment may appear within a delimited comment; occurances of slash-star or star-slash within the single line comment are ignored.
A token is a name, a #-word, an operator, a number, a character literal, a string literal, a symbol literal, or punctuation.
A name is one of the following four possibilities:
The rich set of name characters means that name and operator tokens can blend. Thus Dylan programs usually set off operators with whitespace.
Implementations can add additional characters but programs using them will not be portable.
A #-word is one of
#all-keys. The first two are literal constants, the others are used in parameter lists. Implementations can add additional implementation-defined #-words, but programmers cannot add their own #-words.
- subtraction and negation
< less than
> greater than
<= less than or equal
>= greater than or equal
~= not equal
~== not identical
& logical and
| logical or
~ logical negation
Programmers cannot add their own operators.
A number is a decimal integer with an optional leading sign, a binary integer, an octal integer, a hexadecimal integer, a ratio of two decimal integers with an optional leading sign, or a floating-point number. The complete syntax of numbers is given in "Numbers" on page 404.
The backslash escape sequences used in character and string literals allow "quoting" of the special characters ', ", and \, provide names for "control" characters such as newline, and allow Unicode characters to be specified by their hexadecimal codes.
] square brackets
} curly brackets
:: type specialization
== singleton specialization
#( list/pair literal
#[ vector literal
?? macro pattern variables
... macro ellipsis
Note that some tokens are both punctuation and operators. This ambiguity is resolved by grammatical context.
Note that some punctuation tokens (for example period and equal sign) are capable of blending into some other tokens. Where this can occur, whitespace must be inserted to delimit the token boundary.
Generated with Harlequin WebMaker