ast

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayLiteral

type ArrayLiteral struct {
	Expression
	Token    lexer.Token
	Elements []Expression
}

ArrayLiteral represents an array literal

func (*ArrayLiteral) String

func (al *ArrayLiteral) String() string

func (*ArrayLiteral) TokenLiteral

func (al *ArrayLiteral) TokenLiteral() string

type AssignExpression

type AssignExpression struct {
	Expression
	Token    lexer.Token
	Name     *Identifier
	Operator string
	Value    Expression
}

AssignExpression represents an assign expression

func (*AssignExpression) String

func (ae *AssignExpression) String() string

func (*AssignExpression) TokenLiteral

func (ae *AssignExpression) TokenLiteral() string

type BlockStatement

type BlockStatement struct {
	Statement
	Token      lexer.Token // the '[' token
	Statements []Statement
}

BLOCK statement

func (*BlockStatement) String

func (bs *BlockStatement) String() string

func (*BlockStatement) TokenLiteral

func (bs *BlockStatement) TokenLiteral() string

type BooleanLiteral

type BooleanLiteral struct {
	Expression
	Token lexer.Token
	Value bool
}

BooleanLiteral represents a boolean literal

func (*BooleanLiteral) String

func (b *BooleanLiteral) String() string

func (*BooleanLiteral) TokenLiteral

func (b *BooleanLiteral) TokenLiteral() string

type CallExpression

type CallExpression struct {
	Expression
	Token     lexer.Token
	Function  Expression
	Arguments []Expression
}

CallExpression represents a function call expression

func (*CallExpression) String

func (ce *CallExpression) String() string

func (*CallExpression) TokenLiteral

func (ce *CallExpression) TokenLiteral() string

type ConditionalExpression

type ConditionalExpression struct {
	Expression
	Token           lexer.Token
	Condition       Expression
	ExecutionBlock  *BlockStatement
	NextConditional *ConditionalExpression
}

ConditionalExpression represents an if expression

func (*ConditionalExpression) String

func (i *ConditionalExpression) String() string

func (*ConditionalExpression) TokenLiteral

func (i *ConditionalExpression) TokenLiteral() string

type Expression

type Expression interface {
	Node
	// contains filtered or unexported methods
}

Expression is the interface that all expression nodes in the AST implement

type ExpressionStatement

type ExpressionStatement struct {
	Statement
	Token      lexer.Token
	Expression Expression
}

EXPRESSION statement

func (*ExpressionStatement) String

func (es *ExpressionStatement) String() string

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

type FloatLiteral added in v0.2.0

type FloatLiteral struct {
	Expression
	Token lexer.Token
	Value float64
}

FloatLiteral represents a float literal

func (*FloatLiteral) String added in v0.2.0

func (fl *FloatLiteral) String() string

func (*FloatLiteral) TokenLiteral added in v0.2.0

func (fl *FloatLiteral) TokenLiteral() string

type FunctionExpression

type FunctionExpression struct {
	Expression
	Token      lexer.Token
	Parameters []*Identifier
	Body       *BlockStatement
}

FunctionExpression represents a function expression

func (*FunctionExpression) String

func (fe *FunctionExpression) String() string

func (*FunctionExpression) TokenLiteral

func (fe *FunctionExpression) TokenLiteral() string

type HashLiteral

type HashLiteral struct {
	Expression
	Token lexer.Token
	Pairs map[Expression]Expression
}

HashLiteral represents a hash literal

func (*HashLiteral) String

func (hl *HashLiteral) String() string

func (*HashLiteral) TokenLiteral

func (hl *HashLiteral) TokenLiteral() string

type Identifier

type Identifier struct {
	Expression
	Token lexer.Token
	Value string
}

Identifier is the AST node that represents an identifier

func (*Identifier) String

func (i *Identifier) String() string

func (*Identifier) TokenLiteral

func (i *Identifier) TokenLiteral() string

type IndexExpression

type IndexExpression struct {
	Expression
	Token lexer.Token
	Array Expression
	Index Expression
}

IndexExpression represents an index expression

func (*IndexExpression) String

func (ie *IndexExpression) String() string

func (*IndexExpression) TokenLiteral

func (ie *IndexExpression) TokenLiteral() string

type InfixExpression

type InfixExpression struct {
	Expression
	Token    lexer.Token
	Left     Expression
	Operator string
	Right    Expression
}

InfixExpression represents an infix expression

func (*InfixExpression) String

func (ie *InfixExpression) String() string

func (*InfixExpression) TokenLiteral

func (ie *InfixExpression) TokenLiteral() string

type IntegerLiteral

type IntegerLiteral struct {
	Expression
	Token lexer.Token
	Value int64
}

IntegerLiteral represents an integer literal

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

type LetStatement

type LetStatement struct {
	Statement
	Token lexer.Token // the token.LET token
	Name  *Identifier
	Value Expression
}

func (*LetStatement) String

func (ls *LetStatement) String() string

func (*LetStatement) TokenLiteral

func (ls *LetStatement) TokenLiteral() string

type Node

type Node interface {
	TokenLiteral() string
	String() string
}

Node is the interface that all nodes in the AST implement

type PrefixExpression

type PrefixExpression struct {
	Expression
	Token    lexer.Token
	Operator string
	Right    Expression
}

PrefixExpression represents a prefix expression

func (*PrefixExpression) String

func (pe *PrefixExpression) String() string

func (*PrefixExpression) TokenLiteral

func (pe *PrefixExpression) TokenLiteral() string

type Program

type Program struct {
	Node
	Statements []Statement
}

Program is the root node of every AST that the parser produces

func (*Program) String

func (p *Program) String() string

String returns the string representation of the program

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

TokenLiteral returns the token literal of the first statement in the program

type ReturnStatement

type ReturnStatement struct {
	Statement
	Token       lexer.Token // the 'return' token
	ReturnValue Expression
}

RETURN statement

func (*ReturnStatement) String

func (rs *ReturnStatement) String() string

func (*ReturnStatement) TokenLiteral

func (rs *ReturnStatement) TokenLiteral() string

type Statement

type Statement interface {
	Node
	// contains filtered or unexported methods
}

Statement is the interface that all statement nodes in the AST implement

type StringLiteral

type StringLiteral struct {
	Expression
	Token lexer.Token
	Value string
}

StringLiteral represents a string literal

func (*StringLiteral) String

func (sl *StringLiteral) String() string

func (*StringLiteral) TokenLiteral

func (sl *StringLiteral) TokenLiteral() string

type WhileExpression

type WhileExpression struct {
	Expression
	Token     lexer.Token
	Condition Expression
	Body      *BlockStatement
}

WhileExpression represents a while expression

func (*WhileExpression) String

func (we *WhileExpression) String() string

func (*WhileExpression) TokenLiteral

func (we *WhileExpression) TokenLiteral() string

Jump to

Keyboard shortcuts

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