Lade...
 

CX_FORMULA - Syntax

CX_FORMULA - Syntax

Nachfolgend ist die für CX_FORMULA verwendete Grammatik in EBNF-Notation dokumentiert. Zur besseren Lesbarkeit wurden die sonst bei EBNF notwendigen Kommas weggelassen.

formula := [declarations] [statements] ; declarations := "local" ID {"," ID} ";" ; // The last expression determines the formula's result // If the formula ends with a statement then the result will be NULL // An empty formula (no statements, no expression) will always return 1.0 statements := { statement ";" } [expression] ; statement := if_statement | expression ; // "else" is optional in if_statement if_statement := "if" "(" expression ")" { "else" expression } ; // Operators are ordered according to their precedence from top to bottom expression := if_expression | operand | ("-"|"!") expression | expression ("*"|"/") expression | expression ("+"|"-") expression | expression (">="|"<="|"!="|"="|"<"|">") expression | expression ("&"|"^") expression | expression "|" expression | expression ":=" expression ; operand := constant | function_call | enum | local_var | type_name | term_type | intrinsic_constant | slot_name // ambiguous slots (with DDI fields of identical name) will be handled in 'access_expression' | "slot" "(" slot_name ")" // to explicitly handle ambiguous slots as slots and thus as input variables (dll ≥ 233016) | access_expression | "(" expression ")" ; constant := STRING // may be treated as enum value if previous operand refers to enum slot | INTEGER | CX_NUMERIC | CX_VALUE ; // "else" is mandatory in if_expression if_expression := "if" "(" expression ")" "else" expression ; // A leading "::" denotes an external function, which is a method that is called on // either the evaluating CX_FORMULA object or the first object from the PlugSpace, which implements this method. // Without a leading "::" the function gets called as method on its first argument. (eg. sin(x) -> x.sin()) function_call := ["::"] ID "(" [ expression { "," expression } ] ")" ; // Enum slot name can be explicitly specified with 'slotName::' // if previous operand was an enum slot then 'slotName::' is optional enum := [ID "::"] (ID|STRING) ; // Local variable must be declared in declarations block before being used local_var := ID ; // formula will use the numerical type id type_name := "STRING" | "INTEGER" | "CX_CLASS" | "CX_TRANSACTION" | ... ; term_type := "TERM" | "ANNIVERSARY" | "HOLIDAY" | "VACATION" | "WORKINGDAY" | "REST_TERM" | "ALL_TERM" | "NO_TERM" | "NO_ANNIVERSARY" | "NO_HOLIDAY" | "NO_VACATION" | "NO_WORKINGDAY" ; // Only a slot name or specifier + slot slot_name := [ ID "." ] ID ; // Predefined constants intrinsic_constant := "e" | "pi" | "π" | "true" | "false" | "INVALID" | "invalid" ; // All valid access expressions access_expression := ... ;