Package net.sf.tweety.logics.ml.parser
Class MlParser
- java.lang.Object
-
- net.sf.tweety.commons.Parser<MlBeliefSet,net.sf.tweety.logics.commons.syntax.RelationalFormula>
-
- net.sf.tweety.logics.ml.parser.MlParser
-
public class MlParser extends net.sf.tweety.commons.Parser<MlBeliefSet,net.sf.tweety.logics.commons.syntax.RelationalFormula>
This class implements a parser for modal logic. The BNF for a modal knowledge base is given by (starting symbol is KB)
KB ::== SORTSDEC DECLAR FORMULAS
DECLAR ::== (FUNCTORDEC | PREDDEC)*
SORTSDEC ::== ( SORTNAME "=" "{" (CONSTANTNAME ("," CONSTANTNAME)*)? "}" "\n" )*
PREDDEC ::== "type" "(" PREDICATENAME ("(" SORTNAME ("," SORTNAME)* ")")? ")" "\n"
FUNCTORDEC ::== "type" "(" SORTNAME "=" FUNCTORNAME "(" (SORTNAME ("," SORTNAME)*)? ")" ")" "\n"
FORMULAS ::== ( "\n" FORMULA)*
FORMULA ::== ATOM | "forall" VARIABLENAME ":" "(" FORMULA ")" | "exists" VARIABLENAME ":" "(" FORMULA ")" |
"(" FORMULA ")" | FORMULA "&&" FORMULA | FORMULA "||" FORMULA | "!" FORMULA | "+" | "-" |
FORMULA "=>" FORMULA | FORMULA "<=>" FORMULA | FORMULA "==" FORMULA | FORMULA "/==" FORMULA |
"[]" "(" FORMULA ")" | "<>" "(" FORMULA ")" | FORMULA "^^" FORMULA
ATOM ::== PREDICATENAME ("(" TERM ("," TERM)* ")")?
TERM ::== VARIABLENAME | CONSTANTNAME | FUNCTORNAME "(" (TERM ("," TERM)*)? ")"
where SORTNAME, PREDICATENAME, CONSTANTNAME, and FUNCTORNAME are sequences of
symbols from {a,...,z,A,...,Z,0,...,9} with a letter at the beginning and VARIABLENAME
is a sequence of symbols from {a,...,z,A,...,Z,0,...,9} with an uppercase letter at the beginning.
Note: Equality/Inequality predicates ("==" and "/==") can only be parsed if the parser is given a FolSignature
with equality (which is not the case by default).- Author:
- Matthias Thimm, Anna Gessler
-
-
Constructor Summary
Constructors Constructor Description MlParser()
-
Method Summary
Modifier and Type Method Description net.sf.tweety.logics.fol.syntax.FolSignaturegetSignature()Returns the signature of this parser.MlBeliefSetparseBeliefBase(Reader reader)net.sf.tweety.logics.commons.syntax.RelationalFormulaparseFormula(Reader reader)voidsetSignature(net.sf.tweety.logics.fol.syntax.FolSignature signature)Sets the signature for this parser.
-
-
-
Method Detail
-
parseBeliefBase
public MlBeliefSet parseBeliefBase(Reader reader) throws IOException, net.sf.tweety.commons.ParserException
- Specified by:
parseBeliefBasein classnet.sf.tweety.commons.Parser<MlBeliefSet,net.sf.tweety.logics.commons.syntax.RelationalFormula>- Throws:
IOExceptionnet.sf.tweety.commons.ParserException
-
parseFormula
public net.sf.tweety.logics.commons.syntax.RelationalFormula parseFormula(Reader reader) throws IOException, net.sf.tweety.commons.ParserException
- Specified by:
parseFormulain classnet.sf.tweety.commons.Parser<MlBeliefSet,net.sf.tweety.logics.commons.syntax.RelationalFormula>- Throws:
IOExceptionnet.sf.tweety.commons.ParserException
-
setSignature
public void setSignature(net.sf.tweety.logics.fol.syntax.FolSignature signature)
Sets the signature for this parser.- Parameters:
signature- a fol signature.
-
getSignature
public net.sf.tweety.logics.fol.syntax.FolSignature getSignature()
Returns the signature of this parser.- Returns:
- the signature of this parser.
-
-