ast

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ADTVariantDecl

type ADTVariantDecl struct {
	Name   *Identifier
	Fields []*Identifier
}

type ArrayLiteral

type ArrayLiteral struct {
	Elements []Expression
}

func (*ArrayLiteral) String

func (al *ArrayLiteral) String() string

type ArrayPattern

type ArrayPattern struct {
	Elements []Pattern
	Rest     *Identifier
}

func (*ArrayPattern) String

func (p *ArrayPattern) String() string

type AssignExpression

type AssignExpression struct {
	Target Expression
	Value  Expression
}

func (*AssignExpression) String

func (ae *AssignExpression) String() string

type AwaitExpression

type AwaitExpression struct {
	Value Expression
}

func (*AwaitExpression) String

func (ae *AwaitExpression) String() string

type BindingPattern

type BindingPattern struct {
	Name     *Identifier
	TypeName string
}

func (*BindingPattern) String

func (p *BindingPattern) String() string

type BlockStatement

type BlockStatement struct {
	Statements []Statement
}

func (*BlockStatement) String

func (bs *BlockStatement) String() string

type BooleanLiteral

type BooleanLiteral struct {
	Value bool
}

func (*BooleanLiteral) String

func (bl *BooleanLiteral) String() string

type BreakStatement

type BreakStatement struct{}

func (*BreakStatement) String

func (bs *BreakStatement) String() string

type CallExpression

type CallExpression struct {
	Function  Expression
	Arguments []Expression
	Line      int
	Column    int
}

func (*CallExpression) String

func (ce *CallExpression) String() string

type ChannelReceiveExpression

type ChannelReceiveExpression struct{ Channel Expression }

ChannelReceiveExpression receives a value using postfix `channel <-`.

func (*ChannelReceiveExpression) String

func (e *ChannelReceiveExpression) String() string

type ChannelSendExpression

type ChannelSendExpression struct {
	Channel Expression
	Value   Expression
}

ChannelSendExpression sends Value to Channel using `channel <- value`.

func (*ChannelSendExpression) String

func (e *ChannelSendExpression) String() string

type ClassField

type ClassField struct {
	Name      *Identifier
	Value     Expression
	IsStatic  bool
	IsPrivate bool
}

func (*ClassField) String

func (cf *ClassField) String() string

type ClassMethod

type ClassMethod struct {
	Name          *Identifier
	Parameters    []*Identifier
	ParamTypes    []string
	ParamTypeRefs []*TypeRef
	Defaults      []Expression
	ReturnType    string
	ReturnTypeRef *TypeRef
	HasRest       bool
	Body          *BlockStatement
	IsConstructor bool
	IsStatic      bool
	IsAbstract    bool
	IsPrivate     bool
}

func (*ClassMethod) String

func (cm *ClassMethod) String() string

type ClassStatement

type ClassStatement struct {
	Name       *Identifier
	Parent     *Identifier
	Implements []*Identifier
	Methods    []*ClassMethod
	Fields     []*ClassField
	IsAbstract bool
}

func (*ClassStatement) String

func (cs *ClassStatement) String() string

type ComparisonPattern

type ComparisonPattern struct {
	Operator token.TokenType
	Value    Expression
}

func (*ComparisonPattern) String

func (p *ComparisonPattern) String() string

type CompoundAssignExpression

type CompoundAssignExpression struct {
	Target   Expression
	Operator string
	Value    Expression
}

func (*CompoundAssignExpression) String

func (ca *CompoundAssignExpression) String() string

type ConstructorPattern

type ConstructorPattern struct {
	Name string
	Args []Pattern
}

func (*ConstructorPattern) String

func (p *ConstructorPattern) String() string

type ContinueStatement

type ContinueStatement struct{}

func (*ContinueStatement) String

func (cs *ContinueStatement) String() string

type DestructureLetStatement

type DestructureLetStatement struct {
	Pattern *DestructurePattern
	Value   Expression
	IsConst bool
}

func (*DestructureLetStatement) String

func (d *DestructureLetStatement) String() string

type DestructurePattern

type DestructurePattern struct {
	Kind     string
	Keys     []Expression
	Names    []*Identifier
	Defaults []Expression
	RestName *Identifier
}

type DoWhileStatement

type DoWhileStatement struct {
	Body      *BlockStatement
	Condition Expression
}

func (*DoWhileStatement) String

func (dw *DoWhileStatement) String() string

type DotExpression

type DotExpression struct {
	Left  Expression
	Right *Identifier
}

func (*DotExpression) String

func (de *DotExpression) String() string

type ExportStatement

type ExportStatement struct {
	Declaration Statement
	IsConst     bool
}

func (*ExportStatement) String

func (es *ExportStatement) String() string

type Expression

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

Expression is the interface for all expression nodes.

type ExpressionStatement

type ExpressionStatement struct {
	Expression Expression
}

func (*ExpressionStatement) String

func (es *ExpressionStatement) String() string

type ExtractorPattern

type ExtractorPattern struct {
	Name string
	Args []Pattern
}

func (*ExtractorPattern) String

func (p *ExtractorPattern) String() string

type FloatLiteral

type FloatLiteral struct {
	Value float64
}

func (*FloatLiteral) String

func (fl *FloatLiteral) String() string

type ForAwaitStatement

type ForAwaitStatement struct {
	KeyName   *Identifier
	ValueName *Identifier
	Iterable  Expression
	Body      *BlockStatement
}

func (*ForAwaitStatement) String

func (fa *ForAwaitStatement) String() string

type ForInStatement

type ForInStatement struct {
	KeyName   *Identifier
	ValueName *Identifier
	Iterable  Expression
	Body      *BlockStatement
}

func (*ForInStatement) String

func (fi *ForInStatement) String() string

type ForStatement

type ForStatement struct {
	Init      Statement
	Condition Expression
	Post      Statement
	Body      *BlockStatement
}

func (*ForStatement) String

func (fs *ForStatement) String() string

type FunctionLiteral

type FunctionLiteral struct {
	Name          *Identifier
	Parameters    []*Identifier
	ParamTypes    []string
	ParamTypeRefs []*TypeRef
	Defaults      []Expression
	ReturnType    string
	ReturnTypeRef *TypeRef
	HasRest       bool
	Body          *BlockStatement
	IsArrow       bool
	IsAsync       bool
}

func (*FunctionLiteral) String

func (fl *FunctionLiteral) String() string

type HashEntry

type HashEntry struct {
	Key        Expression
	Value      Expression
	IsSpread   bool
	IsComputed bool
}

type HashLiteral

type HashLiteral struct {
	Entries []HashEntry
}

func (*HashLiteral) String

func (hl *HashLiteral) String() string

type Identifier

type Identifier struct {
	Name string
}

func (*Identifier) String

func (i *Identifier) String() string

type IfExpression

type IfExpression struct {
	Condition   Expression
	Consequence *BlockStatement
	Alternative *BlockStatement
}

func (*IfExpression) String

func (ie *IfExpression) String() string

type ImportSpecifier

type ImportSpecifier struct {
	Imported *Identifier
	Local    *Identifier
}

type ImportStatement

type ImportStatement struct {
	Path       Expression
	Alias      *Identifier
	Names      []*Identifier
	Specifiers []ImportSpecifier
}

func (*ImportStatement) String

func (is *ImportStatement) String() string

type IndexExpression

type IndexExpression struct {
	Left  Expression
	Index Expression
}

func (*IndexExpression) String

func (ie *IndexExpression) String() string

type InfixExpression

type InfixExpression struct {
	Left     Expression
	Operator string
	Right    Expression
}

func (*InfixExpression) String

func (ie *InfixExpression) String() string

type InitStatement

type InitStatement struct {
	Body *BlockStatement
}

func (*InitStatement) String

func (is *InitStatement) String() string

type IntegerLiteral

type IntegerLiteral struct {
	Value int64
}

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

type InterfaceMethod

type InterfaceMethod struct {
	Name          *Identifier
	Parameters    []*Identifier
	ParamTypes    []string
	ParamTypeRefs []*TypeRef
	ReturnType    string
	ReturnTypeRef *TypeRef
}

func (*InterfaceMethod) String

func (im *InterfaceMethod) String() string

type InterfaceStatement

type InterfaceStatement struct {
	Name    *Identifier
	Methods []*InterfaceMethod
}

func (*InterfaceStatement) String

func (is *InterfaceStatement) String() string

type LazyExpression

type LazyExpression struct {
	Value Expression
}

func (*LazyExpression) String

func (le *LazyExpression) String() string

type LetStatement

type LetStatement struct {
	Name     *Identifier
	Names    []*Identifier
	TypeName string
	Type     *TypeRef
	Value    Expression
	IsConst  bool
}

func (*LetStatement) String

func (ls *LetStatement) String() string

type LiteralPattern

type LiteralPattern struct{ Value Expression }

func (*LiteralPattern) String

func (p *LiteralPattern) String() string

type MacroCallExpression

type MacroCallExpression struct {
	Name      *Identifier
	Arguments []Expression
	Block     *BlockStatement
}

MacroCallExpression preserves unevaluated arguments and an optional trailing block so the evaluator can perform hygienic AST substitution.

func (*MacroCallExpression) String

func (mc *MacroCallExpression) String() string

type MacroDefinition

type MacroDefinition struct {
	Name       *Identifier
	Parameters []*Identifier
	Body       *BlockStatement
}

func (*MacroDefinition) String

func (md *MacroDefinition) String() string

type MatchCase

type MatchCase struct {
	Pattern Pattern
	Guard   Expression
	Body    *BlockStatement
	Line    int
}

type MatchExpression

type MatchExpression struct {
	Value Expression
	Cases []*MatchCase
}

func (*MatchExpression) String

func (me *MatchExpression) String() string

type Node

type Node interface {
	String() string
}

Node is the interface implemented by all AST nodes.

type NullLiteral

type NullLiteral struct{}

func (*NullLiteral) String

func (nl *NullLiteral) String() string

type ObjectPattern

type ObjectPattern struct {
	Keys     []string
	Patterns []Pattern
	Rest     *Identifier
}

func (*ObjectPattern) String

func (p *ObjectPattern) String() string

type OptionalDotExpression

type OptionalDotExpression struct {
	Left  Expression
	Right *Identifier
}

func (*OptionalDotExpression) String

func (od *OptionalDotExpression) String() string

type OrPattern

type OrPattern struct{ Patterns []Pattern }

func (*OrPattern) String

func (p *OrPattern) String() string

type Pattern

type Pattern interface {
	String() string
	// contains filtered or unexported methods
}

Pattern is the interface for all pattern types in match expressions.

type PostfixExpression

type PostfixExpression struct {
	Operator string
	Target   Expression
}

func (*PostfixExpression) String

func (pe *PostfixExpression) String() string

type PrefixExpression

type PrefixExpression struct {
	Operator string
	Right    Expression
}

func (*PrefixExpression) String

func (pe *PrefixExpression) String() string

type PrintStatement

type PrintStatement struct {
	Expression Expression
}

func (*PrintStatement) String

func (ps *PrintStatement) String() string

type Program

type Program struct {
	Statements []Statement
}

Program is the root node of the AST.

func (*Program) String

func (p *Program) String() string

type RangeExpression

type RangeExpression struct {
	Left  Expression
	Right Expression
}

func (*RangeExpression) String

func (re *RangeExpression) String() string

type RangePattern

type RangePattern struct {
	Low  Expression
	High Expression
}

func (*RangePattern) String

func (p *RangePattern) String() string

type ReturnStatement

type ReturnStatement struct {
	ReturnValue Expression
}

func (*ReturnStatement) String

func (rs *ReturnStatement) String() string

type SelectCase

type SelectCase struct {
	Channel Expression
	Value   *Identifier
	Body    *BlockStatement
	IsRecv  bool
}

type SelectStatement

type SelectStatement struct {
	Cases   []*SelectCase
	Default *BlockStatement
}

func (*SelectStatement) String

func (ss *SelectStatement) String() string

type SpawnExpression

type SpawnExpression struct {
	Function Expression
	Args     []Expression
}

func (*SpawnExpression) String

func (se *SpawnExpression) String() string

type SpreadExpression

type SpreadExpression struct {
	Value Expression
}

func (*SpreadExpression) String

func (se *SpreadExpression) String() string

type Statement

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

Statement is the interface for all statement nodes.

type StreamLiteral

type StreamLiteral struct {
	Elements []Expression
}

func (*StreamLiteral) String

func (sl *StreamLiteral) String() string

type StringLiteral

type StringLiteral struct {
	Value string
}

func (*StringLiteral) String

func (sl *StringLiteral) String() string

type SwitchCase

type SwitchCase struct {
	Values []Expression
	Body   *BlockStatement
}

type SwitchStatement

type SwitchStatement struct {
	Value   Expression
	Cases   []*SwitchCase
	Default *BlockStatement
}

func (*SwitchStatement) String

func (ss *SwitchStatement) String() string

type TaggedBlockLiteral

type TaggedBlockLiteral struct {
	Tag  string
	Code string
}

func (*TaggedBlockLiteral) String

func (tbl *TaggedBlockLiteral) String() string

type TemplateLiteral

type TemplateLiteral struct {
	Parts []Expression
}

func (*TemplateLiteral) String

func (tl *TemplateLiteral) String() string

type TernaryExpression

type TernaryExpression struct {
	Condition   Expression
	Consequence Expression
	Alternative Expression
}

func (*TernaryExpression) String

func (te *TernaryExpression) String() string

type TestStatement

type TestStatement struct {
	Name string
	Body *BlockStatement
}

func (*TestStatement) String

func (ts *TestStatement) String() string

type ThrowStatement

type ThrowStatement struct {
	Value Expression
}

func (*ThrowStatement) String

func (ts *ThrowStatement) String() string

type TryCatchExpression

type TryCatchExpression struct {
	TryBlock     *BlockStatement
	CatchIdent   *Identifier
	CatchType    string
	CatchBlock   *BlockStatement
	FinallyBlock *BlockStatement
}

func (*TryCatchExpression) String

func (tce *TryCatchExpression) String() string

type TypeDeclarationStatement

type TypeDeclarationStatement struct {
	Name     *Identifier
	Variants []*ADTVariantDecl
}

func (*TypeDeclarationStatement) String

func (td *TypeDeclarationStatement) String() string

type TypeRef

type TypeRef struct {
	Name       string
	Arguments  []*TypeRef
	Union      []*TypeRef
	ArrayDepth int
	Nullable   bool
}

TypeRef is the structured representation of an SPL type annotation. Name is populated for named/generic types, Arguments contains generic parameters, Union contains alternatives, and ArrayDepth/Nullable preserve suffix forms.

func ParseTypeRef

func ParseTypeRef(input string) *TypeRef

ParseTypeRef builds a structured type tree from the canonical parser text.

func (*TypeRef) String

func (t *TypeRef) String() string

type WhileStatement

type WhileStatement struct {
	Condition Expression
	Body      *BlockStatement
}

func (*WhileStatement) String

func (ws *WhileStatement) String() string

type WildcardPattern

type WildcardPattern struct{}

func (*WildcardPattern) String

func (p *WildcardPattern) String() string

type YieldStatement

type YieldStatement struct {
	Value Expression
}

func (*YieldStatement) String

func (ys *YieldStatement) String() string

Jump to

Keyboard shortcuts

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