ast

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ast defines structs and methods to handle AST creation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssignmentStatement

type AssignmentStatement struct {
	Left     *Identifier
	Right    ExprNode
	StartPos int
	EndPos   int
}

AssignmentStatement represents an assignment statement.

func (*AssignmentStatement) EndPosition

func (a *AssignmentStatement) EndPosition() int

EndPosition returns the end position of the assignment statement.

func (*AssignmentStatement) Expr

func (a *AssignmentStatement) Expr() string

Expr returns the expression of the assignment statement.

func (*AssignmentStatement) StartPosition

func (a *AssignmentStatement) StartPosition() int

StartPosition returns the start position of the assignment statement.

func (*AssignmentStatement) Walk

func (a *AssignmentStatement) Walk(fn func(node ExprNode) bool)

Walk walks the assignment statement and its left and right nodes.

type BinaryExpr

type BinaryExpr struct {
	Left     ExprNode
	Right    ExprNode
	Operator token.Token
	StartPos int
	EndPos   int
}

BinaryExpr defines a struct for a binary expression.

func (*BinaryExpr) EndPosition

func (e *BinaryExpr) EndPosition() int

EndPosition returns the end position of the binary expression.

func (*BinaryExpr) Expr

func (e *BinaryExpr) Expr() string

Expr returns the expression of the binary expression.

func (*BinaryExpr) StartPosition

func (e *BinaryExpr) StartPosition() int

StartPosition returns the start position of the binary expression.

func (*BinaryExpr) Walk

func (e *BinaryExpr) Walk(fn func(node ExprNode) bool)

Walk walks the binary expression and its left and right nodes.

type BlockStatement

type BlockStatement struct {
	Statements []ExprNode
	StartPos   int
	EndPos     int
}

BlockStatement defines a struct for a block statement.

func (*BlockStatement) EndPosition

func (e *BlockStatement) EndPosition() int

EndPosition returns the end position of the block statement.

func (*BlockStatement) Expr

func (e *BlockStatement) Expr() string

Expr returns the expression of the block statement.

func (*BlockStatement) StartPosition

func (e *BlockStatement) StartPosition() int

StartPosition returns the start position of the block statement.

func (*BlockStatement) Walk

func (e *BlockStatement) Walk(fn func(node ExprNode) bool)

Walk walks the block statement and its statements.

type BoolLiteral

type BoolLiteral struct {
	Value    string
	StartPos int
	EndPos   int
}

BoolLiteral defines a struct for a literal boolean value.

func (*BoolLiteral) EndPosition

func (e *BoolLiteral) EndPosition() int

EndPosition returns the end position of the boolean literal.

func (*BoolLiteral) Expr

func (e *BoolLiteral) Expr() string

Expr returns the expression of the boolean literal.

func (*BoolLiteral) StartPosition

func (e *BoolLiteral) StartPosition() int

StartPosition returns the start position of the boolean literal.

func (*BoolLiteral) Walk

func (e *BoolLiteral) Walk(fn func(node ExprNode) bool)

Walk walks the boolean literal.

type BreakStatement

type BreakStatement struct {
	Count    int
	StartPos int
	EndPos   int
}

BreakStatement represents a break statement.

func (*BreakStatement) EndPosition

func (b *BreakStatement) EndPosition() int

EndPosition returns the end position of the break statement.

func (*BreakStatement) Expr

func (b *BreakStatement) Expr() string

Expr returns the expression of the break statement.

func (*BreakStatement) StartPosition

func (b *BreakStatement) StartPosition() int

StartPosition returns the start position of the break statement.

func (*BreakStatement) Walk

func (b *BreakStatement) Walk(fn func(node ExprNode) bool)

Walk walks the break statement.

type ConstantDeclaration

type ConstantDeclaration struct {
	Name     string
	Type     string
	Value    ExprNode
	StartPos int
	EndPos   int
}

ConstantDeclaration represents a constant declaration.

func (*ConstantDeclaration) EndPosition

func (c *ConstantDeclaration) EndPosition() int

EndPosition returns the end position of the constant declaration.

func (*ConstantDeclaration) Expr

func (c *ConstantDeclaration) Expr() string

Expr returns the expression of the constant declaration.

func (*ConstantDeclaration) StartPosition

func (c *ConstantDeclaration) StartPosition() int

StartPosition returns the start position of the constant declaration.

func (*ConstantDeclaration) Walk

func (c *ConstantDeclaration) Walk(fn func(node ExprNode) bool)

Walk walks the constant declaration and its value.

type ContinueStatement

type ContinueStatement struct {
	Count    int
	StartPos int
	EndPos   int
}

ContinueStatement represents a continue statement.

func (*ContinueStatement) EndPosition

func (c *ContinueStatement) EndPosition() int

EndPosition returns the end position of the continue statement.

func (*ContinueStatement) Expr

func (c *ContinueStatement) Expr() string

Expr returns the expression of the continue statement.

func (*ContinueStatement) StartPosition

func (c *ContinueStatement) StartPosition() int

StartPosition returns the start position of the continue statement.

func (*ContinueStatement) Walk

func (c *ContinueStatement) Walk(fn func(node ExprNode) bool)

Walk walks the continue statement.

type ExprNode

type ExprNode interface {
	Expr() string
	StartPosition() int
	EndPosition() int
	Walk(func(node ExprNode) bool)
}

ExprNode defines a common interface signature for expression structs.

type ForStatement

type ForStatement struct {
	Condition        ExprNode
	Body             *BlockStatement
	StartPos         int
	EndPos           int
	DeclaredVariable string
	RangeVariable    string
	RangeFrom        ExprNode
	RangeTo          ExprNode
	IsRange          bool
}

ForStatement represents a for statement.

func (*ForStatement) EndPosition

func (f *ForStatement) EndPosition() int

EndPosition returns the end position of the for statement.

func (*ForStatement) Expr

func (f *ForStatement) Expr() string

Expr returns the expression of the for statement.

func (*ForStatement) StartPosition

func (f *ForStatement) StartPosition() int

StartPosition returns the start position of the for statement.

func (*ForStatement) Walk

func (f *ForStatement) Walk(fn func(node ExprNode) bool)

Walk walks the for statement and its condition and body.

type FunctionCall

type FunctionCall struct {
	FunctionName string
	Arguments    []ExprNode
	StartPos     int
	EndPos       int
}

FunctionCall defines a struct for a function call.

func (*FunctionCall) EndPosition

func (fc *FunctionCall) EndPosition() int

EndPosition returns the end position of the function call.

func (*FunctionCall) Expr

func (fc *FunctionCall) Expr() string

Expr returns the expression of the function call.

func (*FunctionCall) StartPosition

func (fc *FunctionCall) StartPosition() int

StartPosition returns the start position of the function call.

func (*FunctionCall) Walk

func (fc *FunctionCall) Walk(fn func(node ExprNode) bool)

Walk walks the function call and its arguments.

type Identifier

type Identifier struct {
	Value    string
	StartPos int
	EndPos   int
}

Identifier defines a struct for an identifier.

func (*Identifier) EndPosition

func (e *Identifier) EndPosition() int

EndPosition returns the end position of the identifier.

func (*Identifier) Expr

func (e *Identifier) Expr() string

Expr returns the expression of the identifier.

func (*Identifier) StartPosition

func (e *Identifier) StartPosition() int

StartPosition returns the start position of the identifier.

func (*Identifier) Walk

func (e *Identifier) Walk(fn func(node ExprNode) bool)

Walk walks the identifier.

type IfStatement

type IfStatement struct {
	Condition ExprNode
	ThenBlock *BlockStatement
	ElseBlock *BlockStatement
	StartPos  int
	EndPos    int
}

IfStatement defines a struct for an if statement.

func (*IfStatement) EndPosition

func (e *IfStatement) EndPosition() int

EndPosition returns the end position of the if statement.

func (*IfStatement) Expr

func (e *IfStatement) Expr() string

Expr returns the expression of the if statement.

func (*IfStatement) StartPosition

func (e *IfStatement) StartPosition() int

StartPosition returns the start position of the if statement.

func (*IfStatement) Walk

func (e *IfStatement) Walk(fn func(node ExprNode) bool)

Walk walks the if statement and its condition and body.

type NullLiteral

type NullLiteral struct {
	StartPos int
	EndPos   int
}

NullLiteral defines a struct for a literal null value.

func (*NullLiteral) EndPosition

func (e *NullLiteral) EndPosition() int

EndPosition returns the end position of the null literal.

func (*NullLiteral) Expr

func (e *NullLiteral) Expr() string

Expr returns the expression of the null literal.

func (*NullLiteral) StartPosition

func (e *NullLiteral) StartPosition() int

StartPosition returns the start position of the null literal.

func (*NullLiteral) Walk

func (e *NullLiteral) Walk(fn func(node ExprNode) bool)

Walk walks the null literal.

type NumberLiteral

type NumberLiteral struct {
	Value    string
	StartPos int
	EndPos   int
}

NumberLiteral defines a struct for a literal number value.

func (*NumberLiteral) EndPosition

func (e *NumberLiteral) EndPosition() int

EndPosition returns the end position of the number literal.

func (*NumberLiteral) Expr

func (e *NumberLiteral) Expr() string

Expr returns the expression of the number literal.

func (*NumberLiteral) StartPosition

func (e *NumberLiteral) StartPosition() int

StartPosition returns the start position of the number literal.

func (*NumberLiteral) Walk

func (e *NumberLiteral) Walk(fn func(node ExprNode) bool)

Walk walks the number literal.

type PrefixExpr

type PrefixExpr struct {
	Operator token.Token
	Operand  ExprNode
	StartPos int
	EndPos   int
}

PrefixExpr defines a struct for a prefix expression.

func (*PrefixExpr) EndPosition

func (e *PrefixExpr) EndPosition() int

EndPosition returns the end position of the prefix expression.

func (*PrefixExpr) Expr

func (e *PrefixExpr) Expr() string

Expr returns the expression of the prefix expression.

func (*PrefixExpr) StartPosition

func (e *PrefixExpr) StartPosition() int

StartPosition returns the start position of the prefix expression.

func (*PrefixExpr) Walk

func (e *PrefixExpr) Walk(fn func(node ExprNode) bool)

Walk walks the prefix expression and its operand.

type StatementList

type StatementList struct {
	Statements []ExprNode
	StartPos   int
	EndPos     int
}

StatementList represents multiple statements separated by newlines.

func (*StatementList) EndPosition

func (sl *StatementList) EndPosition() int

EndPosition returns the end position of the statement list.

func (*StatementList) Expr

func (sl *StatementList) Expr() string

Expr returns the expression in the statement list.

func (*StatementList) StartPosition

func (sl *StatementList) StartPosition() int

StartPosition returns the start position of the statement list.

func (*StatementList) Walk

func (sl *StatementList) Walk(fn func(node ExprNode) bool)

Walk walks the statement list and its statements.

type StringLiteral

type StringLiteral struct {
	Value    string
	StartPos int
	EndPos   int
}

StringLiteral defines a struct for a literal string value.

func (*StringLiteral) EndPosition

func (e *StringLiteral) EndPosition() int

EndPosition returns the end position of the string literal.

func (*StringLiteral) Expr

func (e *StringLiteral) Expr() string

Expr returns the expression of the string literal.

func (*StringLiteral) StartPosition

func (e *StringLiteral) StartPosition() int

StartPosition returns the start position of the string literal.

func (*StringLiteral) Walk

func (e *StringLiteral) Walk(fn func(node ExprNode) bool)

Walk walks the string literal.

type VariableDeclaration

type VariableDeclaration struct {
	Name     string
	Type     string
	Value    ExprNode
	StartPos int
	EndPos   int
}

VariableDeclaration represents a variable declaration.

func (*VariableDeclaration) EndPosition

func (v *VariableDeclaration) EndPosition() int

EndPosition returns the end position of the variable declaration.

func (*VariableDeclaration) Expr

func (v *VariableDeclaration) Expr() string

Expr returns the expression of the variable declaration.

func (*VariableDeclaration) StartPosition

func (v *VariableDeclaration) StartPosition() int

StartPosition returns the start position of the variable declaration.

func (*VariableDeclaration) Walk

func (v *VariableDeclaration) Walk(fn func(node ExprNode) bool)

Walk walks the variable declaration and its value.

Jump to

Keyboard shortcuts

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