Chapter 1 Rule Language Grammar : Rule Language Basics

Rule Language Basics
Whitespace
Whitespace is used to separate tokens (identifiers, keywords, literals, separators, and operators) just as it is used in any written language to separate words. Whitespace is also used to format code.
These are whitespace characters, excluding line terminators:
Line terminators include these characters:
Line terminators are not significant in condition or action rules.
Comments
Comment rules as shown:
/* text */     BusinessEvents ignores the text from “/*” to “*/”.
// text            BusinessEvents ignores the text from “//” to the end of the line.
Separators
The following tokens are used for separators:
 
Identifiers (Names)
An identifier (or name, to use the user interface label) is an unlimited-length sequence of letters and digits, the first of which must be a letter. Letters include uppercase and lowercase ASCII Latin letters A-Z, a-z, and the underscore (_).
Letters and digits may be drawn from the entire Unicode character set, which supports most writing scripts in use in the world today, including the large sets for Chinese, Japanese, and Korean. This allows programmers to use identifiers in their programs that are written in their native languages.
Digits include the ASCII digits 0-9.
Two identifiers are the same only if they have the same Unicode character for each letter or digit. Note that some letters look the same even though they are different Unicode characters. For example, a representation of the letter A using \u0041 is not the same as a representation of the letter A using \u0391.
Example identifiers:
 
Identifiers may not be the same as any literal, keyword, or other reserved word. See Keywords and other Reserved Words and Literals.
Local Variables
You can use local variables of the following types in action rules and rule functions:
You can also use primitive arrays, which are fixed length. Here are examples of array declaration, initialization, and array creation expressions:
    int i;               // int
    int[] ii = {1,2,i};  // array of int
    ii = int[] {1,2,3};
    int[] arr = int[5] {};
    arr = int[5]{};
    int arrLength = arr@length;
Keywords and other Reserved Words
Keywords are words that have special meaning to BusinessEvents. Keywords are not available for use as identifiers. Other words are used internally by BusinessEvents. These words are also not available for use as identifiers. Do not use the words listed in this section as identifiers.
The following words are for BusinessEvents internal use. Do not use them as identifiers, resource names, or folder names.
 
The following reserved words are either implemented as keywords in BusinessEvents or may be implemented in the future. Do not use them as identifiers, resource names, or folder names.
 
Literals
The BusinessEvents rule Language supports these literals:
Integer — One or more digits without a decimal. May be positive or negative. Examples:   4   45   -321   787878
Long — An integer literal suffixed with the letter L. The suffixed L can be either upper or lower case, but keep in mind that the lower case L (l) can be difficult to distinguish from the number one (1).
Examples:   0l   0777L   0x100000000L   2147483648L   0xC0B0L
Double — A number that has a decimal. D suffix is optional unless there is no decimal point or exponent.
Examples:   1D   1e1   2.   .3   0.0D   3.14   1e-9d   1e137
String — Zero or more characters enclosed in double quotes (""). Opening and closing double quotes cannot be interrupted by a line terminator (CR or LF). Use the plus sign (+) to concatenate string segments.
Examples: "" " " "P0QSTN3" "The quick brown fox had quite a feast!"
"The quick brown fox " +
"had quite a feast!"
Boolean — One of these two values:   true    false
Null — This value:   null
Do not use Unicode escapes for newlines or carriage returns as character literals. They will be transformed into actual line terminators. Use ’\n’ or ’\r’ instead.
The characters CR and LF are line terminators, not input characters.
Escape Sequences
You can represent single and double quotes, the backslash character, and some nongraphic characters in literals using these escape sequences:
Operators
The language defines the following operators:
 
Tests whether an object is an instance of specified type.
Restricted to use with concepts and events.
Rule Components
A TIBCO BusinessEvents rule has three components:
Declaration — Use the declaration to declare which concepts and events the rule will depend on, and the names by which instances of these entities can be referred to in the conditions and actions. Aliases must be valid identifiers. Declaring multiple terms of the same type allows the rule to consider multiple instances of the corresponding Entity.
Conditions — Each statement in the condition must evaluate to a boolean value. All of these statements must be true for the rule’s action to be executed. Assignments and calls to certain functions are disallowed in the condition.
Actions — List of statements that will be executed, when the rule is fired, for each combination of terms that matches all the conditions.