dreaeql v0.1.0 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

Specs

ast() :: term()

Link to this section Functions

Specs

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

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

Examples

iex(1)> 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"}
}

}, []}