26 lines
566 B
Plaintext
26 lines
566 B
Plaintext
|
grammar HMKNF;
|
||
|
|
||
|
COMMENT: '#' .*? '\n' -> skip;
|
||
|
WS: [ \n\t\r]+ -> skip;
|
||
|
|
||
|
kb: (lrule | orule)*;
|
||
|
|
||
|
lrule: ((head body) | head | body) '.';
|
||
|
head: IDENTIFIER (',' IDENTIFIER)*;
|
||
|
body: ':-' (katom (',' katom)*)?;
|
||
|
|
||
|
orule: oformula '.';
|
||
|
oformula:
|
||
|
'(' oformula ')' # parenth
|
||
|
| oatom # literal
|
||
|
| '-' oformula # negation
|
||
|
| oformula (operator = ('|' | '&')) oformula # disjOrConj
|
||
|
| <assoc = right> oformula '->' oformula # imp;
|
||
|
|
||
|
katom: patom | natom;
|
||
|
oatom: IDENTIFIER;
|
||
|
patom: IDENTIFIER;
|
||
|
natom: 'not' IDENTIFIER;
|
||
|
|
||
|
IDENTIFIER: [a-z'][A-Za-z0-9'_]*;
|