expressions

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryExpr

type BinaryExpr struct {
	Expr
	interfaces.SourceLocation

	Left     Expr
	Operator tokens.Token
	Right    Expr
}

func (BinaryExpr) Accept

func (BinaryExpr) ExprType added in v0.0.8

func (b BinaryExpr) ExprType() ExprType

func (BinaryExpr) ReturnType

func (b BinaryExpr) ReturnType() types.ValueType

func (BinaryExpr) ToString added in v0.1.0

func (b BinaryExpr) ToString() string

func (BinaryExpr) Validate added in v0.1.0

func (b BinaryExpr) Validate() error

type Expr

type Expr interface {
	Accept(v ExprVisitor) interfaces.IRCode
	ExprType() ExprType
	ReturnType() types.ValueType
	ToString() string
	Validate() error
}

type ExprType

type ExprType string
const (
	BinaryExprType       ExprType = "Binary"
	GroupingExprType     ExprType = "Grouping"
	LiteralExprType      ExprType = "Literal"
	UnaryExprType        ExprType = "Unary"
	FieldAccessExprType  ExprType = "FieldAccess"
	VariableExprType     ExprType = "Variable"
	FunctionCallExprType ExprType = "FunctionCall"
	LogicalExprType      ExprType = "Logical"
	SliceExprType        ExprType = "SliceString"
	ListExprType         ExprType = "List"
	StructExprType       ExprType = "Struct"
)

type ExprVisitor

type ExprVisitor interface {
	VisitBinary(b BinaryExpr) interfaces.IRCode
	VisitGrouping(g GroupingExpr) interfaces.IRCode
	VisitLiteral(l LiteralExpr) interfaces.IRCode
	VisitUnary(u UnaryExpr) interfaces.IRCode
	VisitVariable(v VariableExpr) interfaces.IRCode
	VisitFieldAccess(v FieldAccessExpr) interfaces.IRCode
	VisitFunctionCall(f FunctionCallExpr) interfaces.IRCode
	VisitLogical(l LogicalExpr) interfaces.IRCode
	VisitSlice(s SliceExpr) interfaces.IRCode
	VisitList(s ListExpr) interfaces.IRCode
	VisitStruct(s StructExpr) interfaces.IRCode
}

type FieldAccessExpr added in v0.0.8

type FieldAccessExpr struct {
	Expr
	interfaces.SourceLocation

	Source Expr
	Field  tokens.Token
	Type   types.ValueType
}

func (FieldAccessExpr) Accept added in v0.0.8

func (v FieldAccessExpr) Accept(visitor ExprVisitor) interfaces.IRCode

func (FieldAccessExpr) ExprType added in v0.0.8

func (v FieldAccessExpr) ExprType() ExprType

func (FieldAccessExpr) ReturnType added in v0.0.8

func (v FieldAccessExpr) ReturnType() types.ValueType

func (FieldAccessExpr) ToString added in v0.1.0

func (v FieldAccessExpr) ToString() string

type FunctionCallExpr

type FunctionCallExpr struct {
	Expr
	interfaces.SourceLocation

	Name      tokens.Token
	Arguments []Expr
	Type      types.ValueType
}

func (FunctionCallExpr) Accept

func (f FunctionCallExpr) Accept(visitor ExprVisitor) interfaces.IRCode

func (FunctionCallExpr) ExprType added in v0.0.8

func (f FunctionCallExpr) ExprType() ExprType

func (FunctionCallExpr) ReturnType

func (f FunctionCallExpr) ReturnType() types.ValueType

func (FunctionCallExpr) ToString added in v0.1.0

func (f FunctionCallExpr) ToString() string

type GroupingExpr

type GroupingExpr struct {
	Expr
	interfaces.SourceLocation

	Expression Expr
}

func (GroupingExpr) Accept

func (GroupingExpr) ExprType added in v0.0.8

func (g GroupingExpr) ExprType() ExprType

func (GroupingExpr) ReturnType

func (g GroupingExpr) ReturnType() types.ValueType

func (GroupingExpr) ToString added in v0.1.0

func (g GroupingExpr) ToString() string

type ListExpr added in v0.0.7

type ListExpr struct {
	Expr
	interfaces.SourceLocation

	Elements  []Expr
	ValueType types.ValueType
}

func (ListExpr) Accept added in v0.0.7

func (l ListExpr) Accept(v ExprVisitor) interfaces.IRCode

func (ListExpr) ExprType added in v0.0.8

func (l ListExpr) ExprType() ExprType

func (ListExpr) ReturnType added in v0.0.7

func (l ListExpr) ReturnType() types.ValueType

func (ListExpr) ToString added in v0.1.0

func (l ListExpr) ToString() string

type LiteralExpr

type LiteralExpr struct {
	Expr
	interfaces.SourceLocation

	Value     nbt.Value
	ValueType types.ValueType
}

func (LiteralExpr) Accept

func (LiteralExpr) ExprType added in v0.0.8

func (l LiteralExpr) ExprType() ExprType

func (LiteralExpr) ReturnType

func (l LiteralExpr) ReturnType() types.ValueType

func (LiteralExpr) ToString added in v0.1.0

func (l LiteralExpr) ToString() string

type LogicalExpr

type LogicalExpr struct {
	Left     Expr
	Operator tokens.Token
	Right    Expr

	interfaces.SourceLocation
	Expr
}

func (LogicalExpr) Accept

func (LogicalExpr) ExprType added in v0.0.8

func (l LogicalExpr) ExprType() ExprType

func (LogicalExpr) ReturnType

func (l LogicalExpr) ReturnType() types.ValueType

func (LogicalExpr) ToString added in v0.1.0

func (l LogicalExpr) ToString() string

type SliceExpr

type SliceExpr struct {
	StartIndex Expr
	EndIndex   Expr
	TargetExpr Expr

	interfaces.SourceLocation
	Expr
}

func (SliceExpr) Accept

func (s SliceExpr) Accept(v ExprVisitor) interfaces.IRCode

func (SliceExpr) ExprType added in v0.0.8

func (s SliceExpr) ExprType() ExprType

func (SliceExpr) ReturnType

func (s SliceExpr) ReturnType() types.ValueType

func (SliceExpr) ToString added in v0.1.0

func (s SliceExpr) ToString() string

type StructExpr added in v0.0.14

type StructExpr struct {
	Expr
	interfaces.SourceLocation

	Args       []Expr
	StructType types.StructTypeStruct
}

func (StructExpr) Accept added in v0.0.14

func (StructExpr) ExprType added in v0.0.14

func (s StructExpr) ExprType() ExprType

func (StructExpr) ReturnType added in v0.0.14

func (s StructExpr) ReturnType() types.ValueType

func (StructExpr) ToString added in v0.1.0

func (s StructExpr) ToString() string

type UnaryExpr

type UnaryExpr struct {
	Expr
	interfaces.SourceLocation

	Operator   tokens.Token
	Expression Expr
}

func (UnaryExpr) Accept

func (u UnaryExpr) Accept(v ExprVisitor) interfaces.IRCode

func (UnaryExpr) ExprType added in v0.0.8

func (u UnaryExpr) ExprType() ExprType

func (UnaryExpr) ReturnType

func (u UnaryExpr) ReturnType() types.ValueType

func (UnaryExpr) ToString added in v0.1.0

func (u UnaryExpr) ToString() string

type VariableExpr

type VariableExpr struct {
	Expr
	interfaces.SourceLocation

	Name tokens.Token
	Type types.ValueType
}

func (VariableExpr) Accept

func (v VariableExpr) Accept(visitor ExprVisitor) interfaces.IRCode

func (VariableExpr) ExprType added in v0.0.8

func (v VariableExpr) ExprType() ExprType

func (VariableExpr) ReturnType

func (v VariableExpr) ReturnType() types.ValueType

func (VariableExpr) ToString added in v0.1.0

func (v VariableExpr) ToString() string

Jump to

Keyboard shortcuts

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