Sign in

    moonrockz/partiql-syntax/ast does not have a README file

    ParseError

    pub(all) suberror ParseError {
    Unsupported(message~ : String, span~ : Span)
    Syntax(message~ : String, span~ : Span, expected~ : Array[String], found~ : String)
    } derive(Eq,
    Debug
    )

    Why a statement could not be parsed.

    BinaryOp

    pub(all) enum BinaryOp {
    Add
    Sub
    Mul
    Div
    Mod
    Concat
    Eq
    Ne
    Lt
    Le
    Gt
    Ge
    } derive(Eq,
    Debug
    )

    A non-short-circuit arithmetic, concatenation or comparison operator. AND, OR and NOT have separate expression variants.

    Comment

    pub(all) struct Comment {
    kind : CommentKind
    text : String
    span : Span
    } derive(Eq,
    Debug
    )

    A comment as written: -- note (without the line break) or /* note */.

    CommentKind

    pub(all) enum CommentKind {
    Line
    Block
    } derive(Eq,
    Debug
    )

    Whether a preserved source comment uses line or block delimiters.

    Corresponding

    pub(all) enum Corresponding {
    All
    By(Array[Identifier])
    } derive(Eq,
    Debug
    )

    CORRESPONDING [BY (names)] (RFC 0007).

    CurrentKind

    pub(all) enum CurrentKind {
    Date
    Time
    Timestamp
    } derive(Eq,
    Debug
    )

    The SQL clock functions (SQL-92 6.8).

    DataType

    pub(all) enum DataType {
    Null
    Missing
    Bool
    TinyInt
    SmallInt
    Int
    BigInt
    Decimal(Int?, Int?)
    Numeric(Int?, Int?)
    Real
    Double(Int?)
    Char(Int?)
    Varchar(Int?)
    String
    Symbol
    Blob
    Clob
    Date
    Time(Int?, with_tz~ : Bool)
    Timestamp(Int?, with_tz~ : Bool)
    Interval(IntervalQualifier)
    Struct
    Tuple
    List
    Bag
    Sexp
    Any
    Map(DataType, DataType)
    Array(DataType?)
    Custom(Identifier)
    } derive(Eq,
    Debug
    )

    A data type in CAST, IS and type positions.

    DatetimeField

    pub(all) enum DatetimeField {
    Year
    Month
    Day
    Hour
    Minute
    Second
    TimezoneHour
    TimezoneMinute
    } derive(Eq,
    Debug
    )

    A datetime field used by EXTRACT, DATE_ADD, DATE_DIFF and interval qualifiers. Not every field is valid in every position; the parser checks those rules.

    EdgeDirection

    pub(all) enum EdgeDirection {
    Left
    Undirected
    Right
    LeftOrUndirected
    UndirectedOrRight
    LeftOrRight
    Any
    } derive(Eq,
    Debug
    )

    The allowed edge directions, retaining abbreviated and mixed-direction syntax through the surrounding EdgePattern.

    EdgeFiller

    pub(all) struct EdgeFiller {
    variable : Identifier?
    label : Label?
    where_ : Expr?
    span : Span
    } derive(Eq,
    Debug
    )

    [ [name] [: label] [WHERE expr] ]

    EdgePattern

    pub(all) struct EdgePattern {
    direction : EdgeDirection
    filler : EdgeFiller?
    quantifier : Quantifier?
    span : Span
    } derive(Eq,
    Debug
    )

    An edge. filler is None only for the abbreviated form (->), so -> and -[]-> stay different. The span includes the quantifier.

    Expr

    pub(all) struct Expr {
    kind : ExprKind
    span : Span
    } derive(Eq,
    Debug
    )

    An expression kind and its half-open UTF-16 source span. Recovered expressions may contain ExprKind::Error.

    Expr::canonical

    fn Expr::canonical(self : Expr) -> Expr

    The same expression with every span zero and every regular identifier in lower case: regular identifiers compare without case, so two expressions with equal canonical forms mean the same thing (GROUP BY key matching, spec M4c §3.5.2).

    Expr::strip_spans

    fn Expr::strip_spans(self : Expr) -> Expr

    The same expression with every span set to { start: 0, end: 0 }.

    ExprKind

    pub(all) enum ExprKind {
    Lit(Literal)
    VarRef(Identifier, qualified~ : Bool)
    Parameter
    Path(Expr, Array[PathStep])
    Unary(UnaryOp, Expr)
    Binary(BinaryOp, Expr, Expr)
    And(Expr, Expr)
    Or(Expr, Expr)
    Not(Expr)
    BoolTest(Expr, Bool?, negated~ : Bool)
    Like(Expr, pattern~ : Expr, escape~ : Expr?, negated~ : Bool)
    Between(Expr, low~ : Expr, high~ : Expr, negated~ : Bool)
    In(Expr, Expr, negated~ : Bool)
    IsNull(Expr, negated~ : Bool)
    IsMissing(Expr, negated~ : Bool)
    IsType(Expr, DataType, negated~ : Bool)
    Overlaps(Expr, Expr)
    Case(operand~ : Expr?, branches~ : Array[(Expr, Expr)], default~ : Expr?)
    Cast(Expr, DataType)
    Extract(DatetimeField, Expr)
    Trim(spec~ : TrimSpec?, chars~ : Expr?, Expr)
    Substring(Expr, start~ : Expr, length~ : Expr?)
    Position(Expr, Expr)
    Overlay(Expr, placing~ : Expr, from~ : Expr, for_~ : Expr?)
    Coalesce(Array[Expr])
    NullIf(Expr, Expr)
    DateAdd(DatetimeField, Expr, Expr)
    DateDiff(DatetimeField, Expr, Expr)
    CurrentDatetime(CurrentKind, precision~ : Int?)
    Call(Identifier, Array[Expr], quantifier~ : SetQuantifier?)
    CallStar(Identifier)
    List(Array[Expr])
    Bag(Array[Expr])
    Sexp(Array[Expr])
    Struct(Array[(Expr, Expr)])
    Map(Array[(Expr, Expr)])
    Row(Array[Expr])
    Values(Array[Expr])
    Query(Query)
    GraphMatch(GraphMatch)
    Error
    } derive(Eq,
    Debug
    )

    The syntactic form of an expression, with child expressions in source order. Literal source text and syntactic options are retained for printing. Parsing a form does not imply the evaluator supports it.

    FromItem

    pub(all) enum FromItem {
    Scan(FromSource)
    Unpivot(FromSource)
    Join(Join)
    } derive(Eq,
    Debug
    )

    A FROM source, UNPIVOT source or recursive join tree.

    FromSource

    pub(all) struct FromSource {
    lateral : Bool
    expr : Expr
    as_ : Identifier?
    at : Identifier?
    by : Identifier?
    span : Span
    } derive(Eq,
    Debug
    )

    A FROM source with its AS, AT and BY variables.

    GraphMatch

    pub(all) struct GraphMatch {
    graph : Expr
    pattern : GraphPattern
    span : Span
    } derive(Eq,
    Debug
    )

    (graph MATCH pattern), or graph MATCH pattern as a FROM item. The span includes the parentheses of the parenthesized form.

    GraphPattern

    pub(all) struct GraphPattern {
    selector : Selector?
    paths : Array[PathPattern]
    where_ : Expr?
    span : Span
    } derive(Eq,
    Debug
    )

    A selector, one or more path patterns, and an optional postfilter. paths is never empty; where_ is None in the FROM form.

    GroupBy

    pub(all) struct GroupBy {
    keys : GroupKeys
    group_as : Identifier?
    span : Span
    } derive(Eq,
    Debug
    )

    Grouping keys plus an optional GROUP AS variable and the clause span.

    GroupDelimiter

    pub(all) enum GroupDelimiter {
    Paren
    Bracket
    } derive(Eq,
    Debug
    )

    Whether a graph path group was enclosed in parentheses or brackets.

    GroupKey

    pub(all) struct GroupKey {
    expr : Expr
    as_ : Identifier?
    span : Span
    } derive(Eq,
    Debug
    )

    A grouping expression and its optional explicit alias.

    GroupKeys

    pub(all) enum GroupKeys {
    All
    By(Array[GroupKey], partial~ : Bool)
    } derive(Eq,
    Debug
    )

    GROUP ALL or an ordered list of GROUP BY keys, retaining PARTIAL.

    GroupPattern

    pub(all) struct GroupPattern {
    delimiter : GroupDelimiter
    path : PathPattern
    where_ : Expr?
    quantifier : Quantifier?
    span : Span
    } derive(Eq,
    Debug
    )

    ( path [WHERE expr] ) or [ path [WHERE expr] ], with an optional quantifier. The span includes the quantifier.

    Identifier

    pub(all) struct Identifier {
    text : String
    delimited : Bool
    span : Span
    } derive(Eq,
    Debug
    )

    An identifier: a regular name (case-insensitive) or a delimited "name" (case-sensitive).

    IntervalQualifier

    pub(all) struct IntervalQualifier {
    start : DatetimeField
    start_precision : Int?
    end : DatetimeField?
    fractional_precision : Int?
    } derive(Eq,
    Debug
    )

    The leading and optional trailing fields of an INTERVAL type or literal. Optional precisions retain the written leading and fractional digit counts.

    Join

    pub(all) struct Join {
    kind : JoinKind
    form : JoinForm
    left : FromItem
    right : FromItem
    span : Span
    } derive(Eq,
    Debug
    )

    A binary FROM join with its kind, spelling and complete source span.

    JoinForm

    pub(all) enum JoinForm {
    Comma
    Cross
    On(Expr)
    } derive(Eq,
    Debug
    )

    How a join is written: comma, CROSS JOIN or JOIN with an ON expression.

    JoinKind

    pub(all) enum JoinKind {
    Inner
    Left
    Right
    Full
    } derive(Eq,
    Debug
    )

    The requested join kind, including NULL-padding outer joins.

    Label

    pub(all) struct Label {
    kind : LabelKind
    span : Span
    } derive(Eq,
    Debug
    )

    A label expression. The span of a parenthesized label includes the parentheses.

    LabelKind

    pub(all) enum LabelKind {
    Name(Identifier)
    Wildcard
    Not(Label)
    And(Label, Label)
    Or(Label, Label)
    } derive(Eq,
    Debug
    )

    A graph label name, wildcard, negation, conjunction or disjunction.

    LetBinding

    pub(all) struct LetBinding {
    expr : Expr
    name : Identifier
    span : Span
    } derive(Eq,
    Debug
    )

    A LET expression and its required variable name. Bindings are stored in source order so later expressions can refer to earlier variables.

    Literal

    pub(all) enum Literal {
    Null
    Missing
    Bool(Bool)
    Int(String)
    Decimal(String)
    Float(String)
    String(String)
    Ion(String,
    Ion
    )
    Date(String)
    Time(String, precision~ : Int?, with_tz~ : Bool)
    Timestamp(String, precision~ : Int?, with_tz~ : Bool)
    Interval(String, negative~ : Bool, qualifier~ : IntervalQualifier)
    } derive(
    Debug
    )

    A literal. Numbers keep their source text; an Ion literal keeps its text and its parsed value.
    impl Eq for Literal

    NodePattern

    pub(all) struct NodePattern {
    variable : Identifier?
    label : Label?
    where_ : Expr?
    span : Span
    } derive(Eq,
    Debug
    )

    ( [name] [: label] [WHERE expr] )

    NullsOrder

    pub(all) enum NullsOrder {
    First
    Last
    } derive(Eq,
    Debug
    )

    An explicit NULLS FIRST or NULLS LAST choice. Omission stays None.

    PathPart

    pub(all) enum PathPart {
    Node(NodePattern)
    Edge(EdgePattern)
    Group(GroupPattern)
    } derive(Eq,
    Debug
    )

    One node, edge or nested group in a graph path, in traversal order.

    PathPattern

    pub(all) struct PathPattern {
    restrictor : Restrictor?
    variable : Identifier?
    parts : Array[PathPart]
    span : Span
    } derive(Eq,
    Debug
    )

    [restrictor] [name =] part+. parts is never empty.

    PathStep

    pub(all) enum PathStep {
    Field(Identifier)
    FieldString(String, span~ : Span)
    Index(Expr)
    AllElements(Span)
    AllFields(Span)
    } derive(Eq,
    Debug
    )

    One field, index or wildcard step following a path root. Identifiers retain whether lookup is case-sensitive.

    Projection

    pub(all) enum Projection {
    Star(Span)
    Items(Array[SelectItem])
    Value(Expr)
    Pivot(value~ : Expr, key~ : Expr)
    } derive(Eq,
    Debug
    )

    The output form of SELECT or PIVOT. A value projection produces values; a SELECT list or star describes tuple attributes.

    Quantifier

    pub(all) struct Quantifier {
    kind : QuantifierKind
    span : Span
    } derive(Eq,
    Debug
    )

    A graph path repetition bound and its complete source span.

    QuantifierKind

    pub(all) enum QuantifierKind {
    Plus
    Star
    Range(lower~ : Int, upper~ : Int?)
    } derive(Eq,
    Debug
    )

    Bounds are not negative, and upper >= lower.

    Query

    pub(all) struct Query {
    with_ : Array[WithBinding]
    body : QueryBody
    order_by : Array[SortSpec]
    limit : Expr?
    offset : Expr?
    span : Span
    } derive(Eq,
    Debug
    )

    A query: an optional WITH, a body, and the clauses that apply to the whole body.

    Query::strip_spans

    fn Query::strip_spans(self : Query) -> Query

    The same query with every span set to { start: 0, end: 0 }.

    QueryBody

    pub(all) enum QueryBody {
    Select(Select)
    SetOp(SetOp)
    Expr(Expr)
    Table(Array[Identifier])
    } derive(Eq,
    Debug
    )

    The body before ORDER BY, LIMIT and OFFSET: a SELECT/PIVOT, set operation, scalar expression or TABLE reference.

    Recovered

    pub(all) struct Recovered {
    script : Script
    errors : Array[ParseError]
    } derive(Eq,
    Debug
    )

    The result of parse_script_recovering: the partial script and every error, in source order (spec M3d §3).

    Restrictor

    pub(all) enum Restrictor {
    Walk
    Trail
    Acyclic
    Simple
    } derive(Eq,
    Debug
    )

    The path repetition rule: WALK permits repeats, TRAIL forbids repeated edges, ACYCLIC forbids repeated nodes, and SIMPLE permits only the starting node to repeat as the ending node.

    Script

    pub(all) struct Script {
    statements : Array[Statement]
    comments : Array[Comment]
    span : Span
    } derive(Eq,
    Debug
    )

    The statements of a script, and the comments of its source in source order.

    Script::strip_spans

    fn Script::strip_spans(self : Script) -> Script

    The same script with every span set to { start: 0, end: 0 }.

    Select

    pub(all) struct Select {
    quantifier : SetQuantifier?
    projection : Projection
    from : FromItem?
    let_ : Array[LetBinding]
    where_ : Expr?
    group_by : GroupBy?
    having : Expr?
    span : Span
    } derive(Eq,
    Debug
    )

    A SELECT (or PIVOT) block.

    SelectItem

    pub(all) enum SelectItem {
    Expr(Expr, as_~ : Identifier?, span~ : Span)
    AllFields(Expr, span~ : Span)
    } derive(Eq,
    Debug
    )

    An expression with an optional output alias, or an attribute expansion. span covers the item including its alias.

    Selector

    pub(all) struct Selector {
    kind : SelectorKind
    span : Span
    } derive(Eq,
    Debug
    )

    A graph path selector and the span of its selector keywords and count.

    SelectorKind

    pub(all) enum SelectorKind {
    AnyShortest
    AllShortest
    Shortest
    Any(k~ : Int?)
    ShortestK(k~ : Int, group~ : Bool)
    } derive(Eq,
    Debug
    )

    Counts are not negative.

    SetOp

    pub(all) struct SetOp {
    op : SetOpKind
    quantifier : SetQuantifier?
    outer : Bool
    corresponding : Corresponding?
    left : Query
    right : Query
    span : Span
    } derive(Eq,
    Debug
    )

    A binary set operation, retaining its quantifier, OUTER flag and optional CORRESPONDING clause. Each operand is a complete query.

    SetOpKind

    pub(all) enum SetOpKind {
    Union
    Intersect
    Except
    } derive(Eq,
    Debug
    )

    The UNION, INTERSECT and EXCEPT set operations.

    SetQuantifier

    pub(all) enum SetQuantifier {
    All
    Distinct
    } derive(Eq,
    Debug
    )

    An explicit ALL or DISTINCT keyword. A surrounding None means the keyword was omitted; its default depends on the clause.

    SortOrder

    pub(all) enum SortOrder {
    Asc
    Desc
    } derive(Eq,
    Debug
    )

    An explicit ASC or DESC direction. An omitted direction is stored as None.

    SortSpec

    pub(all) struct SortSpec {
    expr : Expr
    order : SortOrder?
    nulls : NullsOrder?
    span : Span
    } derive(Eq,
    Debug
    )

    One ORDER BY expression with optional direction and null-placement keywords.

    Span

    pub(all) struct Span {
    start : Int
    end : Int
    } derive(Eq,
    Debug
    )

    A range of source text: UTF-16 code unit offsets, end exclusive.

    Span::line_column

    fn Span::line_column(self : Span, source : String) -> ((Int, Int), (Int, Int))

    1-based (line, column) of the start and of the end of the span. Lines end at \n (a preceding \r belongs to the line); columns count UTF-16 code units.

    Span::merge

    fn Span::merge(self : Span, other : Span) -> Span

    The smallest span that covers both spans.

    Statement

    pub(all) enum Statement {
    Query(Query)
    Error(Span)
    } derive(Eq,
    Debug
    )

    A parsed statement. M2 parses queries (DQL).

    Statement::strip_spans

    fn Statement::strip_spans(self : Statement) -> Statement

    The same statement with every span set to { start: 0, end: 0 }, so that == compares structure only.

    TrimSpec

    pub(all) enum TrimSpec {
    Both
    Leading
    Trailing
    } derive(Eq,
    Debug
    )

    Which end of a string TRIM removes matching characters from.

    UnaryOp

    pub(all) enum UnaryOp {
    Pos
    Neg
    } derive(Eq,
    Debug
    )

    The unary numeric signs + and -.

    WithBinding

    pub(all) struct WithBinding {
    name : Identifier
    query : Query
    span : Span
    } derive(Eq,
    Debug
    )

    A named query in a WITH clause, with its complete source span.