1
2
3
4
5
6 classmap RegExClassMap;
7
8 tokens RegExTokens
9 {
10 (LPAREN, "'('"), (RPAREN, "')'"), (LBRACKET, "'['"), (RBRACKET, "']'"), (LBRACE, "'{'"), (RBRACE, "'}"),
11 (ALT, "'|'"), (STAR, "'*'"), (PLUS, "'+'"), (QUEST, "'?'"), (DOT, "'.'"), (ESCAPE, "escape"), (INVERSE, "'^'"), (MINUS, "'-'"), (CHAR, "character")
12 }
13
14 expressions
15 {
16 decdigit="[0-9]";
17 octaldigit="[0-7]";
18 hexdigit="[0-9a-fA-F]";
19 hex4 = "{hexdigit}{hexdigit}{hexdigit}{hexdigit}";
20 hex8 = "{hex4}{hex4}";
21 escape = "\\((x|X){hexdigit}+|(d|D){decdigit}+|{octaldigit}+|u{hex4}|U{hex8}|(a|b|f|n|r|t|v|.))";
22 }
23
24 lexer RegExLexer
25 {
26 "\(" { return LPAREN; }
27 "\)" { return RPAREN; }
28 "\[" { return LBRACKET; }
29 "\]" { return RBRACKET; }
30 "\{" { return LBRACE; }
31 "\}" { return RBRACE; }
32 "\|" { return ALT; }
33 "\*" { return STAR; }
34 "\+" { return PLUS; }
35 "\?" { return QUEST; }
36 "\." { return DOT; }
37 "{escape}" { return ESCAPE; }
38 "^" { return INVERSE; }
39 "-" { return MINUS; }
40 "[^\x0\r\n{}\\()[\]|*+?.^-]" { return CHAR; }
41 }