public class FolParser extends Parser<FolBeliefSet>
Modifier and Type | Field and Description |
---|---|
private FolSignature |
signature
Keeps track of the signature.
|
private java.util.Map<java.lang.String,Variable> |
variables
Keeps track of variables defined.
|
Constructor and Description |
---|
FolParser() |
Modifier and Type | Method and Description |
---|---|
private void |
consumeToken(java.util.Stack<java.lang.Object> stack,
int c)
This method reads one token from the given reader and appropriately
constructs a fol formula from the stream.
|
FolSignature |
getSignature()
Returns the signature of this parser.
|
java.util.Map<java.lang.String,Variable> |
getVariables() |
private FolFormula |
parseAtomic(java.util.List<java.lang.Object> l)
Parses a simple formula as a list of String tokens or formulas into a fol formula.
|
FolBeliefSet |
parseBeliefBase(java.io.Reader reader)
Parses the given reader into a belief base of the given type.
|
private FolFormula |
parseConjunction(java.util.List<java.lang.Object> l)
Parses a simple conjunction as a list of String tokens or formulas into a fol formula.
|
private FolFormula |
parseDisjunction(java.util.List<java.lang.Object> l)
Parses a disjunction as a list of String tokens or formulas into a fol formula.
|
private FolFormula |
parseEquivalence(java.util.List<java.lang.Object> l)
Parses an equivalence as a list of String tokens or formulas into a fol formula.
|
Formula |
parseFormula(java.io.Reader reader)
Parses the given reader into a formula of the given type.
|
private FolFormula |
parseImplication(java.util.List<java.lang.Object> l)
Parses an implication as a list of String tokens or formulas into a fol formula.
|
private FolFormula |
parseNegation(java.util.List<java.lang.Object> l)
Parses a simple formula as a list of String tokens or formulas into a fol formula.
|
private FolFormula |
parseQuantification(java.util.List<java.lang.Object> l)
Parses a quantified formula as a list of String tokens or formulas.
|
FolSignature |
parseSignature(java.lang.String s)
This function parses only the sorts declaration and type declaration parts
of a belief base.
|
void |
parseSortDeclaration(java.lang.String s,
FolSignature sig)
Parses a sort declaration of the form "SORTNAME "=" "{" (CONSTANTNAME ("," CONSTANTNAME)*)? "}""
and modifies the given signature accordingly.
|
private java.util.List<Term<?>> |
parseTermlist(java.util.List<java.lang.Object> l)
Parses a term list as a list of String tokens or terms into a list of terms.
|
void |
parseTypeDeclaration(java.lang.String s,
FolSignature sig)
Parses a predicate declaration of the form "type" "(" PREDICATENAME "(" (SORTNAME ("," SORTNAME)*)? ")" ")"
or a functor declaration of the form "type" "(" SORTNAME "=" FUNCTORNAME "(" (SORTNAME ("," SORTNAME)*)? ")" ")"
and modifies the given signature accordingly.
|
void |
setSignature(FolSignature signature)
Sets the signature for this parser.
|
void |
setVariables(java.util.Map<java.lang.String,Variable> variables) |
isNumeric, parseBeliefBase, parseBeliefBaseFromFile, parseFormula, parseFormulaFromFile
private FolSignature signature
private java.util.Map<java.lang.String,Variable> variables
public FolBeliefSet parseBeliefBase(java.io.Reader reader) throws java.io.IOException, ParserException
Parser
parseBeliefBase
in class Parser<FolBeliefSet>
reader
- a readerjava.io.IOException
ParserException
public void parseSortDeclaration(java.lang.String s, FolSignature sig) throws ParserException
s
- a stringsig
- a signatureParserException
public void parseTypeDeclaration(java.lang.String s, FolSignature sig) throws ParserException
s
- a stringsig
- a signatureParserException
public Formula parseFormula(java.io.Reader reader) throws java.io.IOException, ParserException
Parser
parseFormula
in class Parser<FolBeliefSet>
reader
- a readerjava.io.IOException
ParserException
private void consumeToken(java.util.Stack<java.lang.Object> stack, int c) throws ParserException
stack
- a stack used for monitoring the read items.c
- a token from a stream.ParserException
- in case of parser errors.private java.util.List<Term<?>> parseTermlist(java.util.List<java.lang.Object> l) throws ParserException
l
- a list of objects, either String tokens or objects of type List.ParserException
- if the list could not be parsed.private FolFormula parseQuantification(java.util.List<java.lang.Object> l) throws ParserException
l
- a list objects, either String tokens or objects of type FolFormula.ParserException
- if the list could not be parsed.private FolFormula parseEquivalence(java.util.List<java.lang.Object> l)
l
- a list objects, either String tokens or objects of type FolFormula.ParserException
- if the list could not be parsed.private FolFormula parseImplication(java.util.List<java.lang.Object> l)
l
- a list objects, either String tokens or objects of type FolFormula.ParserException
- if the list could not be parsed.private FolFormula parseDisjunction(java.util.List<java.lang.Object> l)
l
- a list objects, either String tokens or objects of type FolFormula.ParserException
- if the list could not be parsed.private FolFormula parseConjunction(java.util.List<java.lang.Object> l) throws ParserException
l
- a list objects, either String tokens or objects of type FolFormula.ParserException
- if the list could not be parsed.private FolFormula parseNegation(java.util.List<java.lang.Object> l) throws ParserException
l
- a list objects, either String tokens or objects of type FolFormula.ParserException
- if the list could not be parsed.private FolFormula parseAtomic(java.util.List<java.lang.Object> l) throws ParserException
l
- a list objects, either String tokens or objects of type folFormula.ParserException
public FolSignature parseSignature(java.lang.String s)
public void setSignature(FolSignature signature)
signature
- a fol signature.public FolSignature getSignature()
public java.util.Map<java.lang.String,Variable> getVariables()
public void setVariables(java.util.Map<java.lang.String,Variable> variables)