## Regular Definitions

A regular definition gives names to certain regular expressions and uses those names in other regular expressions.

Here is a regular definition for the set of Pascal identifiers that is define as the set of strings of letter and digits beginning with a letters.

letter A | B | . . . | Z | a | b | . . . | z
digit  0 | 1 | 2 | . . . | 9
id  letter (letter | digit)*

The regular expression id is the pattern for the Pascal identifier token and defines letter and digit.
Where letter is a regular expression for the set of all upper-case and lower case letters in the alphabet and digit is the regular for the set of all decimal digits.

The pattern for the Pascal unsigned token can be specified as follows:

digit 0 | 1 | 2 | . . . | 9
digit digit digit*

Optimal-fraction     → . digits | ε
Optimal-exponent  (E (+ | - | ) digits) | ε
num  digits optimal-fraction optimal-exponent.

This regular definition says that

• An optimal-fraction is either a decimal point followed by one or more digits or it is missing (i.e., an empty string).
• An optimal-exponent is either an empty string or it is the letter E followed by an ' optimal + or - sign, followed by one or more digits.

### Notational Shorthand

The unary postfix operator + means "one of more instances of "

(r)+ = rr*

The unary postfix operator? means "zero or one instance of"

r? = (r | ε)

Using these shorthand notation, Pascal unsigned number token can be written as:

digit   0 | 1 | 2 | . . . | 9
digits digit+
optimal-fraction (. digits)?
optimal-exponent  (E (+ | -)?digits)?
num digits optimal-fraction optimal-exponent