-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBibtexLexer.g4
43 lines (26 loc) · 960 Bytes
/
BibtexLexer.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
lexer grammar BibtexLexer;
CURLY_VALUE_START : '=' [ \t\r\n]* '{' -> pushMode(CURLY_VALUE_MODE) ;
AT : '@' ;
COMMA : ',' ;
EQUALS : '=' ;
HASH : '#' ;
OPEN_CURLY : '{' ;
CLOSE_CURLY : '}' ;
OPEN_PAREN : '(' ;
CLOSE_PAREN : ')' ;
STRING : [sS] [tT] [rR] [iI] [nN] [gG] ;
PREAMBLE : [pP] [rR] [eE] [aA] [mM] [bB] [lL] [eE] ;
fragment COMMENT_START: '@' [cC] [oO] [mM] [mM] [eE] [nN] [tT] [ \t\r\n]* ;
COMMENT_START_CURLY: COMMENT_START '{' -> pushMode(CURLY_VALUE_MODE) ;
COMMENT_START_PAREN: COMMENT_START '(' -> pushMode(PAREN_VALUE_MODE) ;
NAME : [0-9a-zA-Z!?$&*+./:;^<>_`|[\]\-]+ ;
STRING_LITERAL : '"' ~["]* '"' ;
WS : [ \t\r\n]+ -> skip ;
mode CURLY_VALUE_MODE;
CURLY_VALUE_OPEN_CURLY : '{' -> pushMode(CURLY_VALUE_MODE) ;
CURLY_VALUE_CLOSE_CURLY : '}' -> popMode ;
CURLY_VALUE : ~[{}]+ ;
mode PAREN_VALUE_MODE;
PAREN_VALUE_OPEN_PAREN : '(' -> pushMode(PAREN_VALUE_MODE) ;
PAREN_VALUE_CLOSE_PAREN : ')' -> popMode ;
PAREN_VALUE : ~[()]+ ;