Next: , Up: scheme entry   [Index]


3.6.1 Syntax entries

If category is “Syntax”, the entry describes a special syntactic construct, and the template gives the syntax of the forms of the construct. The template is written in a notation similar to a right–hand side of the BNF rules in chapter “Lexical syntax and datum syntax”, and describes the set of forms equivalent to the forms matching the template as syntactic data. Some “Syntax” entries carry a suffix (expand), specifying that the syntactic keyword of the construct is exported with level 1. Otherwise, the syntactic keyword is exported with level 0; scheme library import export.

Components of the form described by a template are designated by syntactic variables, which are written using angle brackets, for example, ?expression, ?variable. Case is insignificant in syntactic variables. Syntactic variables stand for other forms, or sequences of them. A syntactic variable may refer to a non–terminal in the grammar for syntactic data, in which case only forms matching that non–terminal are permissible in that position. For example, ?identifier stands for a form which must be an identifier. Also, ?expression stands for any form which is a syntactically valid expression. Other non–terminals that are used in templates are defined as part of the specification.

The notation

?thing1 ...

indicates zero or more occurrences of a ?thing, and

?thing1 ?thing2 ...

indicates one or more occurrences of a ?thing.

It is the programmer’s responsibility to ensure that each component of a form has the shape specified by a template. Descriptions of syntax may express other restrictions on the components of a form. Typically, such a restriction is formulated as a phrase of the form “?x must be a …”. Again, these specify the programmer’s responsibility. It is the implementation’s responsibility to check that these restrictions are satisfied, as long as the macro transformers involved in expanding the form terminate. If the implementation detects that a component does not meet the restriction, an exception with condition type &syntax is raised.


Next: , Up: scheme entry   [Index]