|
CIDER Toolkit Version 0.1.0-beta |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Object | +--Interpreter
The Interpreter is the main control class in the CIDER toolkit that maintains a parse forest representation of a diagram, is responsible for applying productions, and also controls the application of transformations. It as an abstract base class that is extended by a grammar-specific class that is responsible for implementing functionality that is grammar dependent. This grammar-specific class is produced by the CIDER compiler. Note that when an instance of this class is created, auto forest checking and auto constraint solving are initially turned on.
| Method Summary | |
boolean |
addConstraint(Constraint c)
Adds a constraint to the multi-way constraint solver. |
void |
addGrammarSymbolListener(GrammarSymbolListener gsl)
Adds an listener to listen for grammar symbol events. |
boolean |
addTerminalSymbol(GrammarSymbol symbol)
Adds a terminal symbol to the parse forest. |
abstract boolean |
applyTransformation(int transformation)
Applies a specified transformation to the parse forest at the first valid location it finds. |
abstract boolean |
applyTransformationInParallel(int transformation)
Applies a specified transformation to the parse forest in parallel. |
void |
checkForest()
Checks all productions and updates all attributes in the parse forest that require it. |
void |
disableUndo()
Turns off the ability to undo actions. |
void |
enableUndo()
Turns on the ability to undo actions. |
abstract void |
evaluateProductionRules()
Explicitly calls the grammar-specific interpreter to evaluate the production rules. |
ConstraintSolver |
getConstraintSolver()
Returns the multi-way constraint solver associated with the interpreter. |
java.util.Set |
getTerminalSymbols()
Returns a set containing all terminal symbols in the parse forest. |
int |
getUndoIndex()
Returns the index to the most recent action recorded on the undo action list. |
boolean |
isAutoConstraintSolvingOn()
Returns true if auto constraint solving is on, false otherwise. |
boolean |
isAutoForestCheckingOn()
Returns true if auto forest checking is on, false otherwise. |
boolean |
isUndoEnabled()
Returns true if the undo feature is currently enabled, false otherwise. |
boolean |
isUpToDate()
Returns true if the parse forest is up to date, false otherwise. |
boolean |
load(java.lang.String filename)
Restores a previously saved state. |
void |
printForest(java.io.PrintStream stream)
Prints the parse forest. |
void |
reevaluateForest()
Reevaluates all productions in the parse forest. |
boolean |
removeConstraint(Constraint c)
Removes a constraint from the multi-way constraint solver. |
void |
removeGrammarSymbolListener(GrammarSymbolListener gsl)
Removes a listener that listens for grammar symbol events. |
boolean |
removeTerminalSymbol(GrammarSymbol symbol)
Removes a terminal symbol from the parse forest. |
boolean |
save(java.lang.String filename)
Saves the current state. |
void |
setAutoConstraintSolving(boolean on)
Allows auto constraint solving to be turned on or off. |
void |
setAutoForestChecking(boolean on)
Allows auto forest checking to be turned on or off. |
static void |
setLoggingLevel(java.util.logging.Level level)
Allows the logging level for the CIDER logger to be set. |
void |
solve()
Calls the solver to solve all constraints. |
boolean |
undoActions(int index)
Will undo actions that occurred after a specific time, as indicated by the index value. |
void |
variableModified(ConstraintVariableEvent event)
Implemented as part of the ConstraintVariableListener interface. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static void setLoggingLevel(java.util.logging.Level level)
Level.INFO. Logging can be turned off by using Level.OFF, and all messages
will be logged if Level.ALL is used.
level - The logging level to be set.public abstract void evaluateProductionRules()
public abstract boolean applyTransformation(int transformation)
throws java.lang.IllegalArgumentException
transformation - The transformation to be applied.
true if the transformation was successful, false otherwise.
java.lang.IllegalArgumentException - If an unknown transformation is specified.
public abstract boolean applyTransformationInParallel(int transformation)
throws java.lang.IllegalArgumentException
transformation - The transformation to be applied.
true if the transformation was successful, false otherwise.
java.lang.IllegalArgumentException - If an unknown transformation is specified, or a
a transformation is specified that cannot be applied in parallel (such as a compound transformation).public java.util.Set getTerminalSymbols()
public boolean addTerminalSymbol(GrammarSymbol symbol)
symbol - The symbol to be added.
true if successful, false if the symbol
is not a terminal symbol, or is already present in the parse forest.public boolean removeTerminalSymbol(GrammarSymbol symbol)
symbol - The symbol to be removed.
true if successful, false if the symbol
is not a terminal symbol, or is not present in the parse forest.public ConstraintSolver getConstraintSolver()
null is returned.
public boolean addConstraint(Constraint c)
c - The constraint to be added.
true if successful, false if no constraint
solver is present or the solver would not accept the constraint.public boolean removeConstraint(Constraint c)
c - The constraint to be removed.
true if successful, false if no constraint
solver is present or the solver could not remove the constraint.public void solve()
public void printForest(java.io.PrintStream stream)
stream - The output stream where the text is sent to.public boolean isUpToDate()
true if the parse forest is up to date, false otherwise.
public void addGrammarSymbolListener(GrammarSymbolListener gsl)
gsl - The listener to be added.public void removeGrammarSymbolListener(GrammarSymbolListener gsl)
gsl - The listener to be removed.public boolean isAutoForestCheckingOn()
true if auto forest checking is on, false otherwise.
Auto forest checking means that each change that is made to the forest (via a symbol
being added, removed or modified), will result in checks to ensure that the forest
is in a valid state and up to date.
public void setAutoForestChecking(boolean on)
on - true to turn on, false to turn off.public boolean isAutoConstraintSolvingOn()
true if auto constraint solving is on, false otherwise.
Auto constraint solving means that the multi-way constraint solver will automatically
enforce any constraints that it is responsible for, ensuring that the parse forest remains in a valid state.
public void setAutoConstraintSolving(boolean on)
on - true to turn on, false to turn off.public void checkForest()
public void reevaluateForest()
public void variableModified(ConstraintVariableEvent event)
ConstraintVariableListener interface.
Listens for when a constraint variable has been modified by the multi-way constraint solver.
variableModified in interface ConstraintVariableListenerevent - Contains details of the event.public boolean save(java.lang.String filename)
filename - The name of the file where the state will be saved to.
true if successful, false otherwise.public boolean load(java.lang.String filename)
filename - The name of the file that contains the saved state.
true if successful, false otherwise.public boolean isUndoEnabled()
true if the undo feature is currently enabled, false otherwise.
public void enableUndo()
public void disableUndo()
public int getUndoIndex()
undoActions(int) method).
public boolean undoActions(int index)
index - The index in the undo action list (obtained from getUndoIndex()).
true if successful, false if undo is not enabled,
or an invalid index value is given.
|
CIDER Toolkit Version 0.1.0-beta |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||