next up previous contents index
Next: Lexeme class Up: Lexer Specification Previous: Regular expressions

Lexeme

Lexemes are defined using the lexeme declaration in Prop. Its syntax is

Lexeme_Decl ::=lexeme Lexeme_Eq  - ¼ - Lexeme_Eq ;
Lexeme_Eq ::=Id = Regexp

For example, the following lexeme definition is used in the Prop translator to define the lexical structure of common lexical items.

lexeme digits      = /[0-9]+/
     | sign        = /[\+\-]/
     | integer     = /{digits}/
     | exponent    = /[eE]{sign}?{digits}/
     | mantissa    = /({digits}\.{digits}?|\.{digits})/
     | real        = /{mantissa}{exponent}?/
     | string      = /"([^\\"\n]|\\.)*"/
     | character   = /'([^\\'\n]|\\.[0-9a-f]*)'/
     | regexp      = /\/([^\/\n*]|\\.)([^\/\n]|\\.)*\//
     ;

Note that regular expression literals are written between slashes: /re/.



Allen Leung
Mon Apr 7 14:33:55 EDT 1997