Class CLawParser


  • public class CLawParser
    extends net.sf.tweety.commons.Parser<CActionDescription,​net.sf.tweety.commons.Formula>
    This class implements a parser for causal laws in C. The BNF of such rules is given by: (starting symbol is DESC)

    DESC ::== LAW ("\n" LAW)*
    LAW ::== STATICLAW | DYNAMICLAW
    STATICLAW ::== "caused" FOLFORMULA ("if" FOLFORMULA)? ("requires" REQUIREMENTS)?
    DYNAMICLAW ::== "caused" FOLFORMULA ("if" FOLFORMULA)? "after" FOLFORMULA ("requires" REQUIREMENTS)?
    REQUIREMENTS ::== REQUIREMENT ("," REQUIREMENT)*
    REQUIREMENT ::== (VARIABLENAME "<>" VARIABLENAME | VARIABLENAME "<>" CONSTANTNAME)*
    where FOLFORMULA is an unquantified first-order formula without functors,
    and VARIABLENAME, CONSTANTNAME are sequences of symbols
    from {a,...,z,A,...,Z,0,...,9} with a letter at the beginning.
    Author:
    Sebastian Homann
    • Constructor Detail

      • CLawParser

        public CLawParser​(ActionSignature signature)
        This parser needs a valid action signature to parse causal laws.
        Parameters:
        signature - some signature
    • Method Detail

      • parseBeliefBase

        public CActionDescription parseBeliefBase​(Reader reader)
                                           throws net.sf.tweety.commons.ParserException
        Specified by:
        parseBeliefBase in class net.sf.tweety.commons.Parser<CActionDescription,​net.sf.tweety.commons.Formula>
        Throws:
        net.sf.tweety.commons.ParserException
      • parseFormula

        public net.sf.tweety.commons.Formula parseFormula​(Reader reader)
                                                   throws IOException,
                                                          net.sf.tweety.commons.ParserException
        Specified by:
        parseFormula in class net.sf.tweety.commons.Parser<CActionDescription,​net.sf.tweety.commons.Formula>
        Throws:
        IOException
        net.sf.tweety.commons.ParserException
      • parseFolFormula

        protected net.sf.tweety.logics.fol.syntax.FolFormula parseFolFormula​(String s)
                                                                      throws net.sf.tweety.commons.ParserException,
                                                                             IOException
        Parses a FolFormula from a string using the FolParser class
        Parameters:
        s - a string
        Returns:
        A first order formula
        Throws:
        net.sf.tweety.commons.ParserException - if parsing fails
        IOException - if an IO issue occurs.
      • parseFormula

        public net.sf.tweety.commons.Formula parseFormula​(String s)
                                                   throws net.sf.tweety.commons.ParserException,
                                                          IOException
        Overrides:
        parseFormula in class net.sf.tweety.commons.Parser<CActionDescription,​net.sf.tweety.commons.Formula>
        Throws:
        net.sf.tweety.commons.ParserException
        IOException
      • containedKeywords

        protected Set<String> containedKeywords​(String s)
        Returns the set of forbidden keywords, that are contained in a string. This is used for error recognition in input strings.
        Parameters:
        s - some string
        Returns:
        the set of forbidden keywords