Condition Grammar

Basic Concepts

  • Condition Primitive

    • Basic conditional judgment unit, which defines the primitive of comparison

    • e.g.

      1. req_host_in(“www.bfe-networks.com|bfe-networks.com”) # host is one of the configured domains
  • Condition Expression

    • Expression using “and/or/not” to connect condition primitive

    • e.g.

      1. req_host_in(“bfe-networks.com”) && req_method_in(“GET”) # domain is bfe-networks.com and HTTP method is "GET"
  • Condition Variable

    • Variable that is defined by Condition Expression

    • e.g.

      1. bfe_host = req_host_in(“bfe-networks.com”) # variable bfe_host is defined by condition expression
  • Advanced Condition Expression

    • Expression using “and/or/not” to connect condition primitive and condition variable

    • In advanced condition expression, condition variable is identified by “$” prefix

    • e.g.

      1. $news_host && req_method_in("GET") # match condition variable and HTTP method is "GET"

Condition Primitive Grammar

  • Basic conditional judgment unit, format is shown as follows:

FuncName( params )

  • Condition primitive like function definition: FuncName is name of condition primitive; params are input parameters
  • Return value type of Condition Primitive is bool
  • Note: All builtin condition primitives

Condition Expression Grammar

Condition Expression grammar is defined as follows:

  • Priority and combination rule of “&&/||/!” is same as them in C language

  • Expression description

    1. Condition Expression(CE) ->
    2. CE && CE
    3. | CE || CE
    4. | ( CE )
    5. | ! CE
    6. | Condition Primitive

Advanced Condition Expression Grammar

Advanced Condition Expression grammar is defined as follows:

  • Priority and combination rule of “&&/||/!” is same as them in C language

  • Expression description

    1. Advanced Condition Expression(ACE) ->
    2. ACE && ACE
    3. | ACE || ACE
    4. | ( ACE)
    5. | ! ACE
    6. | Condition Primitive
    7. | Condition Variable