Chapter 3: Lexical Analysis

Examples

. Identifier

letter a| b| .|z| A| B| .| Z

digit 0| 1| .| 9

identifier letter(letter|digit)*

. Unsigned number in Pascal

digit 0| 1| . |9

digits digit +

fraction ' . ' digits | ε

exponent (E ( ' + ' | ' - ' |ε ) digits) | ε

number digits fraction exponent

Here are some more examples:

The set of Identifiers is the set of strings of letters and digits beginning with a letter. Here is a regular definition for this set:

letter a| b| .|z| A| B| .| Z i.e., any lower case or upper case alphabet

digit 0| 1| .| 9 i.e., a single digit

identifier letter(letter | digit)* i.e., a string of letters and digits beginning with a letter

Unsigned numbers in Pascal are strings such as 5280, 39.37, 6.336E4, 1.894E-4. Here is a regular definition for this set:

digit 0| 1| .|9 i.e., a single digit

digits digit + i.e., a string of one or more digits

fraction ' . ' digits | ε i.e., an empty string or a decimal symbol followed by one or more digits

exponent (E ( ' + ' | ' - ' | ε ) digits) | ε

number digits fraction exponent