github.com/TIBCOSoftware/flogo-lib@v0.5.9/core/mapper/exprmapper/expression/gocc/flogo.bnf (about)

     1  /*
     2      This file use to describe all function and expression that support in Flogo.
     3      BNF standard expression
     4  
     5      Author: Tracy Li
     6   */
     7  
     8  !whitespace : ' ' | '\t' | '\n' | '\r' ;
     9  
    10  _digit : '0'-'9' ;
    11  
    12  _number : _digit {_digit} ;
    13  
    14  _float_exp  : ( 'e' | 'E' ) [ '+' | '-' ] _number ;
    15  
    16  _float_lit : ( _number '.' _number _float_exp )
    17     | ( _number '.' ( _number | _float_exp ) )
    18     | ( '.' ( _number | _float_exp ) )
    19     | ( _number _float_exp )
    20     ;
    21  
    22  float : (_float_lit);
    23  number : (_number);
    24  _function_name:  'a'-'z' | 'A'-'Z' | '0'-'9' | '.' | '_';
    25  
    26  _refbracket : '[' {.} ']';
    27  _ref : 'a'-'z' | 'A'-'Z' | '.' | '0'-'9' | '-' | '[' | ']' | '_' | ' ' | '$' | '{' | '}' | _refbracket;
    28  _flogostring : {_ref};
    29  
    30  //Static function name, such as concat, substring, len etc...
    31  function_name : {_function_name} ;
    32  _quotedpair : '\\' . ;
    33  
    34  //Double quotes strings
    35  doublequotes_string : '"' {_quotedpair | .} '"';
    36  singlequote_string : '\'' {_quotedpair |.} '\'' ;
    37  //Flogo Ref string, such as" $A3.Input.Query.Result
    38  argument : '$' _flogostring ;
    39  
    40  
    41  << import "github.com/TIBCOSoftware/flogo-lib/core/mapper/exprmapper/expression/direction" >>
    42  
    43  
    44  /*
    45  
    46      Describe Flogo function rules.
    47      Example:
    48          1. concat("This","is",concat("my","first"),"gocc",concat("lexer","and","parser"),concat("go","program","!!!"))
    49             Result:Thisismyfirstgocclexerandparsergoprogram!!!
    50          2. concat("Beijing",String(number(Len("lixingwang"))))
    51             Result: Beijing10
    52   */
    53  
    54  Flogo
    55      : Expr
    56      | TernaryExpr
    57      ;
    58  
    59  Expr
    60      : OrExpr
    61    ;
    62  OrExpr
    63      : OrExpr "||" AndExpr                                        <<direction.NewExpression($0, $1, $2) >>
    64      | AndExpr
    65      ;
    66  AndExpr
    67      : AndExpr "&&" ConditionalExpr                               <<direction.NewExpression($0, $1, $2) >>
    68      | ConditionalExpr
    69      ;
    70  ConditionalExpr
    71      : ConditionalExpr RelOp AddExpr                              <<direction.NewExpression($0, $1, $2) >>
    72      | AddExpr
    73      ;
    74  AddExpr
    75      : AddExpr AddOp MulExpr                                      <<direction.NewExpression($0, $1, $2) >>
    76      | MulExpr
    77      ;
    78  MulExpr
    79      : MulExpr MulOp ParenthesesExpr                              <<direction.NewExpression($0, $1, $2) >>
    80      | ParenthesesExpr
    81      ;
    82  ParenthesesExpr
    83      : ExprLiteral
    84      | "(" Expr ")"                                               <<direction.NewExpressionField($1)>>
    85      ;
    86  
    87  RelOp : "==" | "!=" | "<" | "<=" | ">" | ">=";
    88  AddOp : "+" | "-";
    89  MulOp : "*" | "/" | "%";
    90  
    91  
    92  Func
    93     : function_name "(" ArgsList ")"             << direction.NewFunction($0, $2) >>
    94     | function_name "()"                         << direction.NewFunction($0, "") >>
    95     ;
    96  
    97  ArgsList
    98     : ExprLiteral                                <<direction.NewArgument($0)>>
    99     | ArgsList "," ArgsList                      <<direction.NewArguments($0, $2)>>
   100      ;
   101  
   102  TernaryExpr
   103      : TernaryArgument "?" TernaryArgument ":" TernaryArgument                    <<direction.NewTernaryExpression($0, $2, $4)>>
   104      ;
   105  
   106  TernaryArgument
   107       :  Expr
   108       |  TernaryExpr                              <<direction.NewTernaryArgument($0)>>
   109       | "(" TernaryExpr ")"                       <<direction.NewTernaryArgument($1)>>
   110       ;
   111  
   112  ExprLiteral
   113      : Literal                                    <<direction.NewLiteralExpr($0)>>
   114      | Func
   115      ;
   116  
   117  Literal
   118       : Int                          <<direction.NewIntLit($0)>>
   119       | Float                        <<direction.NewFloatLit($0)>>
   120       | NegativeLiteral
   121       | Bool                         <<direction.NewBool($0)>>
   122       | DoubleQString                <<direction.NewDoubleQuoteStringLit($0)>>
   123       | SingleQString                <<direction.NewSingleQuoteStringLit($0)>>
   124       | MappingRef                   <<direction.NewMappingRef($0)>>
   125       | Nil                          <<direction.NewNilLit($0)>>
   126       ;
   127  
   128  NegativeLiteral
   129      : "-"Int                          <<direction.NewNagtiveIntLit($1)>>
   130      | "-"Float                        <<direction.NewNagtiveFloatLit($1)>>
   131      ;
   132  
   133  DoubleQString
   134      : doublequotes_string
   135      ;
   136  SingleQString
   137      : singlequote_string
   138      ;
   139  Int
   140      : number
   141      ;
   142  MappingRef
   143      : argument
   144      ;
   145  Bool
   146      : "true"
   147      | "false"
   148      ;
   149  Float
   150      : float
   151      ;
   152  Nil
   153      : "nil"
   154      | "null"
   155      ;