dreaeql v0.2.1 DreaeQL

A library for parsing a simple query language into an abstract syntax tree.

Link to this section Summary

Functions

Parses a string into a DreaeQL AST. Returns a tuple containing the AST and any unused tokens, if any.

Link to this section Types

Link to this section Functions

Specs

parse(String.t()) :: {expression(), list()}

Parses a string into a DreaeQL AST. Returns a tuple containing the AST and any unused tokens, if any.

Examples

  iex> DreaeQL.parse("foo = 123 and bar = \"456\"")
  {%DreaeQL.Operators.And{
    left_side: %DreaeQL.Operators.Equals{
      left_side: %DreaeQL.Terms.Identifier{ident: "foo", term: :ident},
      operator: :binary,
      right_side: %DreaeQL.Terms.LiteralInt{term: :int, value: 123}
    },
    operator: :binary,
    right_side: %DreaeQL.Operators.Equals{
      left_side: %DreaeQL.Terms.Identifier{ident: "bar", term: :ident},
      operator: :binary,
      right_side: %DreaeQL.Terms.LiteralString{term: :string, value: "456"}
    }
  }, []}