ast

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLexer

func NewLexer(source []byte) *lexer

Types

type AnonymousFunction

type AnonymousFunction struct {
	Location
	Parameters []Parameter
	ReturnType DeclaredType
	Body       []Statement
}

func (AnonymousFunction) String

func (a AnonymousFunction) String() string

type Argument

type Argument struct {
	Location
	Name    string
	Value   Expression
	Mutable bool
}

type BinaryExpression

type BinaryExpression struct {
	Location
	Operator    Operator
	Left, Right Expression
}

func (BinaryExpression) String

func (b BinaryExpression) String() string

type BoolLiteral

type BoolLiteral struct {
	Location
	Value bool
}

func (BoolLiteral) String

func (b BoolLiteral) String() string

impl interfaces

type BooleanType

type BooleanType struct {
	Location
	// contains filtered or unexported fields
}

func (BooleanType) GetName

func (s BooleanType) GetName() string

func (BooleanType) IsNullable

func (v BooleanType) IsNullable() bool

type Break

type Break struct{ Location }

func (Break) String

func (b Break) String() string

type Comment

type Comment struct {
	Location
	Value string
}

func (Comment) String

func (c Comment) String() string

type ConditionalMatchCase

type ConditionalMatchCase struct {
	Location
	Condition Expression // The boolean condition to evaluate (nil for catch-all case)
	Body      []Statement
}

func (ConditionalMatchCase) String

func (c ConditionalMatchCase) String() string

type ConditionalMatchExpression

type ConditionalMatchExpression struct {
	Location
	Cases    []ConditionalMatchCase
	Comments []Comment // Comments found within the match expression
}

func (ConditionalMatchExpression) String

type CustomType

type CustomType struct {
	Location
	Name string
	Type StaticProperty

	Private  bool
	TypeArgs []DeclaredType
	// contains filtered or unexported fields
}

func (CustomType) GetName

func (u CustomType) GetName() string

func (CustomType) IsNullable

func (u CustomType) IsNullable() bool

func (CustomType) String

func (u CustomType) String() string

type DeclaredType

type DeclaredType interface {
	GetName() string
	IsNullable() bool
	GetLocation() Location
}

type Document

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

func MakeDoc

func MakeDoc(content string) Document

func (*Document) Append

func (d *Document) Append(doc Document) *Document

func (*Document) Dedent

func (d *Document) Dedent() *Document

func (*Document) Indent

func (d *Document) Indent() *Document

func (*Document) Line

func (d *Document) Line(line string) *Document

func (*Document) Nest

func (d *Document) Nest(doc Document) *Document

func (Document) String

func (d Document) String() string

type EnumDefinition

type EnumDefinition struct {
	Location
	Name     string
	Variants []string
	Private  bool
	Comments []Comment // Comments found within the enum definition
}

func (EnumDefinition) String

func (e EnumDefinition) String() string

type Expression

type Expression interface {
	Statement
}

type ExternalFunction

type ExternalFunction struct {
	Location
	Name            string
	Parameters      []Parameter
	ReturnType      DeclaredType
	ExternalBinding string
	Private         bool
}

func (ExternalFunction) String

func (e ExternalFunction) String() string

type FloatType

type FloatType struct {
	Location
	// contains filtered or unexported fields
}

func (FloatType) GetName

func (f FloatType) GetName() string

func (FloatType) IsNullable

func (f FloatType) IsNullable() bool

type ForInLoop

type ForInLoop struct {
	Location
	Cursor   Identifier
	Cursor2  Identifier
	Iterable Expression
	Body     []Statement
}

func (ForInLoop) String

func (f ForInLoop) String() string

type ForLoop

type ForLoop struct {
	Location
	Init        *VariableDeclaration
	Condition   Expression
	Incrementer Statement
	Body        []Statement
}

func (ForLoop) String

func (f ForLoop) String() string

type FunctionCall

type FunctionCall struct {
	Location
	Name     string
	TypeArgs []DeclaredType
	Args     []Argument
	Comments []Comment // Comments found within the function call
}

func (FunctionCall) String

func (f FunctionCall) String() string

type FunctionDeclaration

type FunctionDeclaration struct {
	Location
	Name       string
	Mutates    bool
	Parameters []Parameter
	ReturnType DeclaredType
	Body       []Statement
	Private    bool
	Comments   []Comment // Comments found within the function declaration
}

func (FunctionDeclaration) String

func (f FunctionDeclaration) String() string

type FunctionType

type FunctionType struct {
	Location
	Nullable bool
	Params   []DeclaredType
	Return   DeclaredType
}

func (FunctionType) GetName

func (f FunctionType) GetName() string

func (FunctionType) IsNullable

func (f FunctionType) IsNullable() bool

type GenericType

type GenericType struct {
	Location
	Name string
	// contains filtered or unexported fields
}

func (GenericType) GetName

func (g GenericType) GetName() string

func (GenericType) IsNullable

func (g GenericType) IsNullable() bool

func (GenericType) String

func (g GenericType) String() string

type Identifier

type Identifier struct {
	Location
	Name string
}

func (Identifier) String

func (i Identifier) String() string

type IfStatement

type IfStatement struct {
	Location
	Condition Expression
	Body      []Statement
	Else      Statement
}

func (IfStatement) String

func (i IfStatement) String() string

type ImplBlock

type ImplBlock struct {
	Location
	Target   Identifier
	Methods  []FunctionDeclaration
	Comments []Comment // Comments found within the impl block
}

func (ImplBlock) String

func (i ImplBlock) String() string

type Import

type Import struct {
	Path string
	Name string
	Location
}

func (Import) String

func (p Import) String() string

type InstanceMethod

type InstanceMethod struct {
	Location
	Target Expression
	Method FunctionCall
}

func (InstanceMethod) String

func (im InstanceMethod) String() string

type InstanceProperty

type InstanceProperty struct {
	Location
	Target   Expression
	Property Identifier
}

func (InstanceProperty) String

func (ip InstanceProperty) String() string

type IntType

type IntType struct {
	Location
	// contains filtered or unexported fields
}

func (IntType) GetName

func (s IntType) GetName() string

func (IntType) IsNullable

func (v IntType) IsNullable() bool

type InterpolatedStr

type InterpolatedStr struct {
	Location
	Chunks []Expression
}

func (InterpolatedStr) String

func (i InterpolatedStr) String() string

type List

type List struct {
	Location
	Element DeclaredType
	// contains filtered or unexported fields
}

func (List) GetName

func (s List) GetName() string

func (List) IsNullable

func (v List) IsNullable() bool

type ListLiteral

type ListLiteral struct {
	Location
	Items    []Expression
	Comments []Comment // Comments found within the list literal
}

func (ListLiteral) String

func (l ListLiteral) String() string

type Location

type Location struct {
	Start Point
	End   Point
}

func (Location) GetLocation

func (l Location) GetLocation() Location

func (Location) GetStart

func (l Location) GetStart() Point

func (Location) String

func (l Location) String() string

type Map

type Map struct {
	Location
	Key   DeclaredType
	Value DeclaredType
	// contains filtered or unexported fields
}

func (Map) GetName

func (s Map) GetName() string

func (Map) IsNullable

func (v Map) IsNullable() bool

type MapEntry

type MapEntry struct {
	Key   Expression
	Value Expression
}

type MapLiteral

type MapLiteral struct {
	Location
	Entries  []MapEntry
	Comments []Comment // Comments found within the map literal
}

func (MapLiteral) String

func (m MapLiteral) String() string

type MatchCase

type MatchCase struct {
	Location
	Pattern Expression
	Body    []Statement
}

func (MatchCase) String

func (m MatchCase) String() string

type MatchExpression

type MatchExpression struct {
	Location
	Subject  Expression
	Cases    []MatchCase
	Comments []Comment // Comments found within the match expression
}

func (MatchExpression) String

func (m MatchExpression) String() string

type NumLiteral

type NumLiteral struct {
	Location
	Value string
}

func (NumLiteral) String

func (n NumLiteral) String() string

type Operator

type Operator int
const (
	InvalidOp Operator = iota
	Bang
	Minus
	Decrement
	Plus
	Increment
	Divide
	Multiply
	Modulo
	GreaterThan
	GreaterThanOrEqual
	LessThan
	LessThanOrEqual
	Equal
	NotEqual
	And
	Not
	Or
	Range
	Assign
)

type Parameter

type Parameter struct {
	Location
	Name    string
	Type    DeclaredType
	Mutable bool
}

func (Parameter) String

func (p Parameter) String() string

type ParseError

type ParseError struct {
	Location Location
	Message  string
}

type ParseResult

type ParseResult struct {
	Program *Program
	Errors  []ParseError
	// contains filtered or unexported fields
}

func Parse

func Parse(source []byte, fileName string) ParseResult

func (ParseResult) PrintErrors

func (pr ParseResult) PrintErrors()

type Point

type Point struct {
	Row int
	Col int
}

func (Point) String

func (p Point) String() string

type Program

type Program struct {
	Imports    []Import
	Statements []Statement
}

type RangeExpression

type RangeExpression struct {
	Location
	Start, End Expression
}

func (RangeExpression) String

func (b RangeExpression) String() string

type RangeLoop

type RangeLoop struct {
	Location
	Cursor  Identifier
	Cursor2 Identifier
	Start   Expression
	End     Expression
	Body    []Statement
}

func (RangeLoop) String

func (r RangeLoop) String() string

type ResultType

type ResultType struct {
	Location
	Val, Err DeclaredType
	// contains filtered or unexported fields
}

func (ResultType) GetName

func (r ResultType) GetName() string

func (ResultType) IsNullable

func (r ResultType) IsNullable() bool

type Statement

type Statement interface {
	String() string
	GetLocation() Location
}

type StaticFunction

type StaticFunction struct {
	Location
	Target   Expression
	Function FunctionCall
}

func (StaticFunction) String

func (s StaticFunction) String() string

type StaticFunctionDeclaration

type StaticFunctionDeclaration struct {
	FunctionDeclaration
	Path StaticProperty
}

func (StaticFunctionDeclaration) String

func (f StaticFunctionDeclaration) String() string

type StaticProperty

type StaticProperty struct {
	Location
	Target   Expression
	Property Expression
}

func (StaticProperty) String

func (s StaticProperty) String() string

type StrLiteral

type StrLiteral struct {
	Location
	Value string
}

func (StrLiteral) String

func (s StrLiteral) String() string

type StringType

type StringType struct {
	Location
	// contains filtered or unexported fields
}

func (StringType) GetName

func (s StringType) GetName() string

func (StringType) IsNullable

func (v StringType) IsNullable() bool

type StructDefinition

type StructDefinition struct {
	Location
	Name     Identifier
	Fields   []StructField
	Private  bool
	Comments []Comment // Comments found within the struct definition
}

func (StructDefinition) String

func (s StructDefinition) String() string

type StructField

type StructField struct {
	Name Identifier
	Type DeclaredType
}

type StructInstance

type StructInstance struct {
	Location
	Name       Identifier
	Properties []StructValue
	Comments   []Comment // Comments found within the struct instance
}

func (StructInstance) String

func (s StructInstance) String() string

type StructValue

type StructValue struct {
	Location
	Name  Identifier
	Value Expression
}

type TraitDefinition

type TraitDefinition struct {
	Location
	Name     Identifier
	Methods  []FunctionDeclaration
	Private  bool
	Comments []Comment // Comments found within the trait definition
}

func (TraitDefinition) String

func (t TraitDefinition) String() string

type TraitImplementation

type TraitImplementation struct {
	Location
	Trait   Expression // Identifier | StaticProperty
	ForType Identifier
	Methods []FunctionDeclaration
}

func (TraitImplementation) String

func (t TraitImplementation) String() string

type Try

type Try struct {
	Location

	Expression Expression
	CatchVar   *Identifier // nil if no catch clause
	CatchBlock []Statement // nil if no catch clause
	// contains filtered or unexported fields
}

func (Try) String

func (t Try) String() string

type TypeDeclaration

type TypeDeclaration struct {
	Location
	Name    Identifier
	Type    []DeclaredType
	Private bool
}

func (TypeDeclaration) String

func (t TypeDeclaration) String() string

type UnaryExpression

type UnaryExpression struct {
	Location
	Operator Operator
	Operand  Expression
}

func (UnaryExpression) String

func (u UnaryExpression) String() string

impl interfaces

type VariableAssignment

type VariableAssignment struct {
	Location
	Target   Expression
	Operator Operator
	Value    Expression
}

func (VariableAssignment) String

func (v VariableAssignment) String() string

impl interfaces

type VariableDeclaration

type VariableDeclaration struct {
	Location
	Name    string
	Mutable bool
	Value   Expression
	Type    DeclaredType
}

func (VariableDeclaration) String

func (v VariableDeclaration) String() string

type VoidLiteral

type VoidLiteral struct {
	Location
}

func (VoidLiteral) String

func (v VoidLiteral) String() string

type VoidType

type VoidType struct {
	Location
	// contains filtered or unexported fields
}

func (VoidType) GetName

func (v VoidType) GetName() string

func (VoidType) IsNullable

func (v VoidType) IsNullable() bool

type WhileLoop

type WhileLoop struct {
	Location
	Condition Expression
	Body      []Statement
}

func (WhileLoop) String

func (w WhileLoop) String() string

Jump to

Keyboard shortcuts

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