ARL Master Index

# ARL Coding Conventions

The Able Rule Language syntax is entirely free-form and is very much like standard Java syntax, but there are some conventions you must follow when writing ARL statements. This section describes various components of the rule language and how to code them.

On this page...

- Comments
- White space
- Keywords
- Identifiers
- Boolean Literals
- Numbers
- Lists
- Strings

### Comments

A comment may appear in only two places: on a line by itself or at the end of a line containing a rule language statement. Comments may be delimited by a beginning `//` (slash-slash) or inside a multiline comment block delimited by /* (slash-star) and ended by */ (star-slash). The following lines all demonstrate valid comments:

    /*
     * This is a multi-line comment.
     *
    */
     rule1: a = b; // Comment at end of line

Return to top

### White space

White space (blanks, tabs, newlines, etc.) may be sprinkled freely throughout a source file. They are all ignored. The following two rule statements are parsed identically:

     rule_001:
      if Temperature is slightly elevated then Pressure is positively moderate

     rule_002 :
      if Temperature is slightly elevated
      then Pressure is positively moderate

Return to top

### Keywords

Rule language keywords are case sensitive. For example, the keyword true must be entered as true. True, tRue, TRUE, and so on are invalid. You may not use any keyword as an identifier.

All keywords have a single form. The following table identifies ARL keywords:

Keywords and their meaning
inputs | Denotes a list of variables expected as input by the ruleset
outputs | Denotes a list of variables returned as outputs by the ruleset
functions | Declares a list of user defined functions
library | Loads a user defined function library (a Java class)
import | Loads a Java class for use by rules in the ruleset

In addition to the above reserved keywords, the following tables identify other, reserved, keywords (all case sensitive):

Reserved Keywords
Options related
AlphaCut
CorrelationMethod
DefuzzifyMethod
InferenceMethod
predicates
GoalPredicates
import
library
GoalVariable
Correlation methods
Product
Minimum
Defuzzify methods
Centroid
MaxHeight
Inference methods
Backward
Forward
Forward2
Forward3
Mixed
Predicate
Script
FuzzyAdd
MinMax
ProductOr
Variable related
Boolean
Categorical
Continuous
Discrete
Fuzzy
List
Numeric
Object
String
static
Fuzzy set related
Beta
Gaussian
Linear
Pi
Segments
Shoulder
Sigmoid
Trapezoid
Triangle
Down
Left
Right
Up
Hedges
About
Above
Below
CloseTo
Extremely
Generally
InVicinityOf
Not
Positively
Slightly
Somewhat
Very
Rule related
and
is
if
then
else
when
do
while
Miscellaneous
ruleset
variables
true
false

Return to top

### Identifiers

Identifiers are the names of things that you define; for example, variables names, fuzzy set names, and rule labels that you create are all identifers.

Identifiers are case sensitive. For example, if you define a continuous variable with the name of myVar you cannot later refer to that variable as MYvar as the latter name is taken to refer to a completely different variable that might be of a different type (if it exists at all).

Identifiers are composed of alphabetics (a-zA-Z), numerics (0-9), and the characters `_` (underscore) and `$` (dollar). Numeric characters cannot be used to begin an identifier.

The following are all valid identifiers:

        thisIsVar1
        this_Is_var_2
        foo$
        $foo

The following are examples of illegal identifiers:

     IsVar.1 // Contains a dot
    9foo // Begins with a number

Return to top

### Boolean Literals

Boolean literals are simply the keywords true and false, case sensitive.

     someVariable Boolean(true) if someVariable == true ...

Return to top

### Numbers

Numbers may be entered with a leading `+` (plus) or `-` (minus) sign. Numbers between -1 and +1 must be entered with a leading zero before the decimal point. The following are all valid:

        0.55         -0.55         +0.55
        100          -100          +100
        +100.00       0.001        -36.99

The following are examples of illegal numbers:

     .56 // No zero before the decimal point
    -.05 // No zero before the decimal point

Return to top

### Lists

Most lists can be entered with each element separated by any amount of whitespace, a comma, or both. The following are all valid:

myFuzzyVar is positively very very Hot; myFuzzyVar is positively very, very Hot; myFuzzyVar is positively very,very Hot; myFuzzyVar is positively, very, very, Hot; Categorical myCatVar = new Categorical("a","9","d","4.7","F"); Categorical myCatVar = new Categorical("a", "9", "d", "4.7", "F"); Categorical myCatVar = new Categorical( // List on multiple lines "a", "9", "d", "4.7", "F" );

Return to top

### Strings

Strings are delimited by double quotes ("") and may contain certain whitespace characters. Strings are always case sensitive. The following lines all demonstrate valid strings:

     Categorical myCatVar = new Categorical( "Abc", "Def ghi" );
     String myStringVar = new String("This is a string variable with a long initial value.");

     R01: myStringVar = "This is another string value";

Return to top

Able Rule Language master index.
Able RuleSet Editor master index.
Rule package table of contents.

Last modified: Fri Sep 21 14:21:18 Central Daylight Time 2001