All logic rules in an Able ruleset are grouped into named "rule blocks". A ruleset can have many rule blocks and rules in one rule block can invoke rules in other rule blocks by using the invokeRuleBlock() built-in method.
Rule block statements are the last statements in a ruleset.
RuleSet <nameOfRuleSet> ( . . . Rules <nameOfRuleBlock> ( // One or more named rule blocks <rule>+ // One or more rules in a rule block ) ) ;End of ruleset |
All rules in an Able ruleset are grouped into named "rule blocks". A ruleset can have many rule blocks and rules in one rule block can invoke rules in other rule blocks.
There are three special rule blocks, however. One of them is
required, and the other two are optional. The required rule
block must be unnamed (it is the only rule block that can be
unnamed) or it must have the name of MAIN
(completely case insensitive). The MAIN
rule block is the one that is processed by the specified
inferencing algorithm. (See
InferenceMethod.)
The two optional rule blocks are INIT
and
IDLE
. (Again, these names are completely
case insensitive.) The INIT
rule block, if
present, is processed once and only once the very first time a
ruleset is processed. It can be used, as the name implies, to
perform initialization of the ruleset. The rules in it are
processed sequentially. The IDLE
rule
block, if present, is processed each time a ruleset's inference
engine finishes processing, in its special way, the
MAIN
rule block. As for the
INIT
rule block, rules in the
IDLE
rule block are processed sequentially.
The names of any other rule blocks in a ruleset are case sensitive, and the rules in them are not processed in any way unless the rule blocks are explicitly called from some rule that is processed. If called, rules in these rule blocks are processed sequentially.
Syntax
Rules <nameOfRuleBlock> ( <rule>+ // One or more rules in a rule block )
Parameters
INIT
, MAIN
,
or IDLE
, case insensitive, designating one
of the special rule blocks;
is omitted, designating the rule block as the
MAIN
rule block;
is an identifier that
names a callable rule block.
Examples
RuleSet <nameOfRuleSet> ( . . . Rules init ( // Special rule block INIT a1: someVar = someFunction(); . . . ) Rules ( // Special rule block MAIN m1: if someVar >= 100 then result = invokeRuleBlock("fooBlock") . . . ) Rules fooBlock ( // Callable rule block f1: someVar = someOtherFunction(); . . . ) ) |