statements

package
v0.1.2 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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accessor added in v0.0.8

type Accessor interface {
	ToString() string
}

Accessor is one step in an L-value chain: either [expr] or .field

type BlockStmt

type BlockStmt struct {
	Stmt

	Statements []Stmt
}

func (BlockStmt) Accept

func (b BlockStmt) Accept(visitor StmtVisitor) interfaces.IRCode

func (BlockStmt) StmtType added in v0.0.8

func (b BlockStmt) StmtType() StmtType

func (BlockStmt) ToString added in v0.1.0

func (b BlockStmt) ToString() string

type ExpressionStmt

type ExpressionStmt struct {
	Stmt

	Expression expressions.Expr
}

func (ExpressionStmt) Accept

func (e ExpressionStmt) Accept(visitor StmtVisitor) interfaces.IRCode

func (ExpressionStmt) StmtType added in v0.0.8

func (e ExpressionStmt) StmtType() StmtType

func (ExpressionStmt) ToString added in v0.1.0

func (e ExpressionStmt) ToString() string

type FieldAccessor added in v0.0.8

type FieldAccessor struct {
	Field tokens.Token
}

FieldAccessor holds a parsed field name (foo.bar).

func (FieldAccessor) ToString added in v0.0.14

func (f FieldAccessor) ToString() string

type FunctionDeclarationStmt

type FunctionDeclarationStmt struct {
	Stmt

	Name          tokens.Token
	Parameters    []interfaces.TypedIdentifier
	ReturnType    types.ValueType
	Body          BlockStmt
	Autogenerated bool
}

func (FunctionDeclarationStmt) Accept

func (FunctionDeclarationStmt) HasArg

func (f FunctionDeclarationStmt) HasArg(arg string) bool

func (FunctionDeclarationStmt) StmtType added in v0.0.8

func (f FunctionDeclarationStmt) StmtType() StmtType

func (FunctionDeclarationStmt) ToString added in v0.1.0

func (f FunctionDeclarationStmt) ToString() string

type IfStmt

type IfStmt struct {
	Stmt

	Condition  expressions.Expr
	ThenBranch BlockStmt
	ElseBranch *BlockStmt
}

func (IfStmt) Accept

func (i IfStmt) Accept(visitor StmtVisitor) interfaces.IRCode

func (IfStmt) StmtType added in v0.0.8

func (i IfStmt) StmtType() StmtType

func (IfStmt) ToString added in v0.1.0

func (i IfStmt) ToString() string

type IndexAccessor added in v0.0.8

type IndexAccessor struct {
	Index expressions.Expr
}

IndexAccessor holds a parsed index expression (foo[expr]).

func (IndexAccessor) ToString added in v0.0.14

func (i IndexAccessor) ToString() string

type ReturnStmt

type ReturnStmt struct {
	Stmt

	Expression expressions.Expr
}

func (ReturnStmt) Accept

func (ReturnStmt) StmtType added in v0.0.8

func (s ReturnStmt) StmtType() StmtType

func (ReturnStmt) ToString added in v0.1.0

func (s ReturnStmt) ToString() string

type ScoreStmt added in v0.1.0

type ScoreStmt struct {
	Stmt
	Target string
	Score  int64
}

func (ScoreStmt) Accept added in v0.1.0

func (s ScoreStmt) Accept(visitor StmtVisitor) interfaces.IRCode

func (ScoreStmt) StmtType added in v0.1.0

func (s ScoreStmt) StmtType() StmtType

func (ScoreStmt) ToString added in v0.1.0

func (s ScoreStmt) ToString() string

type SetReturnFlagStmt added in v0.1.0

type SetReturnFlagStmt struct {
	Stmt
}

func (SetReturnFlagStmt) Accept added in v0.1.0

func (SetReturnFlagStmt) StmtType added in v0.1.0

func (s SetReturnFlagStmt) StmtType() StmtType

func (SetReturnFlagStmt) ToString added in v0.1.0

func (s SetReturnFlagStmt) ToString() string

type Stmt

type Stmt interface {
	Accept(StmtVisitor) interfaces.IRCode
	StmtType() StmtType
	ToString() string
}

type StmtType

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

type StmtVisitor

type StmtVisitor interface {
	VisitExpression(ExpressionStmt) interfaces.IRCode
	VisitVariableDeclaration(VariableDeclarationStmt) interfaces.IRCode
	VisitFunctionDeclaration(FunctionDeclarationStmt) interfaces.IRCode
	VisitVariableAssignment(VariableAssignmentStmt) interfaces.IRCode
	VisitStructDeclaration(StructDeclarationStmt) interfaces.IRCode
	VisitBlock(BlockStmt) interfaces.IRCode
	VisitWhile(WhileStmt) interfaces.IRCode
	VisitIf(IfStmt) interfaces.IRCode
	VisitReturn(ReturnStmt) interfaces.IRCode
	VisitScore(ScoreStmt) interfaces.IRCode
	VisitSetReturnFlag(SetReturnFlagStmt) interfaces.IRCode
}

type StructDeclarationStmt added in v0.0.8

type StructDeclarationStmt struct {
	Stmt

	Name       tokens.Token
	StructType types.StructTypeStruct
}

func (StructDeclarationStmt) Accept added in v0.0.8

func (StructDeclarationStmt) StmtType added in v0.0.8

func (s StructDeclarationStmt) StmtType() StmtType

func (StructDeclarationStmt) ToString added in v0.1.0

func (s StructDeclarationStmt) ToString() string

type VarDef

type VarDef struct {
	Name string
	Type types.ValueType
}

type VariableAssignmentStmt

type VariableAssignmentStmt struct {
	Stmt

	Name      tokens.Token
	Accessors []Accessor
	Value     expressions.Expr
}

func (VariableAssignmentStmt) Accept

func (VariableAssignmentStmt) StmtType added in v0.0.8

func (v VariableAssignmentStmt) StmtType() StmtType

func (VariableAssignmentStmt) ToString added in v0.1.0

func (v VariableAssignmentStmt) ToString() string

type VariableDeclarationStmt

type VariableDeclarationStmt struct {
	Stmt

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

func (VariableDeclarationStmt) Accept

func (VariableDeclarationStmt) StmtType added in v0.0.8

func (v VariableDeclarationStmt) StmtType() StmtType

func (VariableDeclarationStmt) ToString added in v0.1.0

func (v VariableDeclarationStmt) ToString() string

type WhileStmt

type WhileStmt struct {
	Stmt

	Condition expressions.Expr
	Body      BlockStmt
}

func (WhileStmt) Accept

func (w WhileStmt) Accept(v StmtVisitor) interfaces.IRCode

func (WhileStmt) StmtType added in v0.0.8

func (w WhileStmt) StmtType() StmtType

func (WhileStmt) ToString added in v0.1.0

func (w WhileStmt) ToString() string

Jump to

Keyboard shortcuts

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