Try OpenEdge Now
skip to main content
BPM Events User's Guide
Rule syntax : Rule module syntax
 

Rule module syntax

translation_unit ::=
    [ "application" <ID> ]
    [ "module" [ <ID> ] [ "import" module_name ( "," module_name )* ";" ] ]
    ( declaration )*
    ( rule_group )*
    [ ["initialize" ] "{" ( statement )* "}" ]
    [ "finalize" "{" ( statement )* "}" ]
    <EOF>
module_name ::= <ID> [ "::" <ID> ]
//
// rule definition
//
rule_group::= "group" <ID> "{" ( rule )* "}"
rule::= "rule" <ID> "activated" "by"
    [ rule_param ("," rule_param )* ]
    ( "correlated" "with" "INDEX"
    |"terminated" "with" "FIRST_SUCCESS"
    |"try" ("SINGLE_CASE" | "ALL_CASE")
    )*
    [ "if" expr ] "then"
    "{" ( statement )* "}"
rule_param::= ["*"] <ID> "of" [<ID>] "::" [<ID>]
//
// declaration
//
declaration::= function_defintion
| value_defintion
| var_defintion
| type_defintion
| enum_defintion
enum_defintion ::= "enum" <ID> "{" <ID> ( "," <ID> )* "}"
function_defintion ::= "fun" function_def ( "and" function_def )*
function_def ::= <ID> fun_args [":" type] compound_statement
fun_args::= ( "(" [ <ID> [":" type ( "," <ID> [":" type] )* ] ")" )+
value_defintion ::= "val" <ID> [":" type] "=" expr ";"
var_defintion::= "var" <ID> [":" type] [ "=" expr ] ";"
//
// type definition
//
type_defintion ::= "type" <ID> "=" type ";"
type::= fun_type
fun_type::= prod_type [ "->" fun_type ]
prod_type::= p_type ( "*" p_type )*
p_type::= primitive_type
| id_type
| struct_type
| object_type
| array_type
| collection_type
| map_type
| instance_type
| iterator_type
| type_var
| "(" type ")"
primitive_type ::= "void"
| "int"
| "double"
| "float"
| "char"
| "string"
| "boolean"
| "unit"
id_type::= qualified_name
struct_type ::= "{" <ID> ":" p_type ( "," <ID> ":" p_type )* "}"
object_type::= ("object" | "cell") struct_type
array_type::= ("array" | "infopad") [ "<" type ">" ]( "[" [longLiteral | id_type] "]" )+
collection_type::= ("set" | "list") [ "<" type ">" ]
map_type::= "map" [ "<" type "," type ">" ]
instance_type::= "instance" "<" type ">"
iterator_type::= "iterator" [ "<" type ">" ]
type_var::= "‘" ( <ID> | longLiteral )
//
// statement
//
statement ::= iterate_statement
| declaration_statement
| compound_statement
| expression_statement
| selection_statement
| jump_statement
| event_statement
declaration_statement ::= declaration
expression_statement ::= [ expr ] ";"
selection_statement ::= "if" "(" expr ")" statement [ "else" statement ]
compound_statement ::= "{" ( statement )* "}"
iterate_statement ::= "for" "(" ( var_defintion | ";" ) [ expr ] ";" [ expr ] ")" statement
| "while" "(" expr ")" statement
| "do" statement
    (
"while" "(" expr ")" ";"
|[ fromClause ] [ whereClause ] ";"
    )
jump_statement ::= "break" ";"
| "continue" ";"
| "return" [ expr ] ";"
event_statement ::= "generate" "(" [ event_ctor_body ] ")"
| "perform" "(" [ "adapter" ":" <STRING> "," ] <STRING> ","
    ( event_ctor_body | expr ("," expr )* ) ")"
| "schedule" "(" expr ( "," expr )*
    [ "," event_ctor_body ] ")"
| "unschedule" "(" expr [ "," event_ctor_body ] ")"
| "discard" "(" expr ( "," expr )* ")"
event_ctor_body ::= event_actionval ( "," event_actionval )*
event_actionval ::= event_actionval_attr ":" expr
event_actionval_attr ::= event_prop_name ( "." event_prop_name )*
event_prop_name ::= <ID>
| "type"
| "event"
//
// expression
//
expr ::= assigmentExpr
assigmentExpr ::= orExpr
    [ (":=" | "+=" | "-=" | "*=" | "/=" | "%=" ) assigmentExpr
    | "::=" <ID> fun_arguments
    ]
orExpr ::= andExpr ( "or" andExpr )*
andExpr ::= quantifierExpr ( "and" quantifierExpr )*
quantifierExpr ::= "for" "all" <ID> "in" expr ":" equalityExpr
| "exists" <ID> "in" expr ":" equalityExpr
| "fn" fun_args [":" type]
    (compound_statement
    |"=>" equalityExpr
    )
| equalityExpr
equalityExpr ::= relationalExpr ( ("=" | "!=") ["some" | "all"] relationalExpr )*
relationalExpr ::= additiveExpr
    (("<" | "<=" | ">" | ">=") ["some" | "all"] additiveExpr
    |"like" additiveExpr
    )*
additiveExpr ::= multicativeExpr ( ("+" | "-" | "union" | "except") multicativeExpr )*
multicativeExpr ::= inExpr ( ("*" | "/" | "%" | "intersect") inExpr )*
inExpr ::= unaryExpr [ "<-" unaryExpr ] ( "?" unaryExpr ":" unaryExpr )*
unaryExpr ::= ("+" | "-" | "not" ) unaryExpr
| ("++" | "--" ) unaryExpr
| ("*" ) unaryExpr
| postfixExpr
postfixExpr ::= primaryExpr
    (
    "." <ID>
    | ("++"|"--")
    | fun_arguments
    | "[" expr "]"
    )*
primaryExpr::= persistent_ctor
|new_expr
|identifier
|("let" | "letrec") declaration "in" expr ( ";" expr )* [";"] "end"
|"(" ")"
|"(" expr ("," expr )* ")"
|"(" expr (";" expr )+ ")"
|struct_ctor
|selectExpr
|enum_length_expr
|date_ctor
|timeunit_ctor
|literal
// query exp
selectExpr ::= "select" [ "distinct" ] ( fieldList | expr )
                    fromClause [ whereClause ] "end"
fromClause ::= "from" iteratorDef ( "," iteratorDef )*
iteratorDef ::= <ID> [":" expr ]
whereClause ::= "where" expr
// struct
struct_ctor::= "{" fieldList "}"
fieldList::= field ( "," field )*
field::= <ID> ":" expr
// aggregate exp
persistent_ctor ::= array_ctor
| collection_ctor
| object_ctor
| map_ctor
array_ctor::= array_type
    (
array_init
    |fun_arguments
    )
array_init::= "{" [ array_init_value ( "," array_init_value)* ] "}"
array_init_value ::= array_init
| expr
collection_ctor ::= collection_type [ "{" [ valueList ] "}" ]
object_ctor::= (id_type | "object" | "cell" ) [ "{" fieldList "}" ]
map_ctor::= map_type [ "{" [ elemMap ( "," elemMap )* ] "}" ]
elemMap::= expr ":" expr
// new exp
new_expr::= "new" ["transient" | "persistent"] [ fun_arguments ] persistent_ctor
fun_arguments ::= "(" [ valueList ] ")"
valueList::= expr ( "," expr )*
enum_length_expr ::= "#" id_type
// date exp
date_ctor ::= date_unit ("/" date_unit )*
| <NOW>
date_unit ::= (<YEAR> | <MONTH> | <DAY> | <HOUR> | <MIN> | <SEC>) ":" primaryExpr
timeunit_ctor ::= (<YEAR>| <MONTH>| <DAY>| <HOUR>| <MIN>| <SEC> )
// literal
identifier::= qualified_name
qualified_name ::= <ID> ( "::" <ID> )*
literal ::= <CHARACTER>
| <STRING>
| "true"
| "false"
| "nil"
| longLiteral
| realLiteral
longLiteral ::= <DECIMALINT>
realLiteral ::= <FLOATONE>
| <FLOATTWO>