|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlp.trans.Grounder<P>
public abstract class Grounder<P>
An abstract class that contains common functionality of classes used to
ground logic programs (LpGrounder
and DlpGrounder
).
LpGrounder
,
DlpGrounder
Field Summary | |
---|---|
private LparseWrapper |
lw
An LparseWrapper instance used to execute lparse when grounding
the logic program with tagged rules created from the original
(non-ground) dynamic logic program. |
private List<GrounderMessage> |
warnings
A list of warnings that lparse issued on the input program. |
Constructor Summary | |
---|---|
Grounder(LparseWrapper wrapper)
Creates a new instance of Grounder that uses the given object
to invoke lparse and process its output. |
Method Summary | |
---|---|
List<GrounderMessage> |
getWarnings()
Returns a list of warnings that lparse issued on the input DLP. |
P |
ground(P inputProgram)
Returns a grounded version of inputProgram . |
protected abstract GrounderMessage |
makeGrounderMessage(LparseMessage lparseMessage,
P inputProgram)
Creates an error message based on lparseMessage from lparse and
the input program. |
protected abstract P |
parseOutput(String lparseOutput)
Parses the given lparse output and returns the grounded program. |
protected abstract void |
printProgram(P inputProgram,
Writer writer)
Prints inputProgram in a form that is groundable by lparse (as
long as the programmer didn't break the constraints imposed by lparse). |
void |
setLparsePath(String lparsePath)
Sets the path to lparse binary that is used to invoke lparse. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final LparseWrapper lw
LparseWrapper
instance used to execute lparse when grounding
the logic program with tagged rules created from the original
(non-ground) dynamic logic program. It also parses the standard error
output of lparse and translates it into LparseMessage
objects.
private final List<GrounderMessage> warnings
Constructor Detail |
---|
public Grounder(LparseWrapper wrapper)
Grounder
that uses the given object
to invoke lparse and process its output.
wrapper
- the object used to execute lparse, parse its warnings
and/or errors and create corresponding LparseMessage objectsMethod Detail |
---|
public void setLparsePath(String lparsePath)
lparsePath
- path to the lparse binary
IllegalArgumentException
- if lparsePath
is null
or
an empty stringpublic P ground(P inputProgram)
inputProgram
.
inputProgram
- the program to ground
inputProgram
. If
inputProgram
is null
, null
is returned.
WrapperException
- if an error occurs while calling lparse, see
LparseWrapper.waitFor()
GrounderMessage
- if lparse refuses to ground the input program,
usually this means that it cannot guarantee that the resulting grounded
program will be finite
IOException
- (wrapped in an ExceptionAdapter
) if
an I/O error occurs while manipulating the standard input and output
streams of an lparse process
LpParserException
- if this exception is thrown, it is most
probably a bug in implementation of this classpublic List<GrounderMessage> getWarnings()
protected abstract void printProgram(P inputProgram, Writer writer)
inputProgram
in a form that is groundable by lparse (as
long as the programmer didn't break the constraints imposed by lparse).
inputProgram
- the (ungrounded) input programwriter
- a Writer
to write to
IOException
- (wrapped in an ExceptionAdapter
) if
an I/O error occurs while manipulating the standard input and output
streams of an lparse processprotected abstract GrounderMessage makeGrounderMessage(LparseMessage lparseMessage, P inputProgram)
lparseMessage
from lparse and
the input program.
lparseMessage
- the error or warning message issued by lparseinputProgram
- the input program
protected abstract P parseOutput(String lparseOutput)
lparseOutput
- the lparse output
LpParserException
- if this exception is thrown, it is most
probably a bug in implementation of this class
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |