25 lines
513 B
ANTLR
25 lines
513 B
ANTLR
grammar HMKNF;
|
|
|
|
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 (operator = ('|' | '&')) oformula # disjOrConj
|
|
| oformula '->' oformula # imp;
|
|
|
|
katom: patom | natom;
|
|
oatom: patom | fatom;
|
|
patom: IDENTIFIER;
|
|
natom: 'not' IDENTIFIER;
|
|
fatom: '-' IDENTIFIER;
|
|
|
|
IDENTIFIER: [a-z'][A-Za-z0-9']*;
|