Class ActionQueryParser
java.lang.Object
org.tweetyproject.commons.Parser<SActionQuerySet,SActionQuery>
org.tweetyproject.action.query.parser.ActionQueryParser
This class implements a parser for action queries in S. The BNF of such queries is given by: (starting symbol is KB)
KB ::== QUERY1 ("\n" QUERY1)*
QUERY1 ::== QUERY ( "requires" REQUIREMENTS )?
QUERY ::== PROPOSITION | QUERY "&&" QUERY | QUERY "||" QUERY | "!" QUERY | "(" QUERY ")" | "+" | "-"
PROPOSITION ::== HOLDSQUERY | ALWAYSQUERY | NECESSARILYQUERY
HOLDSQUERY ::== "holds" "[" STATEFORMULA "]"
ALWAYSQUERY ::== "always" "[" STATEFORMULA "]"
NECESSARILYQUERY ::== "necessarily" "[" STATEFORMULA "]" "after" ACTIONS
ACTIONS ::== ACTION ( ";" ACTION )*
ACTION ::== "{" ACTIONNAME ("," ACTIONNAME)* "}"
REQUIREMENTS ::== REQUIREMENT ("," REQUIREMENT)*
REQUIREMENT ::== (VARIABLENAME "<>" VARIABLENAME | VARIABLENAME "<>" CONSTANTNAME)*
where STATEFORMULA 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.
KB ::== QUERY1 ("\n" QUERY1)*
QUERY1 ::== QUERY ( "requires" REQUIREMENTS )?
QUERY ::== PROPOSITION | QUERY "&&" QUERY | QUERY "||" QUERY | "!" QUERY | "(" QUERY ")" | "+" | "-"
PROPOSITION ::== HOLDSQUERY | ALWAYSQUERY | NECESSARILYQUERY
HOLDSQUERY ::== "holds" "[" STATEFORMULA "]"
ALWAYSQUERY ::== "always" "[" STATEFORMULA "]"
NECESSARILYQUERY ::== "necessarily" "[" STATEFORMULA "]" "after" ACTIONS
ACTIONS ::== ACTION ( ";" ACTION )*
ACTION ::== "{" ACTIONNAME ("," ACTIONNAME)* "}"
REQUIREMENTS ::== REQUIREMENT ("," REQUIREMENT)*
REQUIREMENT ::== (VARIABLENAME "<>" VARIABLENAME | VARIABLENAME "<>" CONSTANTNAME)*
where STATEFORMULA 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, Tim Janus (change constant LogicalSymbols to dynamic)
-
Constructor Summary
ConstructorDescriptionActionQueryParser
(ActionSignature signature) Constructs a new `ActionQueryParser` with the specified action signature. -
Method Summary
Modifier and TypeMethodDescriptionparseBeliefBase
(Reader reader) Parses a belief base from the given reader.parseFormula
(Reader reader) Parses a single formula from the given reader.Methods inherited from class org.tweetyproject.commons.Parser
isNumeric, parseBeliefBase, parseBeliefBaseFromFile, parseFormula, parseFormulaFromFile, parseListOfBeliefBases, parseListOfBeliefBases, parseListOfBeliefBasesFromFile, parseListOfBeliefBasesFromFile
-
Constructor Details
-
ActionQueryParser
Constructs a new `ActionQueryParser` with the specified action signature.- Parameters:
signature
- the action signature used for parsing action queries.
-
-
Method Details
-
parseBeliefBase
Parses a belief base from the given reader. The belief base is expected to contain multiple formulas, separated by newlines, which are parsed into an `SActionQuerySet`.- Specified by:
parseBeliefBase
in classParser<SActionQuerySet,
SActionQuery> - Parameters:
reader
- the reader from which to parse the belief base.- Returns:
- an `SActionQuerySet` representing the parsed belief base.
- Throws:
ParserException
- if an error occurs during parsing.
-
parseFormula
Parses a single formula from the given reader.- Specified by:
parseFormula
in classParser<SActionQuerySet,
SActionQuery> - Parameters:
reader
- the reader from which to parse the formula.- Returns:
- an `SActionQuery` representing the parsed formula.
- Throws:
IOException
- if an I/O error occurs during parsing.ParserException
- if a parsing error occurs.
-