Appendix C. Expressions BNF

TOKENS
<DEFAULT> SKIP : {
" "
| "\t"
| "\n"
| "\r"
}

<DEFAULT> TOKEN : {
<NULL: "null" | "NULL">
| <TRUE: "true" | "TRUE">
| <FALSE: "false" | "FALSE">
}

<DEFAULT> TOKEN : {
<PROPERTY_PATH: <IDENTIFIER> ("." <IDENTIFIER>)*>
}

<DEFAULT> TOKEN : {
<IDENTIFIER: <LETTER> (<LETTER> | <DIGIT>)* (["+"])?>
| <#LETTER: ["_","a"-"z","A"-"Z"]>
| <#DIGIT: ["0"-"9"]>
}

/** 
 * Quoted Strings, whose object value is stored in the token manager's
 * "literalValue" field. Both single and double qoutes are allowed 
 */<DEFAULT> MORE : {
"\'" : WithinSingleQuoteLiteral
| "\"" : WithinDoubleQuoteLiteral
}

<WithinSingleQuoteLiteral> MORE : {
<ESC: "\\" (["n","r","t","b","f","\\","\'","`","\""] | (["0"-"3"])? ["0"-"7"] (["0"-"7"])?)> : {
| <~["\'","\\"]> : {
}

<WithinSingleQuoteLiteral> TOKEN : {
<SINGLE_QUOTED_STRING: "\'"> : DEFAULT
}

<WithinDoubleQuoteLiteral> MORE : {
<STRING_ESC: <ESC>> : {
| <~["\"","\\"]> : {
}

<WithinDoubleQuoteLiteral> TOKEN : {
<DOUBLE_QUOTED_STRING: "\""> : DEFAULT
}

/**
 * Integer or real Numeric literal, whose object value is stored in the token manager's
 * "literalValue" field.
 */<DEFAULT> TOKEN : {
<INT_LITERAL: ("0" (["0"-"7"])* | ["1"-"9"] (["0"-"9"])* | "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+)
        (["l","L","h","H"])?> : {
| <FLOAT_LITERAL: <DEC_FLT> (<EXPONENT>)? (<FLT_SUFF>)? | <DEC_DIGITS> <EXPONENT> (<FLT_SUFF>)?
| <DEC_DIGITS> <FLT_SUFF>> : {
| <#DEC_FLT: (["0"-"9"])+ "." (["0"-"9"])* | "." (["0"-"9"])+>
| <#DEC_DIGITS: (["0"-"9"])+>
| <#EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+>
| <#FLT_SUFF: ["d","D","f","F","b","B"]>
}

NON-TERMINALS
    expression    :=    orCondition <EOF>
    orCondition    :=    andCondition ( "or" andCondition )*
    andCondition    :=    notCondition ( "and" notCondition )*
    notCondition    :=    ( "not" | "!" ) simpleCondition
        |    simpleCondition
    simpleCondition    :=    <TRUE>
        |    <FALSE>
        |    scalarConditionExpression
             ( simpleNotCondition 
               | ( "=" | "==" ) scalarExpression 
               | ( "!=" | "<>" ) scalarExpression 
               | "<=" scalarExpression 
               | "<" scalarExpression | ">" scalarExpression 
               | ">=" scalarExpression 
               | "like" scalarExpression 
               | "likeIgnoreCase" scalarExpression 
               | "in" ( namedParameter | "(" scalarCommaList ")" ) 
               | "between" scalarExpression "and" scalarExpression 
             )?
    simpleNotCondition    :=    ( "not" | "!" )
             ( "like" scalarExpression 
               | "likeIgnoreCase" scalarExpression 
               | "in" ( namedParameter | "(" scalarCommaList ")" ) 
               | "between" scalarExpression "and" scalarExpression 
             )
    scalarCommaList    :=    ( scalarConstExpression ( "," scalarConstExpression )* )
    scalarConditionExpression    :=    scalarNumericExpression
        |    <SINGLE_QUOTED_STRING>
        |    <DOUBLE_QUOTED_STRING>
        |    <NULL>
    scalarExpression    :=    scalarConditionExpression
        |    <TRUE>
        |    <FALSE>
    scalarConstExpression    :=    <SINGLE_QUOTED_STRING>
        |    <DOUBLE_QUOTED_STRING>
        |    namedParameter
        |    <INT_LITERAL>
        |    <FLOAT_LITERAL>
        |    <TRUE>
        |    <FALSE>
    scalarNumericExpression    :=    multiplySubtractExp
             ( "+" multiplySubtractExp | "-" multiplySubtractExp )*
    multiplySubtractExp    :=    numericTerm ( "*" numericTerm | "/" numericTerm )*
    numericTerm    :=    ( "+" )? numericPrimary
        |    "-" numericPrimary
    numericPrimary    :=    "(" orCondition ")"
        |    pathExpression
        |    namedParameter
        |    <INT_LITERAL>
        |    <FLOAT_LITERAL>
    namedParameter    :=    "$" <PROPERTY_PATH>
    pathExpression    :=    ( <PROPERTY_PATH>
                            | "obj:" <PROPERTY_PATH>  
                            | "db:" <PROPERTY_PATH>  
                            | "enum:" <PROPERTY_PATH>  )