-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSuokif.g4
46 lines (33 loc) · 1.22 KB
/
Suokif.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
grammar Suokif ;
file : (sentence | comment)+ EOF ;
sentence : (relsent | logsent | quantsent | variable) ;
quantsent : (forall | exists) ;
exists : '(' 'exists' '(' variable+ ')' sentence ')' ;
forall : '(' 'forall' '(' variable+ ')' sentence ')' ;
logsent : (notsent | andsent | orsent | implies | iff | eqsent) ;
iff : '(' '<=>' sentence sentence ')' ;
implies : '(' '=>' sentence sentence ')' ;
andsent : '(' 'and' sentence sentence+ ')' ;
orsent : '(' 'or' sentence sentence+ ')' ;
notsent : '(' 'not' sentence ')' ;
eqsent : '(' 'equal' term term ')' ;
funterm : '(' FUNWORD argument+ ')' ;
FUNWORD : LETTER WORDCHAR* 'Fn';
relsent : ('(' IDENTIFIER argument+ ')') | ('(' variable argument+ ')') ;
argument : (sentence | term) ;
term : (funterm | variable | string | number | FUNWORD | IDENTIFIER ) ;
IDENTIFIER : LETTER WORDCHAR* ;
NUMBER : '-'? DIGIT+ ([.,] DIGIT+)? EXPONENT? ;
number : NUMBER ;
WORDCHAR : (LETTER | DIGIT | '-' | '_') ;
STRING : '"' ~('"')+ '"' ;
string: STRING ;
COMMENT : ';' ~( '\r' | '\n' )* ;
comment : COMMENT ;
REGVAR : '?' [a-zA-Z0-9]+ ;
ROWVAR : '@' [a-zA-Z0-9]+ ;
variable : (REGVAR | ROWVAR) ;
EXPONENT : 'e' '-'? DIGIT+ ;
LETTER : [A-Za-z] ;
DIGIT : [0-9] ;
WHITESPACE : [ \n\t\r]+ -> skip ;