parse
public Predicate parse(Token[] tokens)
throws InvalidQueryException
Generate a Predicate instance from an array of tokens.
Each input token contains a type and a value.
Based on the token type and location, the tokens are first translated into a list of
expressions, both relational and logical. These expressions are then merged into a tree
of expressions with a single root following operator precedence and explicit grouping rules.
Depending on the query, this merging of expressions into a tree of expressions may occur in
several passes, one pass per level of precedence starting at the highest level of precedence.
The predicate is built by traversing the expression tree in-order with each node expressing itself
as a predicate.
- Parameters:
tokens
- an array of tokens which represent the query,
each token contains type and value information
- Returns:
- a new predicate instance based on the supplied tokens
- Throws:
InvalidQueryException
- if unable to parse the tokens and produce a predicate