Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 19 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:
Comments
Comment rules as shown:
/* text */   The text from “/*” to “*/” is ignored
// text      The text from “//” to the end of the line is ignored
Separators
The following tokens are used for separators:
 
Identifier Naming Requirements
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.
Two example identifiers: new_order  E72526   creditCheck
Local Variables
You can use local variables of the following types in rule actions and rule functions:
Primitive Arrays
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;
Literals
The TIBCO BusinessEvents rule Language supports these literals:
int — 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 can represent fractional values. 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 (""). The string must be on one line. Use \n for newlines. Use the plus sign (+) to concatenate string segments.
Examples: empty string: "" (quotes with no space). Space character: " " (quotes with one or more spaces). Strings with values: "P0QSTN3" "The quick brown fox had quite a feast!" Strings spanning multiple lines:
"The quick brown fox " +
"had quite a feast!"
boolean — One of these two values:   true    false
Null — This value:   null
Escape Sequences
You can represent characters in literals using these escape sequences:
Operators
The language defines the following operators. Operators in this list that are also used in the Java language work the same as the Java operators:
combined operation and assignment. As an example, expr += 2; is the same as expr = expr + 2;
+= works on strings as well as numbers. For example, you have a variable String s = "abc"; and then you use
s+= "def"; and so the value of s becomes "abcdef"

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved