pub fn parse<'a>(input: &'a [Token<'a>]) -> ParseResult<Query<Raw>>Expand description
Parse a sequence of tokens into a Query AST.
This function performs syntactic analysis on the token stream, constructing an abstract syntax tree that represents the structure of the EventQL query.
§Grammar
The parser recognizes the following EventQL grammar:
Query := FROM+ WHERE? GROUP_BY? ORDER_BY? LIMIT? PROJECT
FROM := "FROM" Id "IN" SourceKind
SourceKind := Id | String | "(" Query ")"
WHERE := "WHERE" Expr
GROUP_BY := "GROUP" "BY" Expr
ORDER_BY := "ORDER" "BY" Expr ("ASC" | "DESC")
LIMIT := ("TOP" | "SKIP") Number
PROJECT := "PROJECT" "INTO" Expr
Expr := Binary | Unary | Primary
Primary := Number | String | Bool | Id | Array | Record | Access | App | "(" Expr ")"§Expression Precedence
The parser uses a Pratt parser for expressions with the following precedence (from highest to lowest):
- Unary operators (
+,-,NOT) - Multiplicative (
*,/) - Additive (
+,-) - Comparison (
<,<=,>,>=,==,!=) - Logical (
AND,OR,XOR)