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 type
dreaeql_binary_operator()
Specs
dreaeql_binary_operator() :: DreaeQL.Operators.And.t() | DreaeQL.Operators.Or.t() | DreaeQL.Operators.NotEquals.t() | DreaeQL.Operators.Equals.t() | DreaeQL.Operators.GreaterThan.t() | DreaeQL.Operators.LessThan.t() | DreaeQL.Operators.GreaterThanEquals.t() | DreaeQL.Operators.LessThanEquals.t()
Link to this type
dreaeql_operator()
Specs
dreaeql_operator() :: dreaeql_binary_operator() | dreaeql_unary_operator()
Link to this type
dreaeql_term()
Specs
dreaeql_term() :: DreaeQL.Terms.Identifier.t() | DreaeQL.Terms.LiteralBool.t() | DreaeQL.Terms.LiteralInt.t() | DreaeQL.Terms.LiteralFloat.t() | DreaeQL.Terms.LiteralString.t()
Link to this type
dreaeql_unary_operator()
Specs
dreaeql_unary_operator() :: DreaeQL.Operators.Not.t()
Link to this type
expression()
Specs
expression() :: dreaeql_operator() | dreaeql_term()
Link to this section Functions
Link to this function
parse(string)
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"}
}
}, []}