Class: ConditionParser

ConditionParser

A recursive decent parser for a SQL condition (WHERE or ON). This parser takes in a set of tokens, as generated by the ConditionLexer.parse method, and makes sure that the condition is valid. If the condition sentence does not match the condition grammer, an exception is raised. Otherwise, a parse tree is created.

Constructor

new ConditionParser()

Source:

Methods

parse(tokens) → {Object}

Parse the tokens (as an object) and return a parse tree. The condition must follow the following grammar.
  <condition>                ::= "{" <comparison> | <null-comparison> | <in-comparison> | <logical-condition> "}"
  <comparison>               ::= <comparison-operator> ":" "{" <column> ":" <value> "}"
  <null-comparison>          ::= <null-comparison-operator> ":" "{" <column> ":" <nullable> "}"
  <in-comparison>            ::= <in-comparison-operator> ":" "{" <column> ":" "[" <value> {"," <value>} "]" "}"
  <logical-condition>        ::= <boolean-operator> ":" "[" <condition> {"," <condition>} "]"
  <comparison-operator>      ::= "$eq" | "$neq" | "$lt" | "$lte" | "$gt" | "$gte" | "$like" | "$notlike"
  <in-comparison-operator>   ::= "$in" | "$notIn"
  <null-comparison-operator> ::= "$is" | "$isnt"
  <boolean-operator>         ::= "$and" | "$or"
  <nullable>                 ::= null | <parameter>
  <value>                    ::= <parameter> | <column> | <number> | null
  <column>                   ::= <string>
  <parameter>                ::= :<string>
Parameters:
Name Type Description
tokens Array.<Object> An array of tokens, as created by the ConditionLexer.parse method.
Source:
Returns:
A parse tree. Each node in the tree has a token and children nodes.
Type
Object