expressions

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: GPL-3.0 Imports: 2 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 (b BinaryExpr) Accept(v ExprVisitor) interface{}

func (BinaryExpr) ReturnType

func (b BinaryExpr) ReturnType() ValueType

func (BinaryExpr) TType

func (b BinaryExpr) TType() ExprType

type Expr

type Expr interface {
	Accept(v ExprVisitor) interface{}
	TType() ExprType
	ReturnType() ValueType
}

type ExprType

type ExprType string
const (
	BinaryExprType       ExprType = "Binary"
	GroupingExprType     ExprType = "Grouping"
	LiteralExprType      ExprType = "Literal"
	UnaryExprType        ExprType = "Unary"
	VariableExprType     ExprType = "Variable"
	FunctionCallExprType ExprType = "FunctionCall"
	LogicalExprType      ExprType = "Logical"
	SliceExprType        ExprType = "Slice"
)

type ExprVisitor

type ExprVisitor interface {
	VisitBinary(b BinaryExpr) interface{}
	VisitGrouping(g GroupingExpr) interface{}
	VisitLiteral(l LiteralExpr) interface{}
	VisitUnary(u UnaryExpr) interface{}
	VisitVariable(v VariableExpr) interface{}
	VisitFunctionCall(f FunctionCallExpr) interface{}
	VisitLogical(l LogicalExpr) interface{}
	VisitSlice(s SliceExpr) interface{}
}

type FunctionCallExpr

type FunctionCallExpr struct {
	Expr
	interfaces.SourceLocation

	Name      tokens.Token
	Arguments []Expr
	Type      ValueType
}

func (FunctionCallExpr) Accept

func (f FunctionCallExpr) Accept(visitor ExprVisitor) interface{}

func (FunctionCallExpr) ReturnType

func (f FunctionCallExpr) ReturnType() ValueType

func (FunctionCallExpr) TType

func (f FunctionCallExpr) TType() ExprType

type GroupingExpr

type GroupingExpr struct {
	Expr
	interfaces.SourceLocation

	Expression Expr
}

func (GroupingExpr) Accept

func (g GroupingExpr) Accept(v ExprVisitor) interface{}

func (GroupingExpr) ReturnType

func (g GroupingExpr) ReturnType() ValueType

func (GroupingExpr) TType

func (g GroupingExpr) TType() ExprType

type LiteralExpr

type LiteralExpr struct {
	Expr
	interfaces.SourceLocation

	Value     interface{}
	ValueType ValueType
}

func (LiteralExpr) Accept

func (l LiteralExpr) Accept(v ExprVisitor) interface{}

func (LiteralExpr) ReturnType

func (l LiteralExpr) ReturnType() ValueType

func (LiteralExpr) TType

func (l LiteralExpr) TType() ExprType

type LogicalExpr

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

	interfaces.SourceLocation
	Expr
}

func (LogicalExpr) Accept

func (l LogicalExpr) Accept(v ExprVisitor) interface{}

func (LogicalExpr) ReturnType

func (l LogicalExpr) ReturnType() ValueType

func (LogicalExpr) TType

func (l LogicalExpr) TType() ExprType

type SliceExpr

type SliceExpr struct {
	StartIndex Expr
	EndIndex   Expr
	TargetExpr Expr

	interfaces.SourceLocation
	Expr
}

func (SliceExpr) Accept

func (s SliceExpr) Accept(v ExprVisitor) interface{}

func (SliceExpr) ReturnType

func (s SliceExpr) ReturnType() ValueType

func (SliceExpr) TType

func (s SliceExpr) TType() ExprType

type UnaryExpr

type UnaryExpr struct {
	Expr
	interfaces.SourceLocation

	Operator   tokens.Token
	Expression Expr
}

func (UnaryExpr) Accept

func (u UnaryExpr) Accept(v ExprVisitor) interface{}

func (UnaryExpr) ReturnType

func (u UnaryExpr) ReturnType() ValueType

func (UnaryExpr) TType

func (u UnaryExpr) TType() ExprType

type ValueType

type ValueType string
const (
	VoidType   ValueType = "void"
	ErrorType  ValueType = "error"
	IntType    ValueType = "int"
	StringType ValueType = "str"
	FixedType  ValueType = "fixed"
)

type VariableExpr

type VariableExpr struct {
	Expr
	interfaces.SourceLocation

	Name tokens.Token
	Type ValueType
}

func (VariableExpr) Accept

func (v VariableExpr) Accept(visitor ExprVisitor) interface{}

func (VariableExpr) ReturnType

func (v VariableExpr) ReturnType() ValueType

func (VariableExpr) TType

func (v VariableExpr) TType() ExprType

Jump to

Keyboard shortcuts

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