ast

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package ast defines the abstract syntax tree types for AQL (Aha Query Language).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateFunc

type AggregateFunc struct {
	Func     AggregateType
	Field    *FieldRef // nil for COUNT(*)
	Distinct bool      // COUNT(DISTINCT field)
	Pos      Position
}

AggregateFunc represents an aggregate function call.

func (AggregateFunc) String

func (a AggregateFunc) String() string

String returns the string representation of the aggregate function.

type AggregateType

type AggregateType string

AggregateType represents the type of aggregate function.

const (
	AggCount AggregateType = "COUNT"
	AggSum   AggregateType = "SUM"
	AggAvg   AggregateType = "AVG"
	AggMin   AggregateType = "MIN"
	AggMax   AggregateType = "MAX"
)

Aggregate function types.

type Assignment

type Assignment struct {
	Field string
	Value Value
	Pos   Position
}

Assignment represents a field = value assignment in UPDATE.

type BinaryExpr

type BinaryExpr struct {
	Left  Expr
	Op    LogicalOp
	Right Expr
	// contains filtered or unexported fields
}

BinaryExpr represents a binary logical expression (AND/OR).

func NewBinaryExpr

func NewBinaryExpr(left Expr, op LogicalOp, right Expr, pos Position) *BinaryExpr

NewBinaryExpr creates a new binary expression.

func (*BinaryExpr) Pos

func (e *BinaryExpr) Pos() Position

func (*BinaryExpr) String

func (e *BinaryExpr) String() string

type CompareExpr

type CompareExpr struct {
	Field FieldRef
	Op    CompareOp
	Value *Value // nil for IS NULL/IS NOT NULL
	// contains filtered or unexported fields
}

CompareExpr represents a comparison expression.

func NewCompareExpr

func NewCompareExpr(field FieldRef, op CompareOp, value *Value, pos Position) *CompareExpr

NewCompareExpr creates a new comparison expression.

func (*CompareExpr) Pos

func (e *CompareExpr) Pos() Position

func (*CompareExpr) String

func (e *CompareExpr) String() string

type CompareOp

type CompareOp string

CompareOp represents a comparison operator.

const (
	OpEQ        CompareOp = "="
	OpNE        CompareOp = "!="
	OpLT        CompareOp = "<"
	OpLE        CompareOp = "<="
	OpGT        CompareOp = ">"
	OpGE        CompareOp = ">="
	OpIN        CompareOp = "IN"
	OpNotIn     CompareOp = "NOT IN"
	OpContains  CompareOp = "CONTAINS"
	OpLike      CompareOp = "LIKE"
	OpIsNull    CompareOp = "IS NULL"
	OpIsNotNull CompareOp = "IS NOT NULL"
)

Comparison operators.

type DeleteStatement

type DeleteStatement struct {
	Entity EntityType
	Where  *WhereClause
	Pos    Position
}

DeleteStatement represents a DELETE statement.

type EntityType

type EntityType string

EntityType represents the type of Aha entity being queried.

const (
	EntityComments     EntityType = "comments"
	EntityEpics        EntityType = "epics"
	EntityFeatures     EntityType = "features"
	EntityGoals        EntityType = "goals"
	EntityIdeas        EntityType = "ideas"
	EntityReleases     EntityType = "releases"
	EntityRequirements EntityType = "requirements"
	EntityInitiatives  EntityType = "initiatives"
	EntityProducts     EntityType = "products"
	EntityTags         EntityType = "tags"
	EntityUsers        EntityType = "users"
)

Valid entity types.

func (EntityType) IsValid

func (e EntityType) IsValid() bool

IsValid returns true if the entity type is valid.

type Expr

type Expr interface {
	Pos() Position
	String() string
	// contains filtered or unexported methods
}

Expr is the interface for all expression nodes.

type FieldRef

type FieldRef struct {
	Name      string
	Qualifier string // optional entity qualifier (e.g., "features.name")
	Pos       Position
}

FieldRef references a field, possibly with a table/entity qualifier.

func (FieldRef) String

func (f FieldRef) String() string

String returns the string representation of the field reference.

type FromClause

type FromClause struct {
	Entity EntityType
	Alias  string // optional table alias (e.g., FROM features AS f)
	Pos    Position
}

FromClause specifies the entity type to query.

type FunctionExpr

type FunctionExpr struct {
	Name string
	Args []Expr
	// contains filtered or unexported fields
}

FunctionExpr represents a function call in an expression.

func NewFunctionExpr

func NewFunctionExpr(name string, args []Expr, pos Position) *FunctionExpr

NewFunctionExpr creates a new function expression.

func (*FunctionExpr) Pos

func (e *FunctionExpr) Pos() Position

func (*FunctionExpr) String

func (e *FunctionExpr) String() string

type GroupByClause

type GroupByClause struct {
	Fields []FieldRef
	Pos    Position
}

GroupByClause specifies the grouping fields.

type HavingClause

type HavingClause struct {
	Expr Expr
	Pos  Position
}

HavingClause contains the filter expression for grouped results.

type InsertStatement

type InsertStatement struct {
	Entity  EntityType
	Columns []string
	Values  []Value
	Pos     Position
}

InsertStatement represents an INSERT statement.

type JoinClause

type JoinClause struct {
	Type      JoinType
	Entity    EntityType
	Alias     string // optional table alias
	Condition Expr   // ON condition
	Pos       Position
}

JoinClause represents a JOIN between entities.

type JoinType

type JoinType string

JoinType represents the type of join.

const (
	JoinInner JoinType = "JOIN"
	JoinLeft  JoinType = "LEFT JOIN"
	JoinRight JoinType = "RIGHT JOIN"
)

Join types.

type LiteralExpr

type LiteralExpr struct {
	Value Value
	// contains filtered or unexported fields
}

LiteralExpr represents a literal value expression.

func NewLiteralExpr

func NewLiteralExpr(value Value, pos Position) *LiteralExpr

NewLiteralExpr creates a new literal expression.

func (*LiteralExpr) Pos

func (e *LiteralExpr) Pos() Position

func (*LiteralExpr) String

func (e *LiteralExpr) String() string

type LogicalOp

type LogicalOp string

LogicalOp represents a logical operator.

const (
	OpAnd LogicalOp = "AND"
	OpOr  LogicalOp = "OR"
)

Logical operators.

type NotExpr

type NotExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

NotExpr represents a NOT expression.

func NewNotExpr

func NewNotExpr(expr Expr, pos Position) *NotExpr

NewNotExpr creates a new NOT expression.

func (*NotExpr) Pos

func (e *NotExpr) Pos() Position

func (*NotExpr) String

func (e *NotExpr) String() string

type OrderByClause

type OrderByClause struct {
	Field FieldRef
	Dir   SortDirection
	Pos   Position
}

OrderByClause specifies the sort order.

type ParenExpr

type ParenExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

ParenExpr represents a parenthesized expression.

func NewParenExpr

func NewParenExpr(expr Expr, pos Position) *ParenExpr

NewParenExpr creates a new parenthesized expression.

func (*ParenExpr) Pos

func (e *ParenExpr) Pos() Position

func (*ParenExpr) String

func (e *ParenExpr) String() string

type Position

type Position struct {
	Offset int // byte offset
	Line   int // 1-based line number
	Column int // 1-based column number
}

Position represents a position in the source query.

type Query

type Query struct {
	Select  *SelectClause
	From    *FromClause
	Joins   []*JoinClause
	Where   *WhereClause
	GroupBy *GroupByClause
	Having  *HavingClause
	OrderBy *OrderByClause
	Limit   *int
}

Query represents a complete AQL query.

func (*Query) HasAggregates

func (q *Query) HasAggregates() bool

HasAggregates returns true if the query contains aggregate functions.

type SelectClause

type SelectClause struct {
	Items    []SelectItem
	Distinct bool
	Pos      Position
}

SelectClause specifies which fields or expressions to return.

type SelectItem

type SelectItem struct {
	// Field is set for simple field references
	Field *FieldRef
	// Aggregate is set for aggregate functions
	Aggregate *AggregateFunc
	// Star is true for SELECT *
	Star bool
	// Alias is the optional AS alias
	Alias string
	Pos   Position
}

SelectItem represents a single item in a SELECT clause.

func (SelectItem) OutputName

func (s SelectItem) OutputName() string

OutputName returns the name to use for this item in results.

func (SelectItem) String

func (s SelectItem) String() string

String returns the string representation of the select item.

type SortDirection

type SortDirection string

SortDirection specifies the sort order.

const (
	SortAsc  SortDirection = "ASC"
	SortDesc SortDirection = "DESC"
)

Sort directions.

type Statement

type Statement interface {
	// contains filtered or unexported methods
}

Statement represents any AQL statement (query or mutation).

type SubqueryExpr

type SubqueryExpr struct {
	Query *Query
	// contains filtered or unexported fields
}

SubqueryExpr represents a subquery expression (a nested query).

func NewSubqueryExpr

func NewSubqueryExpr(query *Query, pos Position) *SubqueryExpr

NewSubqueryExpr creates a new subquery expression.

func (*SubqueryExpr) Pos

func (e *SubqueryExpr) Pos() Position

func (*SubqueryExpr) String

func (e *SubqueryExpr) String() string

type UpdateStatement

type UpdateStatement struct {
	Entity      EntityType
	Assignments []Assignment
	Where       *WhereClause
	Pos         Position
}

UpdateStatement represents an UPDATE statement.

type Value

type Value struct {
	Type ValueType
	Raw  string // original string representation

	// Typed values (only one is set based on Type)
	String   string
	Int      int64
	Float    float64
	Bool     bool
	Time     time.Time
	Duration time.Duration
	Strings  []string // for IN clauses
	Subquery *Query   // for subquery expressions
}

Value represents a literal value in an expression.

type ValueType

type ValueType int

ValueType represents the type of a value.

const (
	ValueTypeString ValueType = iota
	ValueTypeInt
	ValueTypeFloat
	ValueTypeBool
	ValueTypeTime
	ValueTypeDuration
	ValueTypeNull
	ValueTypeStringList
	ValueTypeSubquery // for scalar or list subqueries
)

Value types.

func (ValueType) String

func (v ValueType) String() string

String returns the string representation of the value type.

type WhereClause

type WhereClause struct {
	Expr Expr
	Pos  Position
}

WhereClause contains the filter expression.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL