statements

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockStmt

type BlockStmt struct {
	Stmt

	Statements []Stmt
}

func (BlockStmt) Accept

func (b BlockStmt) Accept(visitor StmtVisitor) interface{}

func (BlockStmt) TType

func (b BlockStmt) TType() StmtType

type ExpressionStmt

type ExpressionStmt struct {
	Stmt

	Expression expressions.Expr
}

func (ExpressionStmt) Accept

func (e ExpressionStmt) Accept(visitor StmtVisitor) interface{}

func (ExpressionStmt) TType

func (e ExpressionStmt) TType() StmtType

type FunctionDeclarationStmt

type FunctionDeclarationStmt struct {
	Stmt

	Name       tokens.Token
	Parameters []interfaces.FuncArg
	ReturnType interfaces.ValueType
	Body       BlockStmt
}

func (FunctionDeclarationStmt) Accept

func (f FunctionDeclarationStmt) Accept(visitor StmtVisitor) interface{}

func (FunctionDeclarationStmt) HasArg

func (f FunctionDeclarationStmt) HasArg(arg string) bool

func (FunctionDeclarationStmt) TType

type IfStmt

type IfStmt struct {
	Stmt

	Condition  expressions.Expr
	ThenBranch BlockStmt
	ElseBranch BlockStmt
}

func (IfStmt) Accept

func (i IfStmt) Accept(visitor StmtVisitor) interface{}

func (IfStmt) TType

func (i IfStmt) TType() StmtType

type ReturnStmt

type ReturnStmt struct {
	Stmt

	Expression expressions.Expr
}

func (ReturnStmt) Accept

func (s ReturnStmt) Accept(v StmtVisitor) interface{}

func (ReturnStmt) TType

func (s ReturnStmt) TType() StmtType

type Stmt

type Stmt interface {
	Accept(StmtVisitor) interface{}
	TType() StmtType
}

type StmtType

type StmtType string
const (
	ExpressionStmtType          StmtType = "Expression"
	VariableDeclarationStmtType StmtType = "VariableDeclaration"
	FunctionDeclarationStmtType StmtType = "FunctionDeclaration"
	VariableAssignmentStmtType  StmtType = "VariableAssignment"
	BlockStmtType               StmtType = "Block"
	WhileStmtType               StmtType = "While"
	IfStmtType                  StmtType = "If"
	ReturnStmtType              StmtType = "Return"
)

type StmtVisitor

type StmtVisitor interface {
	VisitExpression(ExpressionStmt) interface{}
	VisitVariableDeclaration(VariableDeclarationStmt) interface{}
	VisitFunctionDeclaration(FunctionDeclarationStmt) interface{}
	VisitVariableAssignment(VariableAssignmentStmt) interface{}
	VisitBlock(BlockStmt) interface{}
	VisitWhile(WhileStmt) interface{}
	VisitIf(IfStmt) interface{}
	VisitReturn(ReturnStmt) interface{}
}

type VarDef

type VarDef struct {
	Name string
	Type interfaces.ValueType
}

type VariableAssignmentStmt

type VariableAssignmentStmt struct {
	Name  tokens.Token
	Value expressions.Expr
}

func (VariableAssignmentStmt) Accept

func (v VariableAssignmentStmt) Accept(visitor StmtVisitor) interface{}

func (VariableAssignmentStmt) TType

func (v VariableAssignmentStmt) TType() StmtType

type VariableDeclarationStmt

type VariableDeclarationStmt struct {
	Stmt

	Name        tokens.Token
	Type        interfaces.ValueType
	Initializer expressions.Expr
}

func (VariableDeclarationStmt) Accept

func (v VariableDeclarationStmt) Accept(visitor StmtVisitor) interface{}

func (VariableDeclarationStmt) TType

type WhileStmt

type WhileStmt struct {
	Stmt

	Condition expressions.Expr
	Body      BlockStmt
}

func (WhileStmt) Accept

func (w WhileStmt) Accept(v StmtVisitor) interface{}

func (WhileStmt) TType

func (w WhileStmt) TType() StmtType

Jump to

Keyboard shortcuts

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