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/.