ast

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressOfExpr

type AddressOfExpr struct {
	Token   lexer.Token // The 'reference' token
	Operand Expression  // The expression to take address of
}

func (*AddressOfExpr) Pos

func (e *AddressOfExpr) Pos() Position

func (*AddressOfExpr) TokenLiteral

func (e *AddressOfExpr) TokenLiteral() string

type ArrowLambda added in v0.0.2

type ArrowLambda struct {
	Token      lexer.Token  // The '=>' token
	Parameters []*Parameter // May have nil Type for untyped params
	Body       Expression   // Expression lambda: single expression (auto-return)
	Block      *BlockStmt   // Block lambda: multi-statement body (mutually exclusive with Body)
}

ArrowLambda represents a short inline function using => syntax. Expression form: (r Repo) => r.Stars > 100 Block form: (r Repo) =>

name := r.Name
return name

func (*ArrowLambda) Pos added in v0.0.2

func (e *ArrowLambda) Pos() Position

func (*ArrowLambda) TokenLiteral added in v0.0.2

func (e *ArrowLambda) TokenLiteral() string

type AssignStmt

type AssignStmt struct {
	Targets []Expression // Can be single or multiple targets
	Values  []Expression // Right-hand side values (can be single or multiple)
	Token   lexer.Token  // The '=' token
	OnErr   *OnErrClause // Optional onerr clause (e.g., x = f() onerr panic "msg")
}

func (*AssignStmt) Pos

func (s *AssignStmt) Pos() Position

func (*AssignStmt) TokenLiteral

func (s *AssignStmt) TokenLiteral() string

type BinaryExpr

type BinaryExpr struct {
	Token    lexer.Token // The operator token
	Left     Expression
	Operator string
	Right    Expression
}

func (*BinaryExpr) Pos

func (e *BinaryExpr) Pos() Position

func (*BinaryExpr) TokenLiteral

func (e *BinaryExpr) TokenLiteral() string

type BlockExpr

type BlockExpr struct {
	Token lexer.Token // The INDENT token
	Body  *BlockStmt
}

func (*BlockExpr) Pos

func (e *BlockExpr) Pos() Position

func (*BlockExpr) TokenLiteral

func (e *BlockExpr) TokenLiteral() string

type BlockStmt

type BlockStmt struct {
	Token      lexer.Token // The '{' or INDENT token
	Statements []Statement
}

func (*BlockStmt) Pos

func (s *BlockStmt) Pos() Position

func (*BlockStmt) TokenLiteral

func (s *BlockStmt) TokenLiteral() string

type BooleanLiteral

type BooleanLiteral struct {
	Token lexer.Token
	Value bool
}

func (*BooleanLiteral) Pos

func (e *BooleanLiteral) Pos() Position

func (*BooleanLiteral) TokenLiteral

func (e *BooleanLiteral) TokenLiteral() string

type BreakStmt

type BreakStmt struct {
	Token lexer.Token // The 'break' token
}

func (*BreakStmt) Pos

func (s *BreakStmt) Pos() Position

func (*BreakStmt) TokenLiteral

func (s *BreakStmt) TokenLiteral() string

type CallExpr

type CallExpr struct {
	Token          lexer.Token // The '(' token or identifier
	Function       Expression
	Arguments      []Expression     // Positional arguments
	NamedArguments []*NamedArgument // Named arguments (e.g., name: value)
	Variadic       bool             // true if 'many' used: f(many args)
}

func (*CallExpr) Pos

func (e *CallExpr) Pos() Position

func (*CallExpr) TokenLiteral

func (e *CallExpr) TokenLiteral() string

type ChannelType

type ChannelType struct {
	Token       lexer.Token // The 'channel' token
	ElementType TypeAnnotation
}

func (*ChannelType) Pos

func (t *ChannelType) Pos() Position

func (*ChannelType) TokenLiteral

func (t *ChannelType) TokenLiteral() string

type CloseExpr

type CloseExpr struct {
	Token   lexer.Token // The 'close' token
	Channel Expression
}

func (*CloseExpr) Pos

func (e *CloseExpr) Pos() Position

func (*CloseExpr) TokenLiteral

func (e *CloseExpr) TokenLiteral() string

type ConstDecl added in v0.0.16

type ConstDecl struct {
	Token lexer.Token  // The 'const' token
	Specs []*ConstSpec // One or more name=value pairs
}

ConstDecl represents a const declaration (single or grouped).

const MaxRetries = 5
const
    StatusOK  = 200
    StatusNotFound = 404

func (*ConstDecl) Pos added in v0.0.16

func (d *ConstDecl) Pos() Position

func (*ConstDecl) TokenLiteral added in v0.0.16

func (d *ConstDecl) TokenLiteral() string

type ConstSpec added in v0.0.16

type ConstSpec struct {
	Name  *Identifier
	Value Expression // Required: const values must always be provided
}

ConstSpec is a single name = value pair inside a const block.

type ContinueStmt

type ContinueStmt struct {
	Token lexer.Token // The 'continue' token
}

func (*ContinueStmt) Pos

func (s *ContinueStmt) Pos() Position

func (*ContinueStmt) TokenLiteral

func (s *ContinueStmt) TokenLiteral() string

type Declaration

type Declaration interface {
	Node
	// contains filtered or unexported methods
}

type DeferStmt

type DeferStmt struct {
	Token lexer.Token // The 'defer' token
	Call  Expression  // Can be CallExpr or MethodCallExpr
}

func (*DeferStmt) Pos

func (s *DeferStmt) Pos() Position

func (*DeferStmt) TokenLiteral

func (s *DeferStmt) TokenLiteral() string

type DerefExpr

type DerefExpr struct {
	Token   lexer.Token // The 'dereference' token
	Operand Expression  // The expression to dereference
}

func (*DerefExpr) Pos

func (e *DerefExpr) Pos() Position

func (*DerefExpr) TokenLiteral

func (e *DerefExpr) TokenLiteral() string

type Directive added in v0.0.14

type Directive struct {
	Token lexer.Token // The TOKEN_DIRECTIVE token
	Name  string      // Directive name (e.g., "deprecated", "fix")
	Args  []string    // Arguments (e.g., ["Use NewFunc instead"])
}

Directive represents a `# kuki:name args...` annotation attached to a declaration.

type DiscardExpr

type DiscardExpr struct {
	Token lexer.Token // The 'discard' token
}

func (*DiscardExpr) Pos

func (e *DiscardExpr) Pos() Position

func (*DiscardExpr) TokenLiteral

func (e *DiscardExpr) TokenLiteral() string

type ElseStmt

type ElseStmt struct {
	Token lexer.Token // The 'else' token
	Body  *BlockStmt
}

func (*ElseStmt) Pos

func (s *ElseStmt) Pos() Position

func (*ElseStmt) TokenLiteral

func (s *ElseStmt) TokenLiteral() string

type EmptyExpr

type EmptyExpr struct {
	Token lexer.Token // The 'empty' token
	Type  TypeAnnotation
}

func (*EmptyExpr) Pos

func (e *EmptyExpr) Pos() Position

func (*EmptyExpr) TokenLiteral

func (e *EmptyExpr) TokenLiteral() string

type ErrorExpr

type ErrorExpr struct {
	Token   lexer.Token // The 'error' token
	Message Expression  // Usually a string literal
}

func (*ErrorExpr) Pos

func (e *ErrorExpr) Pos() Position

func (*ErrorExpr) TokenLiteral

func (e *ErrorExpr) TokenLiteral() string

type Expression

type Expression interface {
	Node
	// contains filtered or unexported methods
}

type ExpressionStmt

type ExpressionStmt struct {
	Expression Expression
	OnErr      *OnErrClause // Optional onerr clause (e.g., f() onerr panic "msg")
}

func (*ExpressionStmt) Pos

func (s *ExpressionStmt) Pos() Position

func (*ExpressionStmt) TokenLiteral

func (s *ExpressionStmt) TokenLiteral() string

type FieldAccessExpr added in v0.0.14

type FieldAccessExpr struct {
	Token  lexer.Token // The '.' token
	Object Expression  // Can be nil for shorthand pipes: |> .Field
	Field  *Identifier
}

func (*FieldAccessExpr) Pos added in v0.0.14

func (e *FieldAccessExpr) Pos() Position

func (*FieldAccessExpr) TokenLiteral added in v0.0.14

func (e *FieldAccessExpr) TokenLiteral() string

type FieldDecl

type FieldDecl struct {
	Name *Identifier
	Type TypeAnnotation
	Tag  string // Struct tag (e.g., `json:"name"`)
}

type FieldValue

type FieldValue struct {
	Name  *Identifier
	Value Expression
}

type FloatLiteral

type FloatLiteral struct {
	Token lexer.Token
	Value float64
}

func (*FloatLiteral) Pos

func (e *FloatLiteral) Pos() Position

func (*FloatLiteral) TokenLiteral

func (e *FloatLiteral) TokenLiteral() string

type ForConditionStmt

type ForConditionStmt struct {
	Token     lexer.Token // The 'for' token
	Condition Expression
	Body      *BlockStmt
}

ForConditionStmt: for condition

func (*ForConditionStmt) Pos

func (s *ForConditionStmt) Pos() Position

func (*ForConditionStmt) TokenLiteral

func (s *ForConditionStmt) TokenLiteral() string

type ForNumericStmt

type ForNumericStmt struct {
	Token    lexer.Token // The 'for' token
	Variable *Identifier
	Start    Expression
	End      Expression
	Through  bool // true for 'through', false for 'to'
	Body     *BlockStmt
}

ForNumericStmt: for i from start to end / for i from start through end

func (*ForNumericStmt) Pos

func (s *ForNumericStmt) Pos() Position

func (*ForNumericStmt) TokenLiteral

func (s *ForNumericStmt) TokenLiteral() string

type ForRangeStmt

type ForRangeStmt struct {
	Token      lexer.Token // The 'for' token
	Variable   *Identifier
	Index      *Identifier // Optional (for index, item in collection)
	Collection Expression
	Body       *BlockStmt
}

ForRangeStmt: for item in collection

func (*ForRangeStmt) Pos

func (s *ForRangeStmt) Pos() Position

func (*ForRangeStmt) TokenLiteral

func (s *ForRangeStmt) TokenLiteral() string

type FunctionDecl

type FunctionDecl struct {
	Token      lexer.Token // The 'func' token
	Name       *Identifier
	Parameters []*Parameter
	Returns    []TypeAnnotation
	Body       *BlockStmt
	Receiver   *Receiver   // For methods (optional)
	Directives []Directive // Attached `# kuki:` directives
}

func (*FunctionDecl) Pos

func (d *FunctionDecl) Pos() Position

func (*FunctionDecl) TokenLiteral

func (d *FunctionDecl) TokenLiteral() string

type FunctionLiteral

type FunctionLiteral struct {
	Token      lexer.Token // The 'func' token
	Parameters []*Parameter
	Returns    []TypeAnnotation
	Body       *BlockStmt
}

func (*FunctionLiteral) Pos

func (e *FunctionLiteral) Pos() Position

func (*FunctionLiteral) TokenLiteral

func (e *FunctionLiteral) TokenLiteral() string

type FunctionType

type FunctionType struct {
	Token      lexer.Token      // The 'func' token
	Parameters []TypeAnnotation // Parameter types
	Returns    []TypeAnnotation // Return types
}

FunctionType represents a function type annotation e.g., func(int, string) bool

func (*FunctionType) Pos

func (t *FunctionType) Pos() Position

func (*FunctionType) TokenLiteral

func (t *FunctionType) TokenLiteral() string

type GoStmt

type GoStmt struct {
	Token lexer.Token // The 'go' token
	Call  Expression  // Can be CallExpr or MethodCallExpr (nil when Block is set)
	Block *BlockStmt  // Block form: go NEWLINE INDENT ... DEDENT (nil when Call is set)
}

func (*GoStmt) Pos

func (s *GoStmt) Pos() Position

func (*GoStmt) TokenLiteral

func (s *GoStmt) TokenLiteral() string

type Identifier

type Identifier struct {
	Token lexer.Token
	Value string
}

func (*Identifier) Pos

func (e *Identifier) Pos() Position

func (*Identifier) TokenLiteral

func (e *Identifier) TokenLiteral() string

type IfStmt

type IfStmt struct {
	Token       lexer.Token // The 'if' token
	Init        Statement   // Optional initialization statement (can be nil)
	Condition   Expression
	Consequence *BlockStmt
	Alternative Statement // Can be ElseStmt or another IfStmt (else if)
}

func (*IfStmt) Pos

func (s *IfStmt) Pos() Position

func (*IfStmt) TokenLiteral

func (s *IfStmt) TokenLiteral() string

type ImportDecl

type ImportDecl struct {
	Token lexer.Token // The 'import' token
	Path  *StringLiteral
	Alias *Identifier // Optional alias
}

func (*ImportDecl) Pos

func (d *ImportDecl) Pos() Position

func (*ImportDecl) TokenLiteral

func (d *ImportDecl) TokenLiteral() string

type IncDecStmt

type IncDecStmt struct {
	Token    lexer.Token // The '++' or '--' token
	Variable Expression
	Operator string // "++" or "--"
}

func (*IncDecStmt) Pos

func (s *IncDecStmt) Pos() Position

func (*IncDecStmt) TokenLiteral

func (s *IncDecStmt) TokenLiteral() string

type IndexExpr

type IndexExpr struct {
	Token lexer.Token // The '[' token
	Left  Expression
	Index Expression
}

func (*IndexExpr) Pos

func (e *IndexExpr) Pos() Position

func (*IndexExpr) TokenLiteral

func (e *IndexExpr) TokenLiteral() string

type IntegerLiteral

type IntegerLiteral struct {
	Token lexer.Token
	Value int64
}

func (*IntegerLiteral) Pos

func (e *IntegerLiteral) Pos() Position

func (*IntegerLiteral) TokenLiteral

func (e *IntegerLiteral) TokenLiteral() string

type InterfaceDecl

type InterfaceDecl struct {
	Token      lexer.Token // The 'interface' token
	Name       *Identifier
	Methods    []*MethodSignature
	Directives []Directive // Attached `# kuki:` directives
}

func (*InterfaceDecl) Pos

func (d *InterfaceDecl) Pos() Position

func (*InterfaceDecl) TokenLiteral

func (d *InterfaceDecl) TokenLiteral() string

type KeyValuePair

type KeyValuePair struct {
	Key   Expression
	Value Expression
}

type ListLiteralExpr

type ListLiteralExpr struct {
	Token    lexer.Token // The '[' token or 'list' keyword
	Type     TypeAnnotation
	Elements []Expression
}

func (*ListLiteralExpr) Pos

func (e *ListLiteralExpr) Pos() Position

func (*ListLiteralExpr) TokenLiteral

func (e *ListLiteralExpr) TokenLiteral() string

type ListType

type ListType struct {
	Token       lexer.Token // The 'list' token
	ElementType TypeAnnotation
}

func (*ListType) Pos

func (t *ListType) Pos() Position

func (*ListType) TokenLiteral

func (t *ListType) TokenLiteral() string

type MakeExpr

type MakeExpr struct {
	Token lexer.Token // The 'make' token
	Type  TypeAnnotation
	Args  []Expression // Size/capacity for slices, channels
}

func (*MakeExpr) Pos

func (e *MakeExpr) Pos() Position

func (*MakeExpr) TokenLiteral

func (e *MakeExpr) TokenLiteral() string

type MapLiteralExpr

type MapLiteralExpr struct {
	Token   lexer.Token // The '{' token or 'map' keyword
	KeyType TypeAnnotation
	ValType TypeAnnotation
	Pairs   []*KeyValuePair
}

func (*MapLiteralExpr) Pos

func (e *MapLiteralExpr) Pos() Position

func (*MapLiteralExpr) TokenLiteral

func (e *MapLiteralExpr) TokenLiteral() string

type MapType

type MapType struct {
	Token     lexer.Token // The 'map' token
	KeyType   TypeAnnotation
	ValueType TypeAnnotation
}

func (*MapType) Pos

func (t *MapType) Pos() Position

func (*MapType) TokenLiteral

func (t *MapType) TokenLiteral() string

type MethodCallExpr

type MethodCallExpr struct {
	Token          lexer.Token // The '.' token
	Object         Expression  // Can be nil for shorthand pipes: |> .Method()
	Method         *Identifier
	Arguments      []Expression     // Positional arguments
	NamedArguments []*NamedArgument // Named arguments (e.g., name: value)
	Variadic       bool             // true if 'many' used: obj.f(many args)
}

func (*MethodCallExpr) Pos

func (e *MethodCallExpr) Pos() Position

func (*MethodCallExpr) TokenLiteral

func (e *MethodCallExpr) TokenLiteral() string

type MethodSignature

type MethodSignature struct {
	Name       *Identifier
	Parameters []*Parameter
	Returns    []TypeAnnotation
}

type NamedArgument

type NamedArgument struct {
	Token lexer.Token // The identifier token for the name
	Name  *Identifier
	Value Expression
}

NamedArgument represents a named argument in a function call e.g., foo(name: "value", count: 5)

func (*NamedArgument) Pos

func (e *NamedArgument) Pos() Position

func (*NamedArgument) TokenLiteral

func (e *NamedArgument) TokenLiteral() string

type NamedType

type NamedType struct {
	Token lexer.Token // The identifier token
	Name  string
}

func (*NamedType) Pos

func (t *NamedType) Pos() Position

func (*NamedType) TokenLiteral

func (t *NamedType) TokenLiteral() string

type Node

type Node interface {
	TokenLiteral() string
	Pos() Position
}

Node is the base interface for all AST nodes

type OnErrClause

type OnErrClause struct {
	Token             lexer.Token // The 'onerr' token
	Handler           Expression  // Error handler (panic, error, empty, discard, or default value)
	Explain           string      // Optional explanation/hint for LLM (e.g., onerr explain "hint message")
	ShorthandReturn   bool        // True for bare "onerr return" — propagate error with zero values
	ShorthandContinue bool        // True for bare "onerr continue"
	ShorthandBreak    bool        // True for bare "onerr break"
	Alias             string      // Named alias for the caught error in block handlers (e.g., "onerr as e")
}

OnErrClause represents the error handling part of an onerr statement. It is not an AST node itself — it is a field on VarDeclStmt, AssignStmt, and ExpressionStmt.

type OtherwiseCase added in v0.0.2

type OtherwiseCase struct {
	Token lexer.Token // The 'otherwise' or 'default' token
	Body  *BlockStmt
}

type PanicExpr

type PanicExpr struct {
	Token   lexer.Token // The 'panic' token
	Message Expression
}

func (*PanicExpr) Pos

func (e *PanicExpr) Pos() Position

func (*PanicExpr) TokenLiteral

func (e *PanicExpr) TokenLiteral() string

type Parameter

type Parameter struct {
	Name         *Identifier
	Type         TypeAnnotation
	Variadic     bool       // true if "many" keyword used
	DefaultValue Expression // Optional default value (e.g., count int = 10)
}

type PetioleDecl

type PetioleDecl struct {
	Token lexer.Token // The 'petiole' token
	Name  *Identifier
}

func (*PetioleDecl) Pos

func (d *PetioleDecl) Pos() Position

func (*PetioleDecl) TokenLiteral

func (d *PetioleDecl) TokenLiteral() string

type PipeExpr

type PipeExpr struct {
	Token lexer.Token // The '|>' token
	Left  Expression
	Right Expression // Must be a function call
}

func (*PipeExpr) Pos

func (e *PipeExpr) Pos() Position

func (*PipeExpr) TokenLiteral

func (e *PipeExpr) TokenLiteral() string

type PipedSwitchBody added in v0.0.13

type PipedSwitchBody interface {
	Node
	// contains filtered or unexported methods
}

type PipedSwitchExpr added in v0.0.13

type PipedSwitchExpr struct {
	Token  lexer.Token     // The '|>' token
	Left   Expression      // The value being piped into the switch
	Switch PipedSwitchBody // The switch block itself
}

func (*PipedSwitchExpr) Pos added in v0.0.13

func (e *PipedSwitchExpr) Pos() Position

func (*PipedSwitchExpr) TokenLiteral added in v0.0.13

func (e *PipedSwitchExpr) TokenLiteral() string

type Position

type Position struct {
	Line   int
	Column int
	File   string
}

Position represents a location in the source code

type PrimitiveType

type PrimitiveType struct {
	Token lexer.Token // The type token
	Name  string      // int, float, string, bool, etc.
}

func (*PrimitiveType) Pos

func (t *PrimitiveType) Pos() Position

func (*PrimitiveType) TokenLiteral

func (t *PrimitiveType) TokenLiteral() string

type Program

type Program struct {
	Target       string        // Directive target (e.g., "mcp")
	PetioleDecl  *PetioleDecl  // Optional petiole declaration
	SkillDecl    *SkillDecl    // Optional skill declaration
	Imports      []*ImportDecl // Import declarations
	Declarations []Declaration // Top-level declarations (types, interfaces, functions)
}

func (*Program) Pos

func (p *Program) Pos() Position

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

type ReceiveExpr

type ReceiveExpr struct {
	Token   lexer.Token // The 'receive' token
	Channel Expression
}

func (*ReceiveExpr) Pos

func (e *ReceiveExpr) Pos() Position

func (*ReceiveExpr) TokenLiteral

func (e *ReceiveExpr) TokenLiteral() string

type Receiver

type Receiver struct {
	Name *Identifier // The receiver variable name
	Type TypeAnnotation
}

type RecoverExpr

type RecoverExpr struct {
	Token lexer.Token // The 'recover' token
}

func (*RecoverExpr) Pos

func (e *RecoverExpr) Pos() Position

func (*RecoverExpr) TokenLiteral

func (e *RecoverExpr) TokenLiteral() string

type ReferenceType

type ReferenceType struct {
	Token       lexer.Token // The 'reference' token
	ElementType TypeAnnotation
}

func (*ReferenceType) Pos

func (t *ReferenceType) Pos() Position

func (*ReferenceType) TokenLiteral

func (t *ReferenceType) TokenLiteral() string

type ReturnExpr

type ReturnExpr struct {
	Token  lexer.Token // The 'return' token
	Values []Expression
}

func (*ReturnExpr) Pos

func (e *ReturnExpr) Pos() Position

func (*ReturnExpr) TokenLiteral

func (e *ReturnExpr) TokenLiteral() string

type ReturnStmt

type ReturnStmt struct {
	Token  lexer.Token // The 'return' token
	Values []Expression
}

func (*ReturnStmt) Pos

func (s *ReturnStmt) Pos() Position

func (*ReturnStmt) TokenLiteral

func (s *ReturnStmt) TokenLiteral() string

type RuneLiteral

type RuneLiteral struct {
	Token lexer.Token
	Value rune
}

func (*RuneLiteral) Pos

func (e *RuneLiteral) Pos() Position

func (*RuneLiteral) TokenLiteral

func (e *RuneLiteral) TokenLiteral() string

type SelectCase added in v0.0.6

type SelectCase struct {
	Token    lexer.Token  // The 'when' token
	Bindings []string     // [], ["v"], or ["v", "ok"]
	Recv     *ReceiveExpr // non-nil for receive cases
	Send     *SendStmt    // non-nil for send cases
	Body     *BlockStmt
}

type SelectStmt added in v0.0.6

type SelectStmt struct {
	Token     lexer.Token // The 'select' token
	Cases     []*SelectCase
	Otherwise *OtherwiseCase // Optional default case
}

func (*SelectStmt) Pos added in v0.0.6

func (s *SelectStmt) Pos() Position

func (*SelectStmt) TokenLiteral added in v0.0.6

func (s *SelectStmt) TokenLiteral() string

type SendStmt

type SendStmt struct {
	Token   lexer.Token // The 'send' token
	Value   Expression
	Channel Expression
}

func (*SendStmt) Pos

func (s *SendStmt) Pos() Position

func (*SendStmt) TokenLiteral

func (s *SendStmt) TokenLiteral() string

type SkillDecl added in v0.0.5

type SkillDecl struct {
	Token       lexer.Token // The 'skill' token
	Name        *Identifier
	Description string // Description field
	Version     string // Version field
}

func (*SkillDecl) Pos added in v0.0.5

func (d *SkillDecl) Pos() Position

func (*SkillDecl) TokenLiteral added in v0.0.5

func (d *SkillDecl) TokenLiteral() string

type SliceExpr

type SliceExpr struct {
	Token lexer.Token // The '[' token
	Left  Expression
	Start Expression // Can be nil
	End   Expression // Can be nil
}

func (*SliceExpr) Pos

func (e *SliceExpr) Pos() Position

func (*SliceExpr) TokenLiteral

func (e *SliceExpr) TokenLiteral() string

type Statement

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

type StringInterpolation

type StringInterpolation struct {
	IsLiteral bool       // True for literal parts, false for expressions
	Literal   string     // For literal parts
	Expr      Expression // For expression parts
}

type StringLiteral

type StringLiteral struct {
	Token        lexer.Token
	Value        string
	Interpolated bool                   // True if contains {expr}
	Parts        []*StringInterpolation // For interpolated strings
}

func (*StringLiteral) Pos

func (e *StringLiteral) Pos() Position

func (*StringLiteral) TokenLiteral

func (e *StringLiteral) TokenLiteral() string

type StructLiteralExpr

type StructLiteralExpr struct {
	Token  lexer.Token // The type identifier
	Type   TypeAnnotation
	Fields []*FieldValue
}

func (*StructLiteralExpr) Pos

func (e *StructLiteralExpr) Pos() Position

func (*StructLiteralExpr) TokenLiteral

func (e *StructLiteralExpr) TokenLiteral() string

type SwitchStmt added in v0.0.2

type SwitchStmt struct {
	Token      lexer.Token // The 'switch' token
	Expression Expression  // Optional (nil for condition switch)
	Cases      []*WhenCase
	Otherwise  *OtherwiseCase // Optional
}

func (*SwitchStmt) Pos added in v0.0.2

func (s *SwitchStmt) Pos() Position

func (*SwitchStmt) TokenLiteral added in v0.0.2

func (s *SwitchStmt) TokenLiteral() string

type TypeAnnotation

type TypeAnnotation interface {
	Node
	// contains filtered or unexported methods
}

type TypeAssertionExpr

type TypeAssertionExpr struct {
	Token      lexer.Token // The '.' token
	Expression Expression
	TargetType TypeAnnotation
}

func (*TypeAssertionExpr) Pos

func (e *TypeAssertionExpr) Pos() Position

func (*TypeAssertionExpr) TokenLiteral

func (e *TypeAssertionExpr) TokenLiteral() string

type TypeCase added in v0.0.5

type TypeCase struct {
	Token lexer.Token    // The 'when' token
	Type  TypeAnnotation // The type to match
	Body  *BlockStmt
}

TypeCase: when reference SomeType / when SomeType

type TypeCastExpr

type TypeCastExpr struct {
	Token      lexer.Token // The 'as' token
	Expression Expression
	TargetType TypeAnnotation
}

func (*TypeCastExpr) Pos

func (e *TypeCastExpr) Pos() Position

func (*TypeCastExpr) TokenLiteral

func (e *TypeCastExpr) TokenLiteral() string

type TypeDecl

type TypeDecl struct {
	Token      lexer.Token // The 'type' token
	Name       *Identifier
	Fields     []*FieldDecl   // nil for type aliases
	AliasType  TypeAnnotation // non-nil for type aliases (e.g., func(...) ...)
	Directives []Directive    // Attached `# kuki:` directives
}

func (*TypeDecl) Pos

func (d *TypeDecl) Pos() Position

func (*TypeDecl) TokenLiteral

func (d *TypeDecl) TokenLiteral() string

type TypeSwitchStmt added in v0.0.5

type TypeSwitchStmt struct {
	Token      lexer.Token    // The 'switch' token
	Expression Expression     // The expression to switch on
	Binding    *Identifier    // The binding variable (e.g., e in "switch event as e")
	Cases      []*TypeCase    // Type cases
	Otherwise  *OtherwiseCase // Optional default branch
}

TypeSwitchStmt: switch expr as binding

func (*TypeSwitchStmt) Pos added in v0.0.5

func (s *TypeSwitchStmt) Pos() Position

func (*TypeSwitchStmt) TokenLiteral added in v0.0.5

func (s *TypeSwitchStmt) TokenLiteral() string

type UnaryExpr

type UnaryExpr struct {
	Token    lexer.Token // The operator token
	Operator string
	Right    Expression
}

func (*UnaryExpr) Pos

func (e *UnaryExpr) Pos() Position

func (*UnaryExpr) TokenLiteral

func (e *UnaryExpr) TokenLiteral() string

type VarDeclStmt

type VarDeclStmt struct {
	Names  []*Identifier
	Type   TypeAnnotation // Optional (can be nil for inference)
	Values []Expression   // Right-hand side values (can be single or multiple)
	Token  lexer.Token    // The identifier token or walrus token
	OnErr  *OnErrClause   // Optional onerr clause (e.g., x := f() onerr panic "msg")
}

func (*VarDeclStmt) Pos

func (s *VarDeclStmt) Pos() Position

func (*VarDeclStmt) TokenLiteral

func (s *VarDeclStmt) TokenLiteral() string

type WhenCase added in v0.0.2

type WhenCase struct {
	Token  lexer.Token // The 'when' or 'case' token
	Values []Expression
	Body   *BlockStmt
}

Jump to

Keyboard shortcuts

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