ast

package
v0.0.0-...-99afa44 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 4 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 {
	Token    token.Token // '['
	Elements []Expression
}

func (*ArrayLiteral) ToString

func (al *ArrayLiteral) ToString() string

func (*ArrayLiteral) TokenLiteral

func (al *ArrayLiteral) TokenLiteral() string

type AssignStatement

type AssignStatement struct {
	Name  *Ident
	Value Expression
}

Statements

func (*AssignStatement) ToString

func (as *AssignStatement) ToString() string

func (*AssignStatement) TokenLiteral

func (as *AssignStatement) TokenLiteral() string

type BlockStatement

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

func (*BlockStatement) ToString

func (bs *BlockStatement) ToString() string

func (*BlockStatement) TokenLiteral

func (bs *BlockStatement) TokenLiteral() string

type Boolean

type Boolean struct {
	Token token.Token // TRUE, FALSE
	Value bool
}

func (*Boolean) ToString

func (b *Boolean) ToString() string

func (*Boolean) TokenLiteral

func (b *Boolean) TokenLiteral() string

type CallExpression

type CallExpression struct {
	Token     token.Token // '('
	Function  Expression  // Ident
	Arguments []Expression
}

func (*CallExpression) ToString

func (ce *CallExpression) ToString() string

func (*CallExpression) TokenLiteral

func (ce *CallExpression) TokenLiteral() string

type Expression

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

All expression nodes implement

type ExpressionStatement

type ExpressionStatement struct {
	Token      token.Token
	Expression Expression
}

func (*ExpressionStatement) ToString

func (es *ExpressionStatement) ToString() string

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

type FunctionLiteral

type FunctionLiteral struct {
	Token      token.Token // 'fn'
	Parameters []*Ident
	Body       *BlockStatement
}

func (*FunctionLiteral) ToString

func (fl *FunctionLiteral) ToString() string

func (*FunctionLiteral) TokenLiteral

func (fl *FunctionLiteral) TokenLiteral() string

type HashMapLiteral

type HashMapLiteral struct {
	Token token.Token // {
	Pairs map[Expression]Expression
}

func (*HashMapLiteral) ToString

func (hl *HashMapLiteral) ToString() string

func (*HashMapLiteral) TokenLiteral

func (hl *HashMapLiteral) TokenLiteral() string

type Ident

type Ident struct {
	Token token.Token // IDENT
	Value string
}

func (*Ident) ToString

func (i *Ident) ToString() string

func (*Ident) TokenLiteral

func (i *Ident) TokenLiteral() string

type IfExpression

type IfExpression struct {
	Token       token.Token // if
	Condition   Expression
	Consequence *BlockStatement
	Alternative *BlockStatement
}

func (*IfExpression) ToString

func (ie *IfExpression) ToString() string

func (*IfExpression) TokenLiteral

func (ie *IfExpression) TokenLiteral() string

type IndexExpression

type IndexExpression struct {
	Token token.Token // [
	Left  Expression
	Index Expression
}

func (*IndexExpression) ToString

func (ie *IndexExpression) ToString() string

func (*IndexExpression) TokenLiteral

func (ie *IndexExpression) TokenLiteral() string

type InfixExpression

type InfixExpression struct {
	Token    token.Token // +, -, etc
	Left     Expression
	Operator string
	Right    Expression
}

func (*InfixExpression) ToString

func (oe *InfixExpression) ToString() string

func (*InfixExpression) TokenLiteral

func (oe *InfixExpression) TokenLiteral() string

type IntegerLiteral

type IntegerLiteral struct {
	Token token.Token // 5 6
	Value int64
}

Expressions

func (*IntegerLiteral) ToString

func (il *IntegerLiteral) ToString() string

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

type Node

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

type PrefixExpression

type PrefixExpression struct {
	Token    token.Token // !
	Operator string
	Right    Expression
}

func (*PrefixExpression) ToString

func (pe *PrefixExpression) ToString() string

func (*PrefixExpression) TokenLiteral

func (pe *PrefixExpression) TokenLiteral() string

type Program

type Program struct {
	Statements []Statement
}

func (*Program) ToString

func (p *Program) ToString() string

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

func (*Program) Tree

func (p *Program) Tree() string

return pretty AST nodes

type ReturnStatement

type ReturnStatement struct {
	Token token.Token // return
	Value Expression
}

func (*ReturnStatement) ToString

func (rs *ReturnStatement) ToString() string

func (*ReturnStatement) TokenLiteral

func (rs *ReturnStatement) TokenLiteral() string

type Statement

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

All statement nodes implement

type StringLiteral

type StringLiteral struct {
	Token token.Token
	Value string
}

func (*StringLiteral) ToString

func (sl *StringLiteral) ToString() string

func (*StringLiteral) TokenLiteral

func (sl *StringLiteral) TokenLiteral() string

Jump to

Keyboard shortcuts

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