Datum syntax

The datum syntax describes the syntax of syntactic data in terms of a sequence of lexemes, as defined in the lexical syntax.

The following grammar describes the syntax of syntactic data in terms of various kinds of lexemes defined in the grammar in section “Lexical Syntax”:

datum ::= defining-datum
         | nondefining-datum
         | defined-datum
nondefining-datum ::= lexeme-datum
         | compound-datum

lexeme-datum ::= boolean | number
         | character | string | symbol
symbol ::= identifier
compound-datum ::= list | vector | uniform-vector | array-literal | extended-string-literal | xml-literal
list ::= (datum*)
         | (datum+ . datum)
         | abbreviation
vector ::= #(datum*)

Datum labels

datum-label ::= #indexnum=
defining-datum ::= datum-label+nondefining-datum
defined-datum ::= #indexnum#
indexnum ::= digit+

The lexical syntax #n=datum reads the same as datum, but also results in datum being labelled by n, which must a sequence of digits.

The lexical syntax #n# serves as a reference to some object labelled by #n=; the result is the same object (in the sense of eq?) as the #n=.

Together, these syntaxes permit the notation of structures with shared or circular substructure.

(let ((x (list 'a 'b 'c)))
  (set-cdr! (cddr x) x)
  x)    ⇒ #0=(a b c . #0#)

The scope of a datum label is the portion of the outermost datum in which it appears that is to the right of the label. Consequently, a reference #n# can occur only after a label #n=; it is an error to attempt a forward reference. In addition, it is an error if the reference appears as the labelled object itself (as in #n=#n#), because the object labelled by #n= is not well defined in this case.

Abbreviations

abbreviation ::= r6rs-abbreviation | kawa-abbreviation
r6rs-abbreviation ::= abbrev-prefix datum
abbrev-prefix ::=  |  | , | ,@
         | #’ | #‘
kawa-abbreviation ::= XXX

The following abbreviations are expanded at read-time:

datum

means (quote datum).

datum

means (quasiquote datum).

,datum

means (unquote datum).

,@datum

means (unquote-splicing datum).

#’datum

means (syntax datum).

#‘datum

means (quasisyntax datum).

#,datum

means (unsyntax datum). This abbreviation is currently only recognized when nested inside an explicit #‘datum form, because of a conflict with SRFI-10 named constructors.

#,@datum

means (unsyntax-splicing datum).

datum1:datum2

means ($lookup$ datum1 (quasiquote datum2)). See Colon notation.

[expression ...]

means ($bracket-list$ expression ...).

operator[expression ...]

means ($bracket-apply$ operator expression ...).