-
Notifications
You must be signed in to change notification settings - Fork 1
/
ShortestCobolLexer.g4
59 lines (53 loc) · 1.36 KB
/
ShortestCobolLexer.g4
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
lexer grammar ShortestCobolLexer;
/* lexer rules defined with uppercase */
//language keywords
DISPLAY : D I S P L A Y;
DIVISION : D I V I S I O N;
IDENTIFICATION : I D E N T I F I C A T I O N;
PROCEDURE : P R O C E D U R E;
PROGRAM_ID : P R O G R A M MINUSCHAR I D;
// literals
IDENTIFIER : ([a-zA-Z0-9]+ [-_a-zA-Z0-9]*);
INT : (PLUSCHAR | MINUSCHAR)? [0-9]+;
NUMBER : DIGIT+ ([.,] DIGIT+)?;
WORD : (LOWERCASE | UPPERCASE | '_')+ ;
//symbols
DOT_FS : DOT ('\r' | '\n' | '\f' | '\t' | ' ')+ | DOT EOF;
DOT : '.';
DOUBLEQUOTE : '"';
MINUSCHAR : '-';
PLUSCHAR : '+';
// Define whitespace rule
WS : [ \t\f;]+ -> channel(HIDDEN);
//WHITESPACE : (' ' | 't') ;
NEWLINE : '\r'? '\n' -> channel(HIDDEN);
// case insensitive characters
fragment A:('a'|'A');
fragment B:('b'|'B');
fragment C:('c'|'C');
fragment D:('d'|'D');
fragment E:('e'|'E');
fragment F:('f'|'F');
fragment G:('g'|'G');
fragment H:('h'|'H');
fragment I:('i'|'I');
fragment J:('j'|'J');
fragment K:('k'|'K');
fragment L:('l'|'L');
fragment M:('m'|'M');
fragment N:('n'|'N');
fragment O:('o'|'O');
fragment P:('p'|'P');
fragment Q:('q'|'Q');
fragment R:('r'|'R');
fragment S:('s'|'S');
fragment T:('t'|'T');
fragment U:('u'|'U');
fragment V:('v'|'V');
fragment W:('w'|'W');
fragment X:('x'|'X');
fragment Y:('y'|'Y');
fragment Z:('z'|'Z');
fragment LOWERCASE : [a-z] ;
fragment UPPERCASE : [A-Z] ;
fragment DIGIT : [0-9] ;