**Table of Contents**

Regular expressions are the patterns that Alex uses to match tokens in the input stream.

regexp := rexp2 { '|' rexp2 } rexp2 := rexp1 { rexp1 } rexp1 := rexp0 [ '*' | '+' | '?' | repeat ] rexp0 := set | @rmac | @string | '(' [ regexp ] ')' repeat := '{' $digit '}' | '{' $digit ',' '}' | '{' $digit ',' $digit '}'

The syntax of regular expressions is fairly standard, the
only difference from normal lex-style regular expressions being
that we allow the sequence `()`

to denote the
regular expression that matches the empty string.

Spaces are ignored in a regular expression, so feel free
to space out your regular expression as much as you like, even
split it over multiple lines and include comments. Literal
whitespace can be included by surrounding it with quotes
`" "`

, or by escaping each whitespace character
with `\`

.

`set`

Matches any of the characters in

. See Section 4.2, “Syntax of character sets” for the syntax of sets.`set`

`@foo`

Expands to the definition of the appropriate regular expression macro.

`"..."`

Matches the sequence of characters in the string, in that order.

*`r`

Matches zero or more occurences of

.`r`

+`r`

Matches one or more occurences of

.`r`

?`r`

Matches zero or one occurences of

.`r`

{`r`

}`n`

Matches

occurrences of`n`

.`r`

{`r`

,}`n`

Matches

or more occurrences of`n`

.`r`

{`r`

,`n`

}`m`

Matches between

and`n`

(inclusive) occurrences of`m`

.`r`