-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRc2Lexer.g4
More file actions
40 lines (28 loc) · 782 Bytes
/
Rc2Lexer.g4
File metadata and controls
40 lines (28 loc) · 782 Bytes
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
lexer grammar Rc2Lexer;
@lexer::declarations {
#include "../LexerHelpers.hpp"
}
@lexer::definitions {
#include "../LexerHelpers.cpp"
}
CODE_START: { isCodeStartBackticks()}? '```' ;
CODE_ARG: '{r' ~'}'* '}' -> pushMode(IN_CODE);
EQ_START: { isEQStart() }? '$$' -> pushMode(IN_EQ);
IEQ_START: '$' { isInlineEqStart() }? -> pushMode(IN_IN_EQ);
IC_START: '`r ' -> pushMode(IN_ICODE);
MDOWN: .+?;
mode IN_ICODE;
IC_END: '`' -> popMode;
IC_CODE: ~[`]+;
mode IN_EQ;
EQ_END: '$$' -> popMode;
EQ_CODE: ('$' ~'$' | ~'$')+;
mode IN_IN_EQ;
IEQ_CODE: ( ~'$' | [ \t\n] '$')+;
IEQ_END: '$' -> popMode;
mode IN_CODE;
CODE_END: {isCodeEndBackticks()}? '```' ' '* (NL | EOF) -> popMode;
NL: '\r'? '\n';
CODE: NL ANY+;
NOT_BACKTICK: ~('`');
fragment ANY: '`'? '`'? NOT_BACKTICK .*?;