parser

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AttrAsync                = ast.AttrAsync
	AttrAudit                = ast.AttrAudit
	AttrCache                = ast.AttrCache
	AttrDeprecated           = ast.AttrDeprecated
	AttrDescription          = ast.AttrDescription
	AttrDestructive          = ast.AttrDestructive
	AttrDisabled             = ast.AttrDisabled
	AttrEnabled              = ast.AttrEnabled
	AttrExecutionTime        = ast.AttrExecutionTime
	AttrExecutor             = ast.AttrExecutor
	AttrFilter               = ast.AttrFilter
	AttrHandler              = ast.AttrHandler
	AttrIdempotent           = ast.AttrIdempotent
	AttrInternal             = ast.AttrInternal
	AttrPermission           = ast.AttrPermission
	AttrPublic               = ast.AttrPublic
	AttrRateLimit            = ast.AttrRateLimit
	AttrRequiresConfirmation = ast.AttrRequiresConfirmation
	AttrRetry                = ast.AttrRetry
	AttrRole                 = ast.AttrRole
	AttrSchedule             = ast.AttrSchedule
	AttrUse                  = ast.AttrUse
	AttrUseSpec              = ast.AttrUseSpec
	AttrUseTrait             = ast.AttrUseTrait
	AttrUseQuery             = ast.AttrUseQuery
	AttrUseMutation          = ast.AttrUseMutation
	AttrUseAutomation        = ast.AttrUseAutomation
	AttrUseLogic             = ast.AttrUseLogic
	AttrUseTool              = ast.AttrUseTool
	AttrUsePrompt            = ast.AttrUsePrompt
	AttrUseProvider          = ast.AttrUseProvider
	AttrUseBuiltin           = ast.AttrUseBuiltin
	AttrTimeout              = ast.AttrTimeout
	AttrTrigger              = ast.AttrTrigger
	AttrVersion              = ast.AttrVersion
	FunctionTypeAutomation   = ast.FunctionTypeAutomation
	FunctionTypeBuiltin      = ast.FunctionTypeBuiltin
	FunctionTypeLogic        = ast.FunctionTypeLogic
	FunctionTypeMutation     = ast.FunctionTypeMutation
	FunctionTypePolicy       = ast.FunctionTypePolicy
	FunctionTypePrompt       = ast.FunctionTypePrompt
	FunctionTypeProvider     = ast.FunctionTypeProvider
	FunctionTypeQuery        = ast.FunctionTypeQuery
	FunctionTypeShape        = ast.FunctionTypeShape
	FunctionTypeSpec         = ast.FunctionTypeSpec
	FunctionTypeTool         = ast.FunctionTypeTool
	LogicalAnd               = ast.LogicalAnd
	LogicalOr                = ast.LogicalOr
	OpEq                     = ast.OpEq
	OpGe                     = ast.OpGe
	OpGt                     = ast.OpGt
	OpHas                    = ast.OpHas
	OpIn                     = ast.OpIn
	OpLe                     = ast.OpLe
	OpLt                     = ast.OpLt
	OpMissing                = ast.OpMissing
	OpNe                     = ast.OpNe
	OpNotMissing             = ast.OpNotMissing
	OpOut                    = ast.OpOut
	ReceiverAutomation       = ast.ReceiverAutomation
	ReceiverBuiltin          = ast.ReceiverBuiltin
	ReceiverLogic            = ast.ReceiverLogic
	ReceiverMutation         = ast.ReceiverMutation
	ReceiverPolicy           = ast.ReceiverPolicy
	ReceiverPrompt           = ast.ReceiverPrompt
	ReceiverProvider         = ast.ReceiverProvider
	ReceiverQuery            = ast.ReceiverQuery
	ReceiverShape            = ast.ReceiverShape
	ReceiverSpec             = ast.ReceiverSpec
	ReceiverTool             = ast.ReceiverTool
	RelAliasOf               = ast.RelAliasOf
	RelChildOf               = ast.RelChildOf
	RelContains              = ast.RelContains
	RelCreatedBy             = ast.RelCreatedBy
	RelEquals                = ast.RelEquals
	RelIds                   = ast.RelIds
	RelInteractsWith         = ast.RelInteractsWith
	RelOwns                  = ast.RelOwns
	RelParentOf              = ast.RelParentOf
	SortAsc                  = ast.SortAsc
	SortDesc                 = ast.SortDesc
	StepTypeAutomation       = ast.StepTypeAutomation
	StepTypeForEach          = ast.StepTypeForEach
	StepTypeFunction         = ast.StepTypeFunction
	StepTypeMutation         = ast.StepTypeMutation
	StepTypeParallel         = ast.StepTypeParallel
	StepTypeQuery            = ast.StepTypeQuery
	StepTypeSwitch           = ast.StepTypeSwitch

	MutationKindInsert = ast.MutationKindInsert
	MutationKindUpdate = ast.MutationKindUpdate
)

Enum / typed-string constants re-exported as vars (Go const aliases do not carry through simple `=` redeclaration; using var is idiomatic for this compatibility shim and the values are immutable in practice).

View Source
var (
	ErrEmptyInput          = errors.New("empty input")
	ErrInvalidSyntax       = errors.New("invalid syntax")
	ErrUnexpectedToken     = errors.New("unexpected token")
	ErrUnexpectedEOF       = errors.New("unexpected end of input")
	ErrUnterminatedString  = errors.New("unterminated string")
	ErrInvalidNumber       = errors.New("invalid number")
	ErrInvalidOperator     = errors.New("invalid operator")
	ErrMissingArgument     = errors.New("missing argument")
	ErrInvalidArgument     = errors.New("invalid argument")
	ErrDuplicateDefinition = errors.New("duplicate definition")
)

Parsing errors

Functions

func LooksLikeFileTopArgs

func LooksLikeFileTopArgs(source string) bool

LooksLikeFileTopArgs reports whether the source declares a file-level `args { ... }` block (outside any struct construct).

func LooksLikeLegacyAutomation

func LooksLikeLegacyAutomation(source string) bool

LooksLikeLegacyAutomation reports whether the source declares the retired procedural `func (Automation) NAME(...)` form. Author files containing this form are rejected at parse time -- the struct form is canonical.

func LooksLikeNonProcedural

func LooksLikeNonProcedural(source string) bool

LooksLikeNonProcedural reports whether the source contains any stripable non-procedural struct-form construct.

func LooksLikeStructAutomation

func LooksLikeStructAutomation(source string) bool

LooksLikeStructAutomation reports whether the source declares a struct-form automation.

func LooksLikeStructLogic

func LooksLikeStructLogic(source string) bool

LooksLikeStructLogic reports whether the source declares a struct-form logic block.

func LooksLikeStructMutation

func LooksLikeStructMutation(source string) bool

LooksLikeStructMutation reports whether the source declares a struct-form mutation.

func LooksLikeStructQuery

func LooksLikeStructQuery(source string) bool

LooksLikeStructQuery reports whether the source declares a struct-form query.

func NormaliseAll

func NormaliseAll(source string) (string, error)

NormaliseAll runs every struct-form rewriter in sequence: query, mutation, logic, automation, file-top args. Each stage is a no-op when the source doesn't match its detector. Errors from any stage are wrapped with the stage name and returned immediately.

func NormaliseAutomationSource

func NormaliseAutomationSource(source string) (string, error)

NormaliseAutomationSource rewrites every `automation NAME { step <name> { ... } }` block to a procedural function whose body assigns each step's call to a named variable.

func NormaliseFileTopArgs

func NormaliseFileTopArgs(source string) (string, error)

NormaliseFileTopArgs is a no-op. It once translated `args.X` references to `ctx.X` inside the function body that followed each file-top `args { ... }` block; the engine parser learned `args.X` natively in F.3 of the ctx-envelope purge. The function stays in the NormaliseAll chain only to preserve the structural-detection callsite shape (LooksLikeFileTopArgs gates whether the chain runs) without churning callers.

func NormaliseLogicSource

func NormaliseLogicSource(source string) (string, error)

NormaliseLogicSource rewrites every `logic NAME { ... }` block to the procedural `func (Logic) NAME(_ any) (any, error) { ... }` form. The body keeps its own trailing `return <expr>`; the rewriter no longer appends `return ctx, nil`.

func NormaliseMutationSource

func NormaliseMutationSource(source string) (string, error)

NormaliseMutationSource rewrites every `mutation NAME { ... }` block to the procedural form.

func NormaliseQuerySource

func NormaliseQuerySource(source string) (string, error)

NormaliseQuerySource rewrites every `query NAME { ... }` block in the source to the procedural `func (Query) NAME(_ any) (any, error) { return <expr>, nil }` form.

func ParsePolicyDecl

func ParsePolicyDecl(source string) (*ast.PolicyDecl, error)

ParsePolicyDecl tokenises a single `policy NAME { }` slice (with its leading attribute set) and returns the typed *ast.PolicyDecl. The caller -- typically the unified policy loader -- has already sliced one policy out of a multi-construct `.memql` file via ExtractKeywordSlices, so the input here is expected to contain exactly one policy declaration.

Returns an error when the slice's syntax is malformed or doesn't produce a policy node.

func ParseProviderDecl

func ParseProviderDecl(source string) (*ast.ProviderDecl, error)

ParseProviderDecl tokenises a single `provider NAME { ... }` slice (with its leading attribute set) and returns the typed *ast.ProviderDecl. The caller -- typically the unified provider loader -- already sliced one provider out of a multi-construct `.memql` file via ExtractKeywordSlices, so the input here is expected to contain exactly one provider declaration.

Returns an error when the slice's syntax is malformed or doesn't produce a provider node.

func ParseSeedDecl

func ParseSeedDecl(source string) (*ast.SeedDecl, error)

ParseSeedDecl tokenises a single `seed NAME { ... }` slice (with its leading attribute set + any preserved file-top `use ...` preamble) and returns the typed *ast.SeedDecl. The caller -- typically the unified seed loader -- pre-pends the file-top preamble onto each slice so signature-bound concept names resolve against the same Form B imports the file declares once at the top.

Returns an error when the slice's syntax is malformed or doesn't produce a seed node. memql#335 (sub-epic #329 / Stage 1C of #310).

func ParseSpecDecl

func ParseSpecDecl(source string) (*ast.SpecDecl, error)

ParseSpecDecl tokenises a single `spec NAME { ... }` or `trait NAME { ... }` slice (with its leading attribute set) and returns the typed *ast.SpecDecl. The caller -- typically the unified spec loader -- already sliced one declaration out of a multi-construct `.memql` file via ExtractKeywordSlices, so the input here is expected to contain exactly one spec or trait.

Returns an error when the slice's syntax is malformed or doesn't produce a spec/trait node.

memql#334 (sub-epic #329 / #310 Stage 1C).

func ParseToolDecl

func ParseToolDecl(source string) (*ast.ToolDecl, error)

ParseToolDecl tokenises a single `tool NAME { ... }` slice (with its leading attribute set) and returns the typed *ast.ToolDecl. The caller -- typically the unified tool loader -- has already sliced one tool out of a multi-construct `.memql` file via ExtractKeywordSlices, so the input here is expected to contain exactly one tool declaration.

Returns an error when the slice's syntax is malformed or doesn't produce a tool node.

func RejectLegacyProceduralAuthorForm

func RejectLegacyProceduralAuthorForm(source string) error

RejectLegacyProceduralAuthorForm returns an error when the source contains author-written procedural form (`func (Receiver) name(ctx any) ...`) for any of the 12 retired receiver names. Called by the DSL load-time entry point (memql#303); see the comment on legacyProceduralAuthorForm for why this isn't wired into NormaliseAll directly.

func StripNonProceduralBlocks

func StripNonProceduralBlocks(source string) string

StripNonProceduralBlocks finds every struct-form construct declaration that's not procedural (`func (X) name`) and removes the block from the source, replacing it with a single-line comment of the form `// <stripped: kind name>`. The comment is placed at the original block header position so downstream error messages with line numbers still point at a reasonable location.

Preamble attribute lines (@-prefixed) immediately above the stripped block are also removed -- they're decorators on the stripped declaration. This avoids leaving orphan @-attributes hanging over the next surviving declaration.

Pass-through if the source contains none of the targeted constructs.

Types

type AddDurationExpr

type AddDurationExpr = ast.AddDurationExpr

Struct / named-type aliases for every AST type.

type AndExpr

type AndExpr = ast.AndExpr

Struct / named-type aliases for every AST type.

type ArgRefExpr

type ArgRefExpr = ast.ArgRefExpr

Struct / named-type aliases for every AST type.

type ArgsField

type ArgsField = ast.ArgsField

Struct / named-type aliases for every AST type.

type ArgsSchema

type ArgsSchema = ast.ArgsSchema

Struct / named-type aliases for every AST type.

type AssignStmt

type AssignStmt = ast.AssignStmt

Struct / named-type aliases for every AST type.

type Attribute

type Attribute = ast.Attribute

Struct / named-type aliases for every AST type.

type AttributeMap

type AttributeMap = ast.AttributeMap

Struct / named-type aliases for every AST type.

type AutomationDef

type AutomationDef = ast.AutomationDef

Struct / named-type aliases for every AST type.

type BreakStmt

type BreakStmt = ast.BreakStmt

Struct / named-type aliases for every AST type.

type BuiltinDecl

type BuiltinDecl = ast.BuiltinDecl

Struct / named-type aliases for every AST type.

func ParseBuiltinDecl

func ParseBuiltinDecl(source string) (*BuiltinDecl, error)

ParseBuiltinDecl tokenises the given source and parses it as a single struct-form builtin declaration. Convenience wrapper around ParseFile for the unified-kinds loader's LoadUnifiedBuiltins flow. Mirrors ParseShapeDecl on the error surface.

memql#318 (sub-epic #309 / #306 child C).

type BuiltinField

type BuiltinField = ast.BuiltinField

Struct / named-type aliases for every AST type.

type BuiltinFunctionExpr

type BuiltinFunctionExpr = ast.BuiltinFunctionExpr

Struct / named-type aliases for every AST type.

type CallerRefExpr

type CallerRefExpr = ast.CallerRefExpr

Struct / named-type aliases for every AST type.

type CanonicalIdExpr

type CanonicalIdExpr = ast.CanonicalIdExpr

Struct / named-type aliases for every AST type.

type CaseClause

type CaseClause = ast.CaseClause

Struct / named-type aliases for every AST type.

type CoalesceExpr

type CoalesceExpr = ast.CoalesceExpr

Struct / named-type aliases for every AST type.

type ComparisonExpr

type ComparisonExpr = ast.ComparisonExpr

Struct / named-type aliases for every AST type.

type ComparisonOperator

type ComparisonOperator = ast.ComparisonOperator

Struct / named-type aliases for every AST type.

type ConcatExpr

type ConcatExpr = ast.ConcatExpr

Struct / named-type aliases for every AST type.

type ConceptDecl

type ConceptDecl = ast.ConceptDecl

Struct / named-type aliases for every AST type.

type CondExpr

type CondExpr = ast.CondExpr

Struct / named-type aliases for every AST type.

type ConditionalFilterExpr

type ConditionalFilterExpr = ast.ConditionalFilterExpr

Struct / named-type aliases for every AST type.

type ContainsExpr

type ContainsExpr = ast.ContainsExpr

Struct / named-type aliases for every AST type.

type ContinueStmt

type ContinueStmt = ast.ContinueStmt

Struct / named-type aliases for every AST type.

type DayOfMonthExpr

type DayOfMonthExpr = ast.DayOfMonthExpr

Struct / named-type aliases for every AST type.

type DaysBetweenExpr

type DaysBetweenExpr = ast.DaysBetweenExpr

Struct / named-type aliases for every AST type.

type DepthExpr

type DepthExpr = ast.DepthExpr

Struct / named-type aliases for every AST type.

type DotAccessExpr

type DotAccessExpr = ast.DotAccessExpr

Struct / named-type aliases for every AST type.

type EqExpr

type EqExpr = ast.EqExpr

Struct / named-type aliases for every AST type.

type ErrorExpr

type ErrorExpr = ast.ErrorExpr

Struct / named-type aliases for every AST type.

type ErrorRefExpr

type ErrorRefExpr = ast.ErrorRefExpr

Struct / named-type aliases for every AST type.

type EventRefExpr

type EventRefExpr = ast.EventRefExpr

Struct / named-type aliases for every AST type.

type ExpressionNode

type ExpressionNode = ast.ExpressionNode

Interface aliases (require Go 1.24+; we are on 1.26.1).

func ParseExpression

func ParseExpression(source string) (ExpressionNode, error)

ParseExpression parses a single MemQL expression from source text and returns the parsed AST node. Public entry point exposed for dedicated per-construct parsers (e.g. component/memql/spec_parser.go) that build their own grammar around the canonical expression parser without going through a synthetic function wrapper.

The source must contain exactly one expression. Trailing tokens after the expression (other than EOF / ; / a closing brace that the caller consumed prior to invocation) produce a parse error.

type FieldRefExpr

type FieldRefExpr = ast.FieldRefExpr

Struct / named-type aliases for every AST type.

type FieldReference

type FieldReference = ast.FieldReference

Struct / named-type aliases for every AST type.

type File

type File = ast.File

Struct / named-type aliases for every AST type.

func ExtractImports

func ExtractImports(source string) (*File, error)

ExtractImports tokenises the source and returns a *File carrying just the parsed `import (...)` block(s). Returns an empty File (no Imports, no Definitions) when the file has no imports. Returns an error only for lexer failures or malformed import blocks; everything outside the import block is silently tolerated.

func ParseFile

func ParseFile(source string) (*File, error)

ParseFile tokenises the given source and parses it as a full .memql file (use-declarations + one or more top-level definitions). It is the shared entry point that future Phase 2 consumers (concept loader, query parser, automation compiler) will call instead of maintaining their own lexer/parser pairs.

For single-expression parses (e.g. a raw query string evaluated via engine.Execute) keep using NewParser(tokens).Parse() -- that path returns an ExpressionNode when the input lacks a top-level definition.

type FirstExpr

type FirstExpr = ast.FirstExpr

Struct / named-type aliases for every AST type.

type ForEachStepConfig

type ForEachStepConfig = ast.ForEachStepConfig

Struct / named-type aliases for every AST type.

type ForRangeStmt

type ForRangeStmt = ast.ForRangeStmt

Struct / named-type aliases for every AST type.

type FunctionArg

type FunctionArg = ast.FunctionArg

Struct / named-type aliases for every AST type.

type FunctionCallExpr

type FunctionCallExpr = ast.FunctionCallExpr

Struct / named-type aliases for every AST type.

type FunctionDef

type FunctionDef = ast.FunctionDef

Struct / named-type aliases for every AST type.

type FunctionReceiver

type FunctionReceiver = ast.FunctionReceiver

Struct / named-type aliases for every AST type.

type FunctionStepConfig

type FunctionStepConfig = ast.FunctionStepConfig

Struct / named-type aliases for every AST type.

type FunctionType

type FunctionType = ast.FunctionType

Struct / named-type aliases for every AST type.

type GtExpr

type GtExpr = ast.GtExpr

Struct / named-type aliases for every AST type.

type GteExpr

type GteExpr = ast.GteExpr

Struct / named-type aliases for every AST type.

type HashExpr

type HashExpr = ast.HashExpr

Struct / named-type aliases for every AST type.

type IfStmt

type IfStmt = ast.IfStmt

Struct / named-type aliases for every AST type.

type ImportDecl

type ImportDecl = ast.ImportDecl

Struct / named-type aliases for every AST type.

type IndexRefExpr

type IndexRefExpr = ast.IndexRefExpr

Struct / named-type aliases for every AST type.

type InputRefExpr

type InputRefExpr = ast.InputRefExpr

Struct / named-type aliases for every AST type.

type IsAnniversaryExpr

type IsAnniversaryExpr = ast.IsAnniversaryExpr

Struct / named-type aliases for every AST type.

type IsFirstDayOfQuarterExpr

type IsFirstDayOfQuarterExpr = ast.IsFirstDayOfQuarterExpr

Struct / named-type aliases for every AST type.

type ItemRefExpr

type ItemRefExpr = ast.ItemRefExpr

Struct / named-type aliases for every AST type.

type LastExpr

type LastExpr = ast.LastExpr

Struct / named-type aliases for every AST type.

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer converts a MemQL string into tokens.

func NewLexer

func NewLexer(input string) *Lexer

NewLexer creates a new lexer for the given input.

func (*Lexer) NextToken

func (l *Lexer) NextToken() (Token, error)

NextToken returns the next token from the input.

func (*Lexer) Tokenize

func (l *Lexer) Tokenize() ([]Token, error)

Tokenize converts the entire input into a slice of tokens. Each token's End* fields are stamped from the lexer's post-scan position so consumers can read the source span without re-implementing per-token length math. Specifically: `len(Literal)` doesn't match the source length for string tokens (quotes are stripped, escape sequences are decoded), so a span derived from `Column + len(Literal)` would be too short by at least 2 (the quotes) -- which surfaced as a trailing-cell color bleed in the cockpit's viewer (memql-cockpit#114).

type LiteralExpr

type LiteralExpr = ast.LiteralExpr

Struct / named-type aliases for every AST type.

type LogicalExpr

type LogicalExpr = ast.LogicalExpr

Struct / named-type aliases for every AST type.

type LogicalOp

type LogicalOp = ast.LogicalOp

Struct / named-type aliases for every AST type.

type LowerExpr

type LowerExpr = ast.LowerExpr

Struct / named-type aliases for every AST type.

type LtExpr

type LtExpr = ast.LtExpr

Struct / named-type aliases for every AST type.

type LteExpr

type LteExpr = ast.LteExpr

Struct / named-type aliases for every AST type.

type MonthExpr

type MonthExpr = ast.MonthExpr

Struct / named-type aliases for every AST type.

type MutationKind

type MutationKind = ast.MutationKind

Struct / named-type aliases for every AST type.

type MutationStepConfig

type MutationStepConfig = ast.MutationStepConfig

Struct / named-type aliases for every AST type.

type MutationStmt

type MutationStmt = ast.MutationStmt

Struct / named-type aliases for every AST type.

type NilExpr

type NilExpr = ast.NilExpr

Struct / named-type aliases for every AST type.

type Node

type Node = ast.Node

Interface aliases (require Go 1.24+; we are on 1.26.1).

type NotExpr

type NotExpr = ast.NotExpr

Struct / named-type aliases for every AST type.

type OrExpr

type OrExpr = ast.OrExpr

Struct / named-type aliases for every AST type.

type PaginateExpr

type PaginateExpr = ast.PaginateExpr

Struct / named-type aliases for every AST type.

type ParallelStepConfig

type ParallelStepConfig = ast.ParallelStepConfig

Struct / named-type aliases for every AST type.

type ParseError

type ParseError struct {
	Message string
	Pos     int
	Line    int
	Column  int
	Token   *Token
}

ParseError represents a parsing error with position information.

func (*ParseError) Error

func (e *ParseError) Error() string

func (*ParseError) Unwrap

func (e *ParseError) Unwrap() error

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser converts tokens into an AST.

func NewParser

func NewParser(tokens []Token) *Parser

NewParser creates a new parser for the given tokens.

func (*Parser) Parse

func (p *Parser) Parse() (Node, error)

Parse parses the token stream and returns the root AST node. For .memql files, this returns a *File containing definitions. For single expressions, this returns an ExpressionNode.

type PolicyDecl

type PolicyDecl = ast.PolicyDecl

Struct / named-type aliases for every AST type.

type PromptDecl

type PromptDecl = ast.PromptDecl

Struct / named-type aliases for every AST type.

func ParsePromptDecl

func ParsePromptDecl(source string) (*PromptDecl, error)

ParsePromptDecl tokenises the given source and parses it as a single struct-form prompt declaration. Convenience wrapper around ParseFile for the unified-kinds loader's LoadUnifiedPrompts flow. Mirrors ParseBuiltinDecl on the error surface.

memql#319 (sub-epic #309 / #306 child C).

type PromptField

type PromptField = ast.PromptField

Struct / named-type aliases for every AST type.

type PropertyDecl

type PropertyDecl = ast.PropertyDecl

Struct / named-type aliases for every AST type.

type PropertyVariant

type PropertyVariant = ast.PropertyVariant

Struct / named-type aliases for every AST type.

type ProviderDecl

type ProviderDecl = ast.ProviderDecl

Struct / named-type aliases for every AST type.

type QuarterExpr

type QuarterExpr = ast.QuarterExpr

Struct / named-type aliases for every AST type.

type QueryStepConfig

type QueryStepConfig = ast.QueryStepConfig

Struct / named-type aliases for every AST type.

type QueryStmt

type QueryStmt = ast.QueryStmt

Struct / named-type aliases for every AST type.

type RateLimitConfig

type RateLimitConfig = ast.RateLimitConfig

Struct / named-type aliases for every AST type.

type ReceiverType

type ReceiverType = ast.ReceiverType

Struct / named-type aliases for every AST type.

type RelationshipDecl

type RelationshipDecl = ast.RelationshipDecl

Struct / named-type aliases for every AST type.

type RelationshipExpr

type RelationshipExpr = ast.RelationshipExpr

Struct / named-type aliases for every AST type.

type RelationshipFunction

type RelationshipFunction = ast.RelationshipFunction

Struct / named-type aliases for every AST type.

type RetryExpr

type RetryExpr = ast.RetryExpr

Struct / named-type aliases for every AST type.

type ReturnStmt

type ReturnStmt = ast.ReturnStmt

Struct / named-type aliases for every AST type.

type SIExpr

type SIExpr = ast.SIExpr

Struct / named-type aliases for every AST type.

type SeedBlock

type SeedBlock = ast.SeedBlock

Struct / named-type aliases for every AST type.

type SeedDecl

type SeedDecl = ast.SeedDecl

Struct / named-type aliases for every AST type.

type SeedValue

type SeedValue = ast.SeedValue

Struct / named-type aliases for every AST type.

type SeedValueKind

type SeedValueKind = ast.SeedValueKind

Struct / named-type aliases for every AST type.

type SelectExpr

type SelectExpr = ast.SelectExpr

Struct / named-type aliases for every AST type.

type ShapeDecl

type ShapeDecl = ast.ShapeDecl

Struct / named-type aliases for every AST type.

func ParseShapeDecl

func ParseShapeDecl(source string) (*ShapeDecl, error)

ParseShapeDecl tokenises the given source and parses it as a single struct-form shape declaration. Convenience wrapper around ParseFile for callers that handle one shape per slice (the unified-kinds loader's LoadUnifiedShapes flow). Returns an error when the source contains zero or more than one definition, or when the single definition isn't a shape.

memql#315 (sub-epic #309 / #306 child C).

type ShapeExpr

type ShapeExpr = ast.ShapeExpr

Struct / named-type aliases for every AST type.

type SortDirection

type SortDirection = ast.SortDirection

Struct / named-type aliases for every AST type.

type SortExpr

type SortExpr = ast.SortExpr

Struct / named-type aliases for every AST type.

type SortField

type SortField = ast.SortField

Struct / named-type aliases for every AST type.

type SpecDecl

type SpecDecl = ast.SpecDecl

Struct / named-type aliases for every AST type.

type SpecReferenceExpr

type SpecReferenceExpr = ast.SpecReferenceExpr

Struct / named-type aliases for every AST type.

type StatementNode

type StatementNode = ast.StatementNode

Interface aliases (require Go 1.24+; we are on 1.26.1).

type StepDef

type StepDef = ast.StepDef

Struct / named-type aliases for every AST type.

type StepRefExpr

type StepRefExpr = ast.StepRefExpr

Struct / named-type aliases for every AST type.

type StepType

type StepType = ast.StepType

Struct / named-type aliases for every AST type.

type SubtractTimestampsExpr

type SubtractTimestampsExpr = ast.SubtractTimestampsExpr

Struct / named-type aliases for every AST type.

type SwitchCase

type SwitchCase = ast.SwitchCase

Struct / named-type aliases for every AST type.

type SwitchStepConfig

type SwitchStepConfig = ast.SwitchStepConfig

Struct / named-type aliases for every AST type.

type SwitchStmt

type SwitchStmt = ast.SwitchStmt

Struct / named-type aliases for every AST type.

type TernaryExpr

type TernaryExpr = ast.TernaryExpr

Struct / named-type aliases for every AST type.

type TimestampExpr

type TimestampExpr = ast.TimestampExpr

Struct / named-type aliases for every AST type.

type TimestampExprFunc

type TimestampExprFunc = ast.TimestampExprFunc

Struct / named-type aliases for every AST type.

type ToStringExpr

type ToStringExpr = ast.ToStringExpr

Struct / named-type aliases for every AST type.

type Token

type Token struct {
	Type    TokenType
	Literal string
	Pos     int
	Line    int
	Column  int
	EndPos  int
	EndLine int
	EndCol  int
}

Token represents a lexical token.

Position fields are 1-indexed (Line, Column) plus a byte offset (Pos). EndLine / EndCol / EndPos point to the FIRST position after the token -- i.e. half-open [Column, EndCol). For single-character tokens, EndCol == Column + 1. For string tokens, the end positions span the closing quote AND the content (Literal strips quotes + decodes escapes, so its length no longer matches the source span -- the EndCol field is the authoritative source-length record).

Tokenize() populates the End* fields after each scan; the individual scan functions don't have to stamp them themselves.

func (Token) String

func (t Token) String() string

String returns a human-readable representation of the token.

type TokenType

type TokenType int

TokenType enumerates lexical token categories.

const (
	TokenEOF TokenType = iota
	TokenIdentifier
	TokenNumber
	TokenString
	TokenOperator
	TokenParenOpen
	TokenParenClose
	TokenBraceOpen
	TokenBraceClose
	TokenBracketOpen
	TokenBracketClose
	TokenColon
	TokenSemicolon
	TokenComma
	TokenDefine           // :=
	TokenQuestion         // ? for ternary operator
	TokenQuestionDot      // ?. for optional/conditional filters
	TokenQuestionQuestion // ?? for null coalescing
	TokenAt               // @ for Python-style attributes/decorators
	TokenAmpAmp           // && for logical AND
	TokenBang             // ! for boolean negation
	TokenDot              // . between path and `{` in `use path.{ names }`

	// Keywords - Type receivers (used in func receiver syntax)
	TokenKeywordQuery      // Query
	TokenKeywordMutation   // Mutation
	TokenKeywordAutomation // Automation
	TokenKeywordSpec       // Spec
	TokenKeywordTool       // Tool
	TokenKeywordBuiltin    // Builtin

	// Keywords - Go-like control flow
	TokenKeywordFunc     // func
	TokenKeywordFor      // for
	TokenKeywordRange    // range
	TokenKeywordIf       // if
	TokenKeywordElse     // else
	TokenKeywordSwitch   // switch
	TokenKeywordCase     // case
	TokenKeywordDefault  // default
	TokenKeywordContinue // continue
	TokenKeywordBreak    // break
	TokenKeywordReturn   // return
	TokenKeywordNil      // nil
	TokenKeywordRetry    // retry
	TokenKeywordWhen     // when (conditional step execution)
	TokenKeywordAs       // as (forEach iteration variable, use alias)
	TokenKeywordWhere    // where (forEach filter)
	TokenKeywordUse      // use (concept import declaration)
	TokenKeywordImport   // import (file-import block; new model)
	TokenKeywordConcept  // concept (concept definition)
	TokenKeywordIn       // in (membership operator)
	TokenKeywordHas      // has (containment operator)
	TokenKeywordNot      // not (negation, used in "not in")
)

func (TokenType) String

func (t TokenType) String() string

String returns a human-readable name for a TokenType. Used in parse error messages so users see "expected '{'" instead of "expected 8".

type ToolDecl

type ToolDecl = ast.ToolDecl

Struct / named-type aliases for every AST type.

type ToolFieldDecl

type ToolFieldDecl = ast.ToolFieldDecl

Struct / named-type aliases for every AST type.

type TriggerDef

type TriggerDef = ast.TriggerDef

Struct / named-type aliases for every AST type.

type TrimExpr

type TrimExpr = ast.TrimExpr

Struct / named-type aliases for every AST type.

type TypeRef

type TypeRef = ast.TypeRef

Struct / named-type aliases for every AST type.

type UpperExpr

type UpperExpr = ast.UpperExpr

Struct / named-type aliases for every AST type.

type UseDeclaration

type UseDeclaration = ast.UseDeclaration

Struct / named-type aliases for every AST type.

type VarRefExpr

type VarRefExpr = ast.VarRefExpr

Struct / named-type aliases for every AST type.

type YearExpr

type YearExpr = ast.YearExpr

Struct / named-type aliases for every AST type.

Jump to

Keyboard shortcuts

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