Class ActionSignatureParser
- java.lang.Object
-
- net.sf.tweety.action.signature.parser.ActionSignatureParser
-
public class ActionSignatureParser extends Object
This class implements a parser for signatures of action descriptions. The BNF for such signatures is given by: (starting symbol is SIG)
SIG ::== (SORTSDEC | DECLAR)*
SORTSDEC ::== ( SORTNAME "=" "{" (CONSTANTNAME ("," CONSTANTNAME)*)? "}" "\n" )*
DECLAR ::== (ACTIONDEC | FLUENTDEC)*
ACTIONDEC ::== "action" "(" ACTIONNAME ("(" SORTNAME ("," SORTNAME)* ")")? ")" "\n"
FLUENTDEC ::== "fluent" "(" FLUENTNAME ("(" SORTNAME ("," SORTNAME)* ")")? ")" "\n"
where SORTNAME, ACTIONNAME, FLUENTNAME, CONSTANTNAME are sequences of
symbols from {a,...,z,A,...,Z,0,...,9} with a letter at the beginning.- Author:
- Sebastian Homann
-
-
Constructor Summary
Constructors Constructor Description ActionSignatureParser()
-
Method Summary
Modifier and Type Method Description ActionSignatureparseSignature(Reader reader)Parses the given reader into a signature of the given type.ActionSignatureparseSignature(String text)Parses the given text into a signature of the given type.ActionSignatureparseSignatureFromFile(String filename)Parses the file of the given filename into a signature.protected voidparseSortDeclaration(String s)Parses a sort declaration of the form "SORTNAME "=" "{" (CONSTANTNAME ("," CONSTANTNAME)*)? "}"" and adds it to the signature.protected voidparseTypeDeclaration(String s)Parses an action declaration of the form "action" "(" ACTIONNAME ("(" SORTNAME ("," SORTNAME)* ")")? ")" or a fluent declaration of the form "fluent" "(" FLUENTNAME ("(" SORTNAME ("," SORTNAME)* ")")? ")" and adds them to the signature.
-
-
-
Method Detail
-
parseSignatureFromFile
public ActionSignature parseSignatureFromFile(String filename) throws FileNotFoundException, IOException, net.sf.tweety.commons.ParserException
Parses the file of the given filename into a signature.- Parameters:
filename- the name of a file- Returns:
- a formula
- Throws:
FileNotFoundException- if the file is not foundIOException- if IO failsnet.sf.tweety.commons.ParserException- some parsing exceptions may be added here.
-
parseSignature
public ActionSignature parseSignature(String text) throws IOException, net.sf.tweety.commons.ParserException
Parses the given text into a signature of the given type.- Parameters:
text- a string- Returns:
- a formula
- Throws:
IOException- if IO failsnet.sf.tweety.commons.ParserException- some parsing exceptions may be added here.
-
parseSignature
public ActionSignature parseSignature(Reader reader) throws IOException, net.sf.tweety.commons.ParserException
Parses the given reader into a signature of the given type.- Parameters:
reader- a reader- Returns:
- a formula
- Throws:
IOException- if IO failsnet.sf.tweety.commons.ParserException- some parsing exceptions may be added here.
-
parseSortDeclaration
protected void parseSortDeclaration(String s) throws net.sf.tweety.commons.ParserException
Parses a sort declaration of the form "SORTNAME "=" "{" (CONSTANTNAME ("," CONSTANTNAME)*)? "}"" and adds it to the signature.- Parameters:
s- a string- Throws:
net.sf.tweety.commons.ParserException- if parsing fails
-
parseTypeDeclaration
protected void parseTypeDeclaration(String s) throws net.sf.tweety.commons.ParserException
Parses an action declaration of the form "action" "(" ACTIONNAME ("(" SORTNAME ("," SORTNAME)* ")")? ")" or a fluent declaration of the form "fluent" "(" FLUENTNAME ("(" SORTNAME ("," SORTNAME)* ")")? ")" and adds them to the signature.- Parameters:
s- a string- Throws:
net.sf.tweety.commons.ParserException- if parsing fails
-
-