2017 October Release

Grammar of the app.ducx Expression LanguagePermanent link for this heading

The grammar of the app.ducx Expression Language is formally defined as described below.

Grammar

app.ducx Expression Language

Expression := { Statement }.
Statement := ( ";" | Directive ";" | Block | Declare ";" | If | For | While | Do ";" |
  Switch | Break ";" | Continue ";" | Return ";" | Yield ";" | Try | Throw ";" |
  Sequence [ ";" ] ).
Directive := "%%" Name [ ( Sequence | "(" [ Sequence ] ")" ) ].
Block := "{" Expression "}".
Declare := "declare" [ ">" | "&" | "<" ] Ident { "," [ ">" | "&" | "<" ] Ident }.
If := "if" "(" Cond ")" Block [ "else" ( If | Block ) ].
For := "for" "(" Sequence ( ";" [ Cond ] ";" Sequence | ":" Statement ) ")"
  Block.
While := "while" "(" Cond ")" Block.
Do := "do" Block "while" "(" Cond ")".
Switch := "switch" "(" Cond ")" "{" { ( "case" ( Ident | Const ) | "default" ) ":"
  [ Expression ] } "}".
Break := "break".
Continue := "continue".
Return := "return" [ Assign ].
Yield := "yield" Assign.
Try := "try" [ [ "new" ] "transaction" ] Block {
  "catch" "(" ( [ "+" | "-" ] Integer | Object |
    [ ( "@" | "::" | ":>" ) ] Ident | "..." ) ")" Block }
  [ "finally" Block ].
Throw := "throw" Cond.
Items := [ Init ] { "," [ Init ] }.
Sequence := [ Assign ] { "," [ Assign ] }.
Arguments := [ Assign ] { "," [ Assign ] }.
Init := Cond [ ( ":" | "=" ) Assign ].
Assign :=
  Cond [ [ "[]" ] [ ( "@" | "::" | ":>" ) ] Ident ]
  [ ( "=" | "&=" | "^=" | "|=" | "<<=" | ">>=" | "+=" | "-=" | "*=" | "/=" | "%=" )
  Assign ].
Cond := Or [ "?" Sequence ":" Cond ].
Or := And { ( "||" | "or" ) And }.
And := BitOr { ( "&&" | "and" ) BitOr }.
BitOr := BitXOr { "|" BitXOr }.
BitXOr := BitAnd { "^" BitAnd }.
BitAnd := Equal { "&" Equal }.
Equal := Rel [ ( "==" | "!=" | "<>" ) Rel ].
Rel := Shift [ ( ( "<" | "<=" | ">" | ">=" | "<=>" ) Shift |
  [ "sounds" ] [ "not" ] "like" Shift |
  [ "not" ] "contains" Shift |
  [ "not" ] "in" Shift |
  [ "not" ] "includes" Shift |
  [ "not" ] "between" Shift "and" Shift |
  "is" [ "not" ] "null" ) ].
Shift := Add { ( "<<" | ">>" ) Add }.
Add := Mul { ( "+" | "-" ) Mul }.
Mul := Prefix { ( "*" | "/" | "%" ) Prefix }.
Prefix := ( Postfix |
  ( "&" | "++" | "--" | "!" | "not" | "~" | "+" | "-" ) Prefix ).
Postfix := ( Primary { "." Qualifier |
  "(" Arguments ")" [ "[" ( "..." | Cond ) "]" ] |
  "[" Sequence "]" |
  "++" | "--" |
  "->" Qualifier "(" Arguments ")" [ "[" Cond "]" ] } |
  "->" Qualifier [ "(" Arguments ")" [ "[" Cond "]" ] ] ).
Qualifier := ( Ident | Reference | "[" Sequence "]" ).
Primary := (
  "@" ( "this" | Ident ) |
  "::" ( "this" | Ident | Reference ) |
  ":>" ( "this" | Ident | Reference ) |
  "this" | Ident | Reference |
  "[]" | "null" | "true" | "false" |
  "coort" | "cootx" | "cooobj" | "coometh" | "coocontext" |
  "coouser" |"coogroup" |"cooposition" |

  "cooenv" | "cooroot" | "coolang" | "coodomain" | "coonow" |
  ( [ "upper" | "lower" | "count" | "sum" | "avg" | "min" | "max" ] "(" Sequence ")" ) |
  "insert" "(" Assign "," Assign "," Assign ")" |
  "delete" "(" Assign "," Assign [ "," Assign ] ")" |
  "find" "(" Assign "," Assign ")" |
  "sort" "(" Assign ")" |
  "unique" "(" Assign ")" |
  "revert" "(" Assign ")" |
  "super" "(" ")" |
  "typeof" "(" Assign ")" |
  "indexof" "(" Assign "," Assign ")" |
  "strlen" "(" Assign ")" |
  "strtrim" "(" Assign ")" |
  "strhead" "(" Assign "," Assign ")" |
  "strtail" "(" Assign "," Assign ")" |
  "strsplit" "(" Assign "," Assign ")" |
  "strjoin" "(" Assign [ "," Assign ] ")" |
  "strreplace" "(" Assign "," Assign [ "," Assign ] ")" |
  "(" Sequence ")" |
  "{" Items "}" |
  "[" Sequence "]" |
  Const ).
Const := ( String | [ "+" | "-" ] Integer | [ "+" | "-" ] Float | DateTime | Object ).
Ident := ( "$" | [ "$" ] Name ).
Letter := "a" ... "z" "A" ... "Z".
Digit := "0" ... "9".
HexDigit := "0" ... "9" "a" ... "f" "A" ... "F".
Digits := Digit { Digit }.
HexDigits := HexDigit { HexDigit }.
Name := Letter { ( Letter | Digit | "_" ) }.
Reference := Name [ "@" Digits "." Digits [ ":" Name ] ].
String := ( "'" ... "'" | '"' ... '"' ).
Integer := ( Digits | "0" ( "x" | "X" ) HexDigits ).
Float := Digits "." [ Digits ]
  [ ( "d" | "D" | "e" | "E" ) [ ( "+" | "-" ) ] Digits ].
DateTime := Digits "-" Digits "-" Digits
  ( "T" | " " ) Digit Digit ":" Digit Digit ":" Digit Digit.
Object := ( Address | "#" Reference ).
Address := "COO." Digits "." Digits "." Digits "." Digits [ "@" DateTime ].