|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PredicateEnvironment
Predicate environments are similar to normal keyword environments except instead of binding commands to an identifier they are bound to a predicate condition.
In general the sleep syntax for declaring a predicate environment is:
keyword (condition) { commands; }
Script predicate environment bridge keywords should be registered with the script parser before any scripts are loaded. This can be accomplished as follows:
ParserConfig.addKeyword("keyword");
To install a new predicate environment into the script environment:
ScriptInstance script; // assume Environment myEnvironmentBridge; // assume Hashtable environment = script.getScriptEnvironment().getEnvironment(); environment.put("keyword", myEnvironmentBridge);
Predicate environments are a powerful way to create environments that are triggered selectively. Predicate environments can also be used to add new constructs to the sleep language such as an unless (comparison) { } construct.
Environment
,
ParserConfig.addKeyword(String)
Method Summary | |
---|---|
void |
bindPredicate(ScriptInstance si,
java.lang.String typeKeyword,
Check condition,
Block functionBody)
binds a function (functionName) of a certain type (typeKeyword) to the defined functionBody. |
Method Detail |
---|
void bindPredicate(ScriptInstance si, java.lang.String typeKeyword, Check condition, Block functionBody)
typeKeyword
- the keyword for the function. (i.e. sub)condition
- the condition under which this can / should be executed.functionBody
- the compiled body of the function (i.e. code to add 2 numbers)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |