CBCL / DocumentationDocs v0.3.1

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.

On this page

Atoms

KindExamplesRule
String"Lunch?", "@bob"Double quotes enclose text. The second example is text that contains an address spelling.
Symbolvote, @bob, +A symbol names a verb, parameter, role, or other value. Position determines its use.
Keyword:choice, :2faA colon introduces a keyword. In a message, a keyword takes the next expression as its value.
Boolean#t, #fThese are the two Boolean literals.
Integer0, -42The value must fit in a signed 64-bit integer.
Float2.0, 1e-3A fraction or exponent selects binary64. The result must be finite.
Decimal12.34m, 2mThe 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.