Class CParser
java.lang.Object
org.tweetyproject.commons.Parser<CActionDescription,Formula>
org.tweetyproject.action.description.parser.CParser
This class implements a parser for an Action Description in the
Action Description Language C from [Gelfond, Michael and Lifschitz, Vladimir:
Action Languages. ETAI: Electronic Transactions on AI, 1998.]
The BNF is given by: (starting symbol is DESC)
DESC ::== ":- signature" "\n" SIGNATURE "\n" ":- laws" "\n" LAWS
where SIGNATURE is parsed by CSignatureParser and LAWS is parsed by CLawParser.
DESC ::== ":- signature" "\n" SIGNATURE "\n" ":- laws" "\n" LAWS
where SIGNATURE is parsed by CSignatureParser and LAWS is parsed by CLawParser.
- Author:
- Sebastian Homann
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the signature of the action.parseBeliefBase
(Reader reader) Parses a belief base from the provided reader.parseFormula
(Reader reader) Parses a formula from the given reader.parseFormula
(String formula) Parses the given formula string and returns the corresponding Formula object.void
setSignature
(ActionSignature signature) Sets the action signature for this parser.Methods inherited from class org.tweetyproject.commons.Parser
isNumeric, parseBeliefBase, parseBeliefBaseFromFile, parseFormulaFromFile, parseListOfBeliefBases, parseListOfBeliefBases, parseListOfBeliefBasesFromFile, parseListOfBeliefBasesFromFile
-
Constructor Details
-
CParser
public CParser()
-
-
Method Details
-
parseBeliefBase
Parses a belief base from the provided reader. The method reads from the reader and separates formulas by "\n". It follows a state-based approach where: - State 0 is for initialization - State 1 is for reading the signature - State 2 is for reading the lawbase- Specified by:
parseBeliefBase
in classParser<CActionDescription,
Formula> - Parameters:
reader
- the Reader object from which the belief base is read- Returns:
- a CActionDescription object representing the parsed belief base
- Throws:
IOException
- if an I/O error occursParserException
- if a parsing error occurs
-
parseFormula
Parses a formula from the given reader.- Specified by:
parseFormula
in classParser<CActionDescription,
Formula> - Parameters:
reader
- the reader to read the formula from- Returns:
- the parsed formula
- Throws:
IOException
- if an I/O error occurs while reading from the readerParserException
- if the formula cannot be parsed
-
parseFormula
Parses the given formula string and returns the corresponding Formula object.- Overrides:
parseFormula
in classParser<CActionDescription,
Formula> - Parameters:
formula
- the formula string to be parsed- Returns:
- the parsed Formula object
- Throws:
ParserException
- if there is an error during parsingIOException
- if there is an error reading the formula string
-
setSignature
Sets the action signature for this parser.- Parameters:
signature
- the action signature to be set
-
getSignature
Returns the signature of the action.- Returns:
- the signature of the action
-