Next: , Up: silex syntax   [Index]


53.5.1 Macro definitions part

The first part of a specification contains zero or more macro definitions. A definition consists of a name and a regular expression, separated by white spaces (meaning: horizontal blank characters, vertical blank characters like newlines and comments). It looks better when each definition is written on a separate line.

The syntax for a macro name is that of an R6RS symbol. For example, abcd, +, ..., Digit and digit are all valid macro names; the last two being different. It is an error to write two macro definitions with the same name, unless they have equal regexp specification.

The defined macros can be referenced in regular expressions using the syntax {name}. The scope of a macro definition includes the remaining definitions and the rules part; it is analogous to let* in Scheme, where the macro definitions correspond to the bindings and the rules part corresponds to the body.

We end the macro definitions part with %%.