ast

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ast defines the abstract syntax tree nodes for the CSV spreadsheet language.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrCircularDependency

func ErrCircularDependency() error

func ErrCircularInclude

func ErrCircularInclude(chain []string) error

func ErrIncludeFileNotFound

func ErrIncludeFileNotFound(path string, position scanner.Position) error

func ErrIncludeReadError

func ErrIncludeReadError(path string, err error) error

func ErrInvalidRange

func ErrInvalidRange(start, end string) error

func ExpandRange

func ExpandRange(start, end string) ([]string, error)

func ExtractDependencies

func ExtractDependencies(expr Node) []string

func GetStatementDependencies

func GetStatementDependencies(stmt Node) []string

GetStatementDependencies returns the dependencies of a statement

func GetStatementName

func GetStatementName(stmt Node) string

GetStatementName returns the name/identifier of a statement if it defines one

func IsBoolean

func IsBoolean(expr Node) bool

func IsCell

func IsCell(expr Node) bool

func IsCellIdentifier

func IsCellIdentifier(identifier string) bool

IsCellIdentifier returns true if the identifier matches A1 cell name format

func IsDate

func IsDate(expr Node) bool

func IsFloat

func IsFloat(expr Node) bool

func IsFunction

func IsFunction(expr Node) bool

func IsIdentifier

func IsIdentifier(expr Node) bool

func IsInt

func IsInt(expr Node) bool

func IsLiteral

func IsLiteral(expr Node) bool

IsLiteral returns true if the expression is a literal value type

func IsNumeric

func IsNumeric(expr Node) bool

IsNumeric returns true if the expression is a numeric type (int or float)

func IsRange

func IsRange(expr Node) bool

func IsString

func IsString(expr Node) bool

func ParseCell

func ParseCell(cell string) (c, r int)

ParseCell parses a cell reference like "A1" into a zero based column and row components

func ToCell

func ToCell(column, row int) string

ToCell converts 0-based column, row to cell like 0, 0 to "A1", 1,1 to "B2", etc.

func TypeName

func TypeName(expr Node) string

TypeName returns a human-readable name for the expression type.

Types

type BooleanExpression

type BooleanExpression struct {
	Node
	Token lexer.Token
	Value bool
}

func (BooleanExpression) String

func (expr BooleanExpression) String() string

type CallExpression

type CallExpression struct {
	Node
	Token      lexer.Token
	Identifier Node
	Arguments  []Node
}

func (CallExpression) String

func (expr CallExpression) String() string

type DateExpression

type DateExpression struct {
	Node
	Token lexer.Token
	Value time.Time
}

func (DateExpression) String

func (expr DateExpression) String() string

type DependencyGraph

type DependencyGraph struct {
	Nodes    map[string]*DependencyInfo
	AdjList  map[string][]string
	InDegree map[string]int
}

func NewDependencyGraph

func NewDependencyGraph(program Program) *DependencyGraph

NewDependencyGraph creates a new dependency graph from a program

func (*DependencyGraph) Sort

func (g *DependencyGraph) Sort() ([]Node, error)

Sort performs Kahn's algorithm for topological sorting

type DependencyInfo

type DependencyInfo struct {
	Name         string
	Statement    Node
	Dependencies []string
}

type ExpressionStatement

type ExpressionStatement struct {
	Node
	Token lexer.Token
	Value Node
}

func (ExpressionStatement) String

func (stmt ExpressionStatement) String() string

type FloatExpression

type FloatExpression struct {
	Node
	Token lexer.Token
	Value float64
}

func ToFloat

func ToFloat(expr *Node) (*FloatExpression, bool)

func (FloatExpression) String

func (expr FloatExpression) String() string

type FmtStatement

type FmtStatement struct {
	Node
	Identifier IdentifierExpression
	Value      Node
}

func (FmtStatement) String

func (stmt FmtStatement) String() string

type IdentifierExpression

type IdentifierExpression struct {
	Node
	Token lexer.Token
	Value string
}

func (IdentifierExpression) String

func (expr IdentifierExpression) String() string

type IncludeStatement

type IncludeStatement struct {
	Node
	Token lexer.Token
	Path  string
}

func (IncludeStatement) String

func (stmt IncludeStatement) String() string

type InfixExpression

type InfixExpression struct {
	Node
	Token    lexer.Token
	Left     Node
	Operator lexer.Token
	Right    Node
}

func (InfixExpression) String

func (expr InfixExpression) String() string

type IntExpression

type IntExpression struct {
	Node
	Token lexer.Token
	Value int
}

func ToInt

func ToInt(expr *Node) (*IntExpression, bool)

func (IntExpression) String

func (expr IntExpression) String() string

type LetStatement

type LetStatement struct {
	Node
	Identifier IdentifierExpression
	Value      Node
}

func (LetStatement) String

func (stmt LetStatement) String() string

type Node

type Node interface {
	String() string
}

type PrefixExpression

type PrefixExpression struct {
	Node
	Token    lexer.Token
	Operator lexer.Token
	Value    Node
}

func (PrefixExpression) String

func (expr PrefixExpression) String() string

type Program

type Program []Node

func SortProgram

func SortProgram(program Program) (Program, error)

SortProgram sorts a program's statements in topological order

func (Program) String added in v0.2.0

func (p Program) String() string

type RangeExpression

type RangeExpression struct {
	Node
	Token lexer.Token
	Value []string
}

func (RangeExpression) String

func (expr RangeExpression) String() string

type StringExpression

type StringExpression struct {
	Node
	Token lexer.Token
	Value string
}

func (StringExpression) String

func (expr StringExpression) String() string

Jump to

Keyboard shortcuts

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