statements

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 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 Accessor added in v0.0.8

type Accessor interface{}

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) string

func (BlockStmt) StmtType added in v0.0.8

func (b BlockStmt) StmtType() StmtType

type ExpressionStmt

type ExpressionStmt struct {
	Stmt

	Expression expressions.Expr
}

func (ExpressionStmt) Accept

func (e ExpressionStmt) Accept(visitor StmtVisitor) string

func (ExpressionStmt) StmtType added in v0.0.8

func (e ExpressionStmt) StmtType() StmtType

type FieldAccessor added in v0.0.8

type FieldAccessor struct {
	Field tokens.Token
}

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

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) string

func (FunctionDeclarationStmt) HasArg

func (f FunctionDeclarationStmt) HasArg(arg string) bool

func (FunctionDeclarationStmt) StmtType added in v0.0.8

func (f FunctionDeclarationStmt) StmtType() StmtType

type IfStmt

type IfStmt struct {
	Stmt

	Condition  expressions.Expr
	ThenBranch BlockStmt
	ElseBranch BlockStmt
}

func (IfStmt) Accept

func (i IfStmt) Accept(visitor StmtVisitor) string

func (IfStmt) StmtType added in v0.0.8

func (i IfStmt) StmtType() StmtType

type IndexAccessor added in v0.0.8

type IndexAccessor struct {
	Index expressions.Expr
}

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

type ReturnStmt

type ReturnStmt struct {
	Stmt

	Expression expressions.Expr
}

func (ReturnStmt) Accept

func (s ReturnStmt) Accept(v StmtVisitor) string

func (ReturnStmt) StmtType added in v0.0.8

func (s ReturnStmt) StmtType() StmtType

type Stmt

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

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"
)

type StmtVisitor

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

type StructDeclarationStmt added in v0.0.8

type StructDeclarationStmt struct {
	Stmt

	Name   tokens.Token
	Fields []interfaces.StructField
}

func (StructDeclarationStmt) Accept added in v0.0.8

func (s StructDeclarationStmt) Accept(visitor StmtVisitor) string

func (StructDeclarationStmt) StmtType added in v0.0.8

func (s StructDeclarationStmt) StmtType() StmtType

type VarDef

type VarDef struct {
	Name string
	Type interfaces.ValueType
}

type VariableAssignmentStmt

type VariableAssignmentStmt struct {
	Stmt

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

func (VariableAssignmentStmt) Accept

func (v VariableAssignmentStmt) Accept(visitor StmtVisitor) string

func (VariableAssignmentStmt) StmtType added in v0.0.8

func (v VariableAssignmentStmt) StmtType() 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) string

func (VariableDeclarationStmt) StmtType added in v0.0.8

func (v VariableDeclarationStmt) StmtType() StmtType

type WhileStmt

type WhileStmt struct {
	Stmt

	Condition expressions.Expr
	Body      BlockStmt
}

func (WhileStmt) Accept

func (w WhileStmt) Accept(v StmtVisitor) string

func (WhileStmt) StmtType added in v0.0.8

func (w WhileStmt) StmtType() StmtType

Jump to

Keyboard shortcuts

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