Text and values
CBCL reads UTF-8 text. Each input contains one S-expression. An S-expression is an atom or a parenthesized list of expressions. The empty list is (). A list can contain other lists.
Atoms
| Kind | Examples | Rule |
|---|---|---|
| String | "Lunch?", "@bob" | Double quotes enclose text. The second example is text that contains an address spelling. |
| Symbol | vote, @bob, + | A symbol names a verb, parameter, role, or other value. Position determines its use. |
| Keyword | :choice, :2fa | A colon introduces a keyword. In a message, a keyword takes the next expression as its value. |
| Boolean | #t, #f | These are the two Boolean literals. |
| Integer | 0, -42 | The value must fit in a signed 64-bit integer. |
| Float | 2.0, 1e-3 | A fraction or exponent selects binary64. The result must be finite. |
| Decimal | 12.34m, 2m | The lowercase suffix selects an exact decimal. Decimal literals do not accept an exponent. |
A numeric token starts with a digit or a minus followed by a digit. For example, +1.0 and -.5 are symbols. The forms 2, 2.0, and 2m have three different types. A shape can distinguish them.
Character and token rules
Symbols use ASCII letters and these characters: _ . / ! ? + * < > = @ -. Digits can follow the first character. A leading minus has the numeric rule above. A keyword must have one or more symbol characters after its colon. Keywords can start with a digit after the colon.
A string can contain Unicode text. The escape sequences are \n, \r, \t, \", and \\. Outside strings, a semicolon starts a comment. The comment ends at the next line feed or the end of the input.
A space, tab, carriage return, line feed, or form feed can separate tokens. Parentheses delimit lists. Separate adjacent names with whitespace so that the reader can identify each token.
A list in a named field
This act opens a lunch poll. The lang form selects the dialect. The propose verb sends the question to @team.
(lang lunch-vote
(propose @team
:question "Lunch?"
:options ("Sushi" "Pizza")
:caused-by begin
:thread "friday"
:from @alice))
The value of :options is a list of two strings. The poll dialect defines the fields for propose.