;;;;;; Pseudo-BNF description of Scheme's syntax -*- Text -*- ;;; Taylor Campbell wrote this text; he places it in the public domain. ;;; [TRC 2009-10-19: Updated for the first time since 2005-09-09 to ;;; omit a duplicate "~" in the production rule.] ;;; This file describes the syntax of Scheme at two different levels, ;;; and it partitions the core of Scheme's syntax from standard macros ;;; such as COND or LET. The first level of the syntax is the level of ;;; S-expression representations of Scheme objects. Note that, since ;;; this is only BNF, it does _not_ provide a useful mapping from text ;;; to the Scheme objects represented by that text; it only describes ;;; the syntax of S-expressions. The second level described here is ;;; Scheme's syntax itself; note that the description is in terms of ;;; Scheme objects, _not_ text. This applies similarly to the section ;;; on standard macros. (Note that there is, again, no mapping from ;;; the syntax of standard macros to the transformed expressions in a ;;; more primitive Scheme.) ;;; -------------------- ;;; S-expression syntax ---> * * ;;; is left unspecified. It is expected to at ;;; least contain the ASCII characters space, carriage return, form ;;; feed/page, line feed, & tab. ---> | ";" * ---> | "'" | "`" | "," | ",@" ---> | | | | ;;; must be terminated by a delimiter as listed here. The ;;; nonterminal is not actually used, however, since it ;;; would consume. ---> | "(" | ")" | | ";" ---> * | ---> | "!" | "$" | "%" | "&" | "*" | "/" | ":" | "<" | "=" | ">" | "?" | "^" | "_" | "~" ---> | | "+" | "-" | "." | "@" ---> "+" | "-" | "..." ;;; The number-related rules should all be replicated for each R in {2, ;;; 8, 10, 16}. is the only decimal rule; decimal points ;;; may not be written with other radices. is a digit valid ;;; with a radix of R. Radix 2 has 0 & 1; radix 8, 0-7; radix 10, 0-9; ;;; & radix 16, 0-9 & A-F. ---> "#i" | "#e" | ---> "#x" | "#d" | "#o" | "#b" | ---> | "@" | "+" "i" | "-" "i" | "+i" | "-i" | "+" "i" | "-" "i" | "+i" | "-i" ---> ---> | "/" | ---> + "#"* ---> | "#"* ---> "." + | + "." * | + "#"+ "." ---> | "+" | "-" ---> | + ---> "e" | "s" | "f" | "d" | "l" ---> "(" * ---> | ---> ")" ---> "." * ---> * | * "#;" * ---> * ---> | "\\" | "\" ---> ---> "#" ---> "t" | "f" ; Boolean | "\" ; Character | "(" * ; Vector | "x" ; Hexadecimal | "d" ; Decimal | "o" ; Octal | "b" ; Binary | "i" ; Inexact | "e" ; Exact | ";" ; S-expression comment ---> | ---> "space" | "newline" ; Case-insensitive here ;;; -------------------- ;;; Scheme's syntax ;;; is used in this section to denote any Scheme object, ;;; usually only those that can be read with READ (i.e. those that have ;;; external representations that could be accepted by the above ;;; grammar for S-expressions). ;;; At the top level, a Scheme program consists of a sequence of ;;; terms. ---> | | | ---> (BEGIN *) ---> (DEFINE ) | (DEFINE ( . ) . ) ---> (DEFINE-SYNTAX ) ;;; Syntax transformers ---> (SYNTAX-RULES (*) *) ---> (