blob: 765d8c9fa402714def73c11e82e7670ba6eaff86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// This is a sample lexer generated by the ANTLR3 Maven Archetype
// generator. It shows how to use a superclass to implement
// support methods and variables you may use in the lexer actions
// rather than create a messy lexer that has the Java code embedded
// in it.
//
lexer grammar TLexer;
options {
language=Java; // Default
// Tell ANTLR to make the generated lexer class extend the
// the named class, which is where any supporting code and
// variables will be placed.
//
superClass = AbstractTLexer;
}
// What package should the generated source exist in?
//
@header {
package ${package};
}
// This is just a simple lexer that matches the usual suspects
//
KEYSER : 'Keyser' ;
SOZE : 'Soze' ;
ADD : '+' ;
SEMI: ';' ;
ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
;
INT : '0'..'9'+
;
COMMENT
: '//' ~('\n'|'\r')* '\r'? '\n' {skip();}
| '/*' ( options {greedy=false;} : . )* '*/' {skip();}
;
WS : ( ' '
| '\t'
| '\r'
| '\n'
) {skip();}
;
STRING
: '"' ( ESC_SEQ | ~('\\'|'"') )* '"'
;
fragment
HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;
fragment
ESC_SEQ
: '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
| UNICODE_ESC
| OCTAL_ESC
;
fragment
OCTAL_ESC
: '\\' ('0'..'3') ('0'..'7') ('0'..'7')
| '\\' ('0'..'7') ('0'..'7')
| '\\' ('0'..'7')
;
fragment
UNICODE_ESC
: '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
;
|