Contents    Page-10    Prev    Next    Page+10    Index   

Comments on Sample lex[slide by John Werth.]

Manifest Constants: these definitions are surrounded by %{ ... %} and will be copied verbatim into the generated program.

Regular Definitions: these are names followed by a regular expression. For example, delim is one of the characters blank, tab, or newline.

Note that if a string is a name then it is surrounded by braces (as delim is in the definition of ws) so that it will not be interpreted as a set of characters.

[A-Z] is the set of characters from A to Z.

Parentheses are meta-symbols used to group. | is a meta-symbol for union. ? is a meta-symbol for 0 or more occurrences. - is a meta-symbol for range.

\ is an escape which allows a meta-symbol to be used as a normal character. "" has the same effect.