Class ActionSignatureParser
- java.lang.Object
-
- net.sf.tweety.action.signature.parser.ActionSignatureParser
-
public class ActionSignatureParser extends java.lang.ObjectThis 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
-
-
Field Summary
Fields Modifier and Type Field Description private ActionSignaturesignatureResulting signature.
-
Constructor Summary
Constructors Constructor Description ActionSignatureParser()
-
Method Summary
Modifier and Type Method Description ActionSignatureparseSignature(java.io.Reader reader)Parses the given reader into a signature of the given type.ActionSignatureparseSignature(java.lang.String text)Parses the given text into a signature of the given type.ActionSignatureparseSignatureFromFile(java.lang.String filename)Parses the file of the given filename into a signature.protected voidparseSortDeclaration(java.lang.String s)Parses a sort declaration of the form "SORTNAME "=" "{" (CONSTANTNAME ("," CONSTANTNAME)*)? "}"" and adds it to the signature.protected voidparseTypeDeclaration(java.lang.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.
-
-
-
Field Detail
-
signature
private ActionSignature signature
Resulting signature.
-
-
Method Detail
-
parseSignatureFromFile
public ActionSignature parseSignatureFromFile(java.lang.String filename) throws java.io.FileNotFoundException, java.io.IOException, ParserException
Parses the file of the given filename into a signature.- Parameters:
filename- the name of a file- Returns:
- a formula
- Throws:
java.io.FileNotFoundException- if the file is not foundjava.io.IOException- if IO failsParserException- some parsing exceptions may be added here.
-
parseSignature
public ActionSignature parseSignature(java.lang.String text) throws java.io.IOException, ParserException
Parses the given text into a signature of the given type.- Parameters:
text- a string- Returns:
- a formula
- Throws:
java.io.IOException- if IO failsParserException- some parsing exceptions may be added here.
-
parseSignature
public ActionSignature parseSignature(java.io.Reader reader) throws java.io.IOException, ParserException
Parses the given reader into a signature of the given type.- Parameters:
reader- a reader- Returns:
- a formula
- Throws:
java.io.IOException- if IO failsParserException- some parsing exceptions may be added here.
-
parseSortDeclaration
protected void parseSortDeclaration(java.lang.String s) throws ParserExceptionParses a sort declaration of the form "SORTNAME "=" "{" (CONSTANTNAME ("," CONSTANTNAME)*)? "}"" and adds it to the signature.- Parameters:
s- a string- Throws:
ParserException- if parsing fails
-
parseTypeDeclaration
protected void parseTypeDeclaration(java.lang.String s) throws ParserExceptionParses 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:
ParserException- if parsing fails
-
-