searchql v1.0.0 SearchQL.BooleanParser

Parses boolean expressions in a SearchQL query.

Summary

Functions

Parses a list of tokens and returns that list with boolean expressions replaced by boolean tokens. Note that boolean parsing is case-insensitive

Functions

parse(tokens)

Parses a list of tokens and returns that list with boolean expressions replaced by boolean tokens. Note that boolean parsing is case-insensitive.

iex> SearchQL.BooleanParser.parse([data: "foo and bar"])
[and: {[data: "foo"], [data: "bar"]}]

This function parses tokens in reverse order, “OR”s before “AND”s. This results in a parsing where “AND” has the higher precedence, and where operator precedence is left-associative:

iex> SearchQL.BooleanParser.parse([data: "foo or bar and baz and qux"])
[or: {
  [data: "foo"],
  [and: {
    [and: {
      [data: "bar"],
      [data: "baz"]}],
    [data: "qux"]}]}]