-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArgumentScript.g4
45 lines (37 loc) · 1.23 KB
/
ArgumentScript.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
grammar ArgumentScript;
/*
* Parser Rules
*/
file : definition NEWLINE* argument NEWLINE* assertion NEWLINE*;
definition : DEFHEADER NEWLINE+ (TERM NEWLINE)* DEFFOOTER NEWLINE+;
argument : ARGHEADER NEWLINE+ (proposition NEWLINE)* ARGFOOTER NEWLINE+;
assertion : ASRTHEADER NEWLINE+ (OPERATOR? TERM NEWLINE)* ASRTFOOTER NEWLINE*;
proposition : TERM
| proposition OPERATOR proposition?
| '(' proposition ')'
| (OPERATOR proposition);
/*
* Lexer Rules
*/
TERM : '"' [a-zA-Z ]+ '"';
DEFHEADER : '#DEF';
DEFFOOTER : '#END_DEF';
ARGHEADER : '#ARG';
ARGFOOTER : '#END_ARG';
ASRTHEADER : '#ASRT';
ASRTFOOTER : '#END_ASRT';
NEWLINE : ('\r'? '\n' | '\r');
OPERATOR : ('~' | '&' | '|' | '->');
WS : (' '|'\t')+ { skip(); };
fragment POUND : '#';
fragment UNDERSCORE : '_';
fragment D : 'D';
fragment E : 'E';
fragment F : 'F';
fragment A : 'A';
fragment R : 'R';
fragment G : 'G';
fragment S : 'S';
fragment T : 'T';
fragment N : 'N';
fragment DQUOTE : '"';