checker

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bool = &_bool{}
View Source
var Dynamic = &dynamicType{}
View Source
var Float = &float{}
View Source
var Int = &_int{}
View Source
var Str = &str{}
View Source
var Void = &void{}

Functions

func Check

func Check(input *ast.Program, moduleResolver *ModuleResolver, filePath string) (Module, []Diagnostic)

func IsMaybe

func IsMaybe(t Type) bool

Types

type And

type And struct {
	Left, Right Expression
}

func (*And) Type

func (a *And) Type() Type

type Any

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

func (Any) Actual

func (a Any) Actual() Type

func (Any) String

func (a Any) String() string

type Block

type Block struct {
	Stmts []Statement
}

func (*Block) Type

func (b *Block) Type() Type

type BoolLiteral

type BoolLiteral struct {
	Value bool
}

func (*BoolLiteral) String

func (b *BoolLiteral) String() string

func (*BoolLiteral) Type

func (b *BoolLiteral) Type() Type

type BoolMatch

type BoolMatch struct {
	Subject Expression
	True    *Block
	False   *Block
}

func (*BoolMatch) Type

func (b *BoolMatch) Type() Type

type ConditionalCase

type ConditionalCase struct {
	Condition Expression // Must be type Bool
	Body      *Block
}

type ConditionalMatch

type ConditionalMatch struct {
	Cases    []ConditionalCase
	CatchAll *Block
}

func (*ConditionalMatch) Type

func (c *ConditionalMatch) Type() Type

type CopyExpression

type CopyExpression struct {
	Expr  Expression
	Type_ Type
}

func (*CopyExpression) Type

func (c *CopyExpression) Type() Type

type Diagnostic

type Diagnostic struct {
	Kind    DiagnosticKind
	Message string
	// contains filtered or unexported fields
}

func (Diagnostic) String

func (d Diagnostic) String() string

type DiagnosticKind

type DiagnosticKind string
const (
	Error DiagnosticKind = "error"
	Warn  DiagnosticKind = "warn"
)

type EmbeddedModule

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

EmbeddedModule represents a standard library module loaded from embedded .ard files

func (EmbeddedModule) Get

func (m EmbeddedModule) Get(name string) Symbol

func (EmbeddedModule) Path

func (m EmbeddedModule) Path() string

func (EmbeddedModule) Program

func (m EmbeddedModule) Program() *Program

type Enum

type Enum struct {
	Name     string
	Private  bool
	Variants []string
	Methods  map[string]*FunctionDef
	Traits   []*Trait
	Location ast.Location
}

func (Enum) NonProducing

func (e Enum) NonProducing()

func (Enum) String

func (e Enum) String() string

func (Enum) Type

func (e Enum) Type() Type

type EnumMatch

type EnumMatch struct {
	Subject  Expression
	Cases    []*Block
	CatchAll *Block
}

func (*EnumMatch) Type

func (e *EnumMatch) Type() Type

type EnumVariant

type EnumVariant struct {
	Variant int8
	// contains filtered or unexported fields
}

func (EnumVariant) String

func (ev EnumVariant) String() string

func (EnumVariant) Type

func (ev EnumVariant) Type() Type

type Equality

type Equality struct {
	Left, Right Expression
}

func (*Equality) Type

func (n *Equality) Type() Type

type Expression

type Expression interface {
	Type() Type
}

type ExternalFunctionDef

type ExternalFunctionDef struct {
	Name            string
	Parameters      []Parameter
	ReturnType      Type
	ExternalBinding string
	Private         bool
}

func (ExternalFunctionDef) String

func (e ExternalFunctionDef) String() string

func (*ExternalFunctionDef) Type

func (e *ExternalFunctionDef) Type() Type

type FiberExecution

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

func (FiberExecution) GetMainName

func (f FiberExecution) GetMainName() string

func (FiberExecution) GetModule

func (f FiberExecution) GetModule() Module

func (FiberExecution) Type

func (f FiberExecution) Type() Type

type FloatAddition

type FloatAddition struct {
	Left  Expression
	Right Expression
}

func (*FloatAddition) Type

func (n *FloatAddition) Type() Type

type FloatDivision

type FloatDivision struct {
	Left  Expression
	Right Expression
}

func (*FloatDivision) Type

func (n *FloatDivision) Type() Type

type FloatGreater

type FloatGreater struct {
	Left  Expression
	Right Expression
}

func (*FloatGreater) Type

func (n *FloatGreater) Type() Type

type FloatGreaterEqual

type FloatGreaterEqual struct {
	Left  Expression
	Right Expression
}

func (*FloatGreaterEqual) Type

func (n *FloatGreaterEqual) Type() Type

type FloatLess

type FloatLess struct {
	Left  Expression
	Right Expression
}

func (*FloatLess) Type

func (n *FloatLess) Type() Type

type FloatLessEqual

type FloatLessEqual struct {
	Left  Expression
	Right Expression
}

func (*FloatLessEqual) Type

func (n *FloatLessEqual) Type() Type

type FloatLiteral

type FloatLiteral struct {
	Value float64
}

func (*FloatLiteral) String

func (f *FloatLiteral) String() string

func (*FloatLiteral) Type

func (f *FloatLiteral) Type() Type

type FloatMultiplication

type FloatMultiplication struct {
	Left  Expression
	Right Expression
}

func (*FloatMultiplication) Type

func (n *FloatMultiplication) Type() Type

type FloatSubtraction

type FloatSubtraction struct {
	Left  Expression
	Right Expression
}

func (*FloatSubtraction) Type

func (n *FloatSubtraction) Type() Type

type ForInList

type ForInList struct {
	Cursor string
	Index  string
	List   Expression
	Body   *Block
}

func (ForInList) NonProducing

func (f ForInList) NonProducing()

type ForInMap

type ForInMap struct {
	Key  string
	Val  string
	Map  Expression
	Body *Block
}

func (ForInMap) NonProducing

func (f ForInMap) NonProducing()

type ForInStr

type ForInStr struct {
	Cursor string
	Index  string
	Value  Expression
	Body   *Block
}

func (ForInStr) NonProducing

func (f ForInStr) NonProducing()

type ForIntRange

type ForIntRange struct {
	Cursor string
	Index  string
	Start  Expression
	End    Expression
	Body   *Block
}

func (ForIntRange) NonProducing

func (f ForIntRange) NonProducing()

type ForLoop

type ForLoop struct {
	Init      *VariableDef
	Condition Expression
	Update    *Reassignment
	Body      *Block
}

func (ForLoop) NonProducing

func (f ForLoop) NonProducing()

type FunctionCall

type FunctionCall struct {
	Name string
	Args []Expression
	// contains filtered or unexported fields
}

func CreateCall

func CreateCall(name string, args []Expression, fn FunctionDef) *FunctionCall

func (*FunctionCall) Type

func (f *FunctionCall) Type() Type

type FunctionDef

type FunctionDef struct {
	Name       string
	Parameters []Parameter
	ReturnType Type
	Mutates    bool
	Body       *Block
	Private    bool
}

func (FunctionDef) String

func (f FunctionDef) String() string

func (*FunctionDef) Type

func (f *FunctionDef) Type() Type

type GenericContext

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

type Identifier

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

func (*Identifier) Type

func (i *Identifier) Type() Type

type If

type If struct {
	Condition Expression
	Body      *Block
	ElseIf    *If
	Else      *Block
}

func (*If) Type

func (i *If) Type() Type

type InstanceMethod

type InstanceMethod struct {
	Subject Expression
	Method  *FunctionCall
}

func (*InstanceMethod) Type

func (i *InstanceMethod) Type() Type

type InstanceProperty

type InstanceProperty struct {
	Subject  Expression
	Property string
	// contains filtered or unexported fields
}

func (*InstanceProperty) String

func (i *InstanceProperty) String() string

String returns a string representation of the instance property

func (*InstanceProperty) Type

func (i *InstanceProperty) Type() Type

type IntAddition

type IntAddition struct {
	Left  Expression
	Right Expression
}

func (*IntAddition) Type

func (n *IntAddition) Type() Type

type IntDivision

type IntDivision struct {
	Left  Expression
	Right Expression
}

func (*IntDivision) Type

func (n *IntDivision) Type() Type

type IntGreater

type IntGreater struct {
	Left  Expression
	Right Expression
}

func (*IntGreater) Type

func (n *IntGreater) Type() Type

type IntGreaterEqual

type IntGreaterEqual struct {
	Left  Expression
	Right Expression
}

func (*IntGreaterEqual) Type

func (n *IntGreaterEqual) Type() Type

type IntLess

type IntLess struct {
	Left  Expression
	Right Expression
}

func (*IntLess) Type

func (n *IntLess) Type() Type

type IntLessEqual

type IntLessEqual struct {
	Left  Expression
	Right Expression
}

func (*IntLessEqual) Type

func (n *IntLessEqual) Type() Type

type IntLiteral

type IntLiteral struct {
	Value int
}

func (*IntLiteral) String

func (i *IntLiteral) String() string

func (*IntLiteral) Type

func (i *IntLiteral) Type() Type

type IntMatch

type IntMatch struct {
	Subject    Expression
	IntCases   map[int]*Block      // keys are integer values
	RangeCases map[IntRange]*Block // keys are integer ranges
	CatchAll   *Block
}

func (*IntMatch) Type

func (i *IntMatch) Type() Type

type IntModulo

type IntModulo struct {
	Left  Expression
	Right Expression
}

func (*IntModulo) Type

func (n *IntModulo) Type() Type

type IntMultiplication

type IntMultiplication struct {
	Left  Expression
	Right Expression
}

func (*IntMultiplication) Type

func (n *IntMultiplication) Type() Type

type IntRange

type IntRange struct {
	Start int
	End   int
}

type IntSubtraction

type IntSubtraction struct {
	Left  Expression
	Right Expression
}

func (*IntSubtraction) Type

func (n *IntSubtraction) Type() Type

type List

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

func MakeList

func MakeList(of Type) *List

func (List) Of

func (l List) Of() Type

func (List) String

func (l List) String() string

type ListLiteral

type ListLiteral struct {
	Elements []Expression
	// contains filtered or unexported fields
}

func (*ListLiteral) Type

func (l *ListLiteral) Type() Type

type Map

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

func MakeMap

func MakeMap(key, value Type) *Map

func (*Map) Key

func (m *Map) Key() Type

func (Map) String

func (m Map) String() string

func (*Map) Value

func (m *Map) Value() Type

type MapLiteral

type MapLiteral struct {
	Keys   []Expression
	Values []Expression
	// contains filtered or unexported fields
}

func (*MapLiteral) Type

func (m *MapLiteral) Type() Type

type Match

type Match struct {
	Pattern *Identifier
	Body    *Block
}

type Maybe

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

func MakeMaybe

func MakeMaybe(of Type) *Maybe

func (*Maybe) Of

func (m *Maybe) Of() Type

func (*Maybe) String

func (m *Maybe) String() string

type MaybePkg

type MaybePkg struct{}

ard/maybe

func (MaybePkg) Get

func (pkg MaybePkg) Get(name string) Symbol

func (MaybePkg) Path

func (pkg MaybePkg) Path() string

func (MaybePkg) Program

func (pkg MaybePkg) Program() *Program

type Module

type Module interface {
	Path() string
	Get(name string) Symbol
	Program() *Program
}

func FindEmbeddedModule

func FindEmbeddedModule(path string) (Module, bool)

findEmbeddedModule loads a .ard standard library module from embedded files

type ModuleFunctionCall

type ModuleFunctionCall struct {
	Module string
	Call   *FunctionCall
}

func (*ModuleFunctionCall) Type

func (p *ModuleFunctionCall) Type() Type

type ModuleResolver

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

ModuleResolver handles finding and loading user modules

func NewModuleResolver

func NewModuleResolver(workingDir string) (*ModuleResolver, error)

NewModuleResolver creates a new module resolver for the given working directory

func (*ModuleResolver) GetProjectInfo

func (mr *ModuleResolver) GetProjectInfo() *ProjectInfo

GetProjectInfo returns the current project information

func (*ModuleResolver) LoadModule

func (mr *ModuleResolver) LoadModule(importPath string) (*ast.Program, error)

LoadModule loads and parses a module file from the given import path

func (*ModuleResolver) LoadModuleWithDependencies

func (mr *ModuleResolver) LoadModuleWithDependencies(importPath string) (*ast.Program, error)

LoadModuleWithDependencies loads a module and all its dependencies, detecting circular dependencies

func (*ModuleResolver) ResolveImportPath

func (mr *ModuleResolver) ResolveImportPath(importPath string) (string, error)

ResolveImportPath converts an import path to a file system path Example: "my_project/utils" -> "utils.ard" Example: "my_project/math/operations" -> "math/operations.ard"

type ModuleStructInstance

type ModuleStructInstance struct {
	Module   string
	Property *StructInstance
}

func (*ModuleStructInstance) Type

func (p *ModuleStructInstance) Type() Type

type ModuleSymbol

type ModuleSymbol struct {
	Module string
	Symbol Symbol
}

func (*ModuleSymbol) Type

func (p *ModuleSymbol) Type() Type

type Negation

type Negation struct {
	Value Expression
}

func (*Negation) String

func (n *Negation) String() string

func (*Negation) Type

func (n *Negation) Type() Type

type NonProducing

type NonProducing interface {
	NonProducing()
}

type Not

type Not struct {
	Value Expression
}

func (*Not) String

func (n *Not) String() string

func (*Not) Type

func (n *Not) Type() Type

type OptionMatch

type OptionMatch struct {
	Subject Expression
	Some    *Match
	None    *Block
}

func (*OptionMatch) Type

func (o *OptionMatch) Type() Type

type Or

type Or struct {
	Left, Right Expression
}

func (*Or) Type

func (o *Or) Type() Type

type Panic

type Panic struct {
	Message Expression
	// contains filtered or unexported fields
}

func (Panic) GetLocation

func (p Panic) GetLocation() ast.Location

func (Panic) Type

func (p Panic) Type() Type

type Parameter

type Parameter struct {
	Name    string
	Type    Type
	Mutable bool
}

type Program

type Program struct {
	Imports    map[string]Module
	Statements []Statement
}

type ProjectInfo

type ProjectInfo struct {
	RootPath    string // absolute path to project root
	ProjectName string // project name from ard.toml or directory name
}

ProjectInfo holds information about the current project

type Reassignment

type Reassignment struct {
	Target Expression
	Value  Expression
}

func (*Reassignment) NonProducing

func (r *Reassignment) NonProducing()

type Result

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

func MakeResult

func MakeResult(val, err Type) *Result

func (*Result) Err

func (r *Result) Err() Type

func (Result) String

func (r Result) String() string

func (*Result) Val

func (r *Result) Val() Type

type ResultMatch

type ResultMatch struct {
	Subject Expression
	Ok      *Match
	Err     *Match
}

func (ResultMatch) Type

func (r ResultMatch) Type() Type

type ResultPkg

type ResultPkg struct {
}

func (ResultPkg) Get

func (pkg ResultPkg) Get(name string) Symbol

func (ResultPkg) Path

func (pkg ResultPkg) Path() string

func (ResultPkg) Program

func (pkg ResultPkg) Program() *Program

type Statement

type Statement struct {
	Break bool
	Expr  Expression
	Stmt  NonProducing
}

can either produce a value or not

type StrAddition

type StrAddition struct {
	Left  Expression
	Right Expression
}

func (*StrAddition) Type

func (n *StrAddition) Type() Type

type StrLiteral

type StrLiteral struct {
	Value string
}

func (*StrLiteral) String

func (s *StrLiteral) String() string

func (*StrLiteral) Type

func (s *StrLiteral) Type() Type

type StructDef

type StructDef struct {
	Name    string
	Fields  map[string]Type
	Methods map[string]*FunctionDef
	Self    string
	Traits  []*Trait
	Private bool
}

func (StructDef) NonProducing

func (def StructDef) NonProducing()

func (StructDef) String

func (def StructDef) String() string

type StructInstance

type StructInstance struct {
	Name   string
	Fields map[string]Expression
	// contains filtered or unexported fields
}

func (StructInstance) Type

func (s StructInstance) Type() Type

type Symbol

type Symbol struct {
	Name string
	Type Type
	// contains filtered or unexported fields
}

func (Symbol) IsZero

func (s Symbol) IsZero() bool

type SymbolTable

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

type TemplateStr

type TemplateStr struct {
	Chunks []Expression
}

func (*TemplateStr) String

func (t *TemplateStr) String() string

func (*TemplateStr) Type

func (t *TemplateStr) Type() Type

type Trait

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

func (Trait) GetMethods

func (t Trait) GetMethods() []FunctionDef

func (Trait) String

func (t Trait) String() string

type TryOp

type TryOp struct {
	CatchBlock *Block
	CatchVar   string
	// contains filtered or unexported fields
}

func (TryOp) Expr

func (t TryOp) Expr() Expression

func (TryOp) Type

func (t TryOp) Type() Type

type Type

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

type Union

type Union struct {
	Name  string
	Types []Type
}

func (Union) NonProducing

func (u Union) NonProducing()

func (Union) String

func (u Union) String() string

func (Union) Type

func (u Union) Type() Type

type UnionMatch

type UnionMatch struct {
	Subject   Expression
	TypeCases map[string]*Match
	CatchAll  *Block
}

func (*UnionMatch) Type

func (u *UnionMatch) Type() Type

type UserModule

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

UserModule represents a user-defined module that implements the Module interface

func NewUserModule

func NewUserModule(filePath string, program *Program, globalScope *SymbolTable) *UserModule

NewUserModule creates a UserModule from a checked program, extracting only public symbols

func (*UserModule) Get

func (m *UserModule) Get(name string) Symbol

Get returns a public symbol by name, or nil if not found or private

func (*UserModule) Path

func (m *UserModule) Path() string

Path returns the file path for this module

func (*UserModule) Program

func (m *UserModule) Program() *Program

Program returns the checked program for this module

type Variable

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

func (Variable) Name

func (v Variable) Name() string

func (Variable) String

func (v Variable) String() string

func (Variable) Type

func (v Variable) Type() Type

type VariableDef

type VariableDef struct {
	Mutable bool
	Name    string

	Value Expression
	// contains filtered or unexported fields
}

func (*VariableDef) NonProducing

func (v *VariableDef) NonProducing()

func (*VariableDef) Type

func (v *VariableDef) Type() Type

type VoidLiteral

type VoidLiteral struct{}

func (*VoidLiteral) String

func (v *VoidLiteral) String() string

func (*VoidLiteral) Type

func (v *VoidLiteral) Type() Type

type WhileLoop

type WhileLoop struct {
	Condition Expression
	Body      *Block
}

func (WhileLoop) NonProducing

func (w WhileLoop) NonProducing()

Jump to

Keyboard shortcuts

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