Package net.sf.tweety.arg.delp.parser
Class DelpParser
- java.lang.Object
-
- net.sf.tweety.commons.Parser<DefeasibleLogicProgram,Formula>
-
- net.sf.tweety.arg.delp.parser.DelpParser
-
- All Implemented Interfaces:
DelpParserConstants
public class DelpParser extends Parser<DefeasibleLogicProgram,Formula> implements DelpParserConstants
This class implements a parser for defeasible logic programs. The BNF for defeasible logic program files is given by (start symbol is THEORY)
THEORY ::== (EXPRESSION)+ EXPRESSION ::== FACT | STRICTRULE | DEFEASIBLERULE FACT ::== LITERAL + "." STRICTRULE ::== LITERAL + "<-" + RULEBODY + "." DEFEASIBLERULE ::== LITERAL + "-<" + RULEBODY + "." RULEBODY ::== LITERAL | LITERAL + "," + RULEBODY LITERAL ::== "~" + ATOM | ATOM ATOM ::== PREDICATE | PREDICATE + "(" + TERMLIST + ")" TERMLIST ::== TERM | TERM + "," + TERMLIST TERM ::== VARIABLE | CONSTANT | QUOTED_STRING PREDICATE is a sequence of symbols from {a,...,z,A,...,Z,0,...,9,_,-} with a letter at the beginning. VARIABLE is a sequence of symbols from {a,...,z,A,...,Z,0,...,9,_,-} with an uppercase letter at the beginning. CONSTANT is a sequence of symbols from {a,...,z,A,...,Z,0,...,9,_,-} with an lowercase letter at the beginning. QUOTED_STRING is all characters between double quotes.
-
-
Field Summary
Fields Modifier and Type Field Description Token
jj_nt
Token
token
DelpParserTokenManager
token_source
-
Fields inherited from interface net.sf.tweety.arg.delp.parser.DelpParserConstants
DEFAULT, EOF, NAME, QUOTED, tokenImage
-
-
Constructor Summary
Constructors Constructor Description DelpParser()
DelpParser(java.io.InputStream stream)
DelpParser(java.io.InputStream stream, java.lang.String encoding)
DelpParser(java.io.Reader stream)
DelpParser(DelpParserTokenManager tm)
-
Method Summary
Modifier and Type Method Description FolAtom
Atom(DefeasibleLogicProgram delp, FolSignature signature)
void
disable_tracing()
void
enable_tracing()
void
Expression(DefeasibleLogicProgram delp, FolSignature signature)
FolFormula
Formula(FolSignature signature)
ParseException
generateParseException()
Token
getNextToken()
FolSignature
getSignature()
Token
getToken(int index)
FolFormula
Literal(DefeasibleLogicProgram delp, FolSignature signature)
DefeasibleLogicProgram
parseBeliefBase(java.io.Reader reader)
Parses the given reader into a belief base of the given type.Formula
parseFormula(java.io.Reader reader)
Parses the given reader into a formula of the given type.void
ReInit(java.io.InputStream stream)
void
ReInit(java.io.InputStream stream, java.lang.String encoding)
void
ReInit(java.io.Reader stream)
void
ReInit(DelpParserTokenManager tm)
Term
Term(DefeasibleLogicProgram delp, FolSignature signature)
DefeasibleLogicProgram
Theory(FolSignature signature)
-
Methods inherited from class net.sf.tweety.commons.Parser
isNumeric, parseBeliefBase, parseBeliefBaseFromFile, parseFormula, parseFormulaFromFile
-
-
-
-
Field Detail
-
token_source
public DelpParserTokenManager token_source
-
token
public Token token
-
jj_nt
public Token jj_nt
-
-
Constructor Detail
-
DelpParser
public DelpParser()
-
DelpParser
public DelpParser(java.io.InputStream stream)
-
DelpParser
public DelpParser(java.io.InputStream stream, java.lang.String encoding)
-
DelpParser
public DelpParser(java.io.Reader stream)
-
DelpParser
public DelpParser(DelpParserTokenManager tm)
-
-
Method Detail
-
parseBeliefBase
public DefeasibleLogicProgram parseBeliefBase(java.io.Reader reader) throws ParserException
Description copied from class:Parser
Parses the given reader into a belief base of the given type.- Specified by:
parseBeliefBase
in classParser<DefeasibleLogicProgram,Formula>
- Parameters:
reader
- a reader- Returns:
- a belief base
- Throws:
ParserException
- some parsing exceptions may be added here.
-
parseFormula
public Formula parseFormula(java.io.Reader reader) throws ParserException
Description copied from class:Parser
Parses the given reader into a formula of the given type.- Specified by:
parseFormula
in classParser<DefeasibleLogicProgram,Formula>
- Parameters:
reader
- a reader- Returns:
- a formula
- Throws:
ParserException
- some parsing exceptions may be added here.
-
getSignature
public FolSignature getSignature()
-
Theory
public final DefeasibleLogicProgram Theory(FolSignature signature) throws ParseException
- Throws:
ParseException
-
Expression
public final void Expression(DefeasibleLogicProgram delp, FolSignature signature) throws ParseException
- Throws:
ParseException
-
Formula
public final FolFormula Formula(FolSignature signature) throws ParseException
- Throws:
ParseException
-
Literal
public final FolFormula Literal(DefeasibleLogicProgram delp, FolSignature signature) throws ParseException
- Throws:
ParseException
-
Atom
public final FolAtom Atom(DefeasibleLogicProgram delp, FolSignature signature) throws ParseException
- Throws:
ParseException
-
Term
public final Term Term(DefeasibleLogicProgram delp, FolSignature signature) throws ParseException
- Throws:
ParseException
-
ReInit
public void ReInit(java.io.InputStream stream)
-
ReInit
public void ReInit(java.io.InputStream stream, java.lang.String encoding)
-
ReInit
public void ReInit(java.io.Reader stream)
-
ReInit
public void ReInit(DelpParserTokenManager tm)
-
getNextToken
public final Token getNextToken()
-
getToken
public final Token getToken(int index)
-
generateParseException
public ParseException generateParseException()
-
enable_tracing
public final void enable_tracing()
-
disable_tracing
public final void disable_tracing()
-
-