ast

package
v0.0.0-...-af76a4e Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2019 License: MIT Imports: 3 Imported by: 4

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 // the '[' token
	Elements []Expression
}

ArrayLiteral represents an array literal.

func (*ArrayLiteral) String

func (al *ArrayLiteral) String() string

func (*ArrayLiteral) TokenLiteral

func (al *ArrayLiteral) TokenLiteral() string

TokenLiteral returns a token literal of array.

type BlockStatement

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

BlockStatement represents a block statement.

func (*BlockStatement) String

func (bs *BlockStatement) String() string

func (*BlockStatement) TokenLiteral

func (bs *BlockStatement) TokenLiteral() string

TokenLiteral returns a token literal of block statement.

type Boolean

type Boolean struct {
	Token token.Token
	Value bool
}

Boolean represents a boolean value.

func (*Boolean) String

func (b *Boolean) String() string

func (*Boolean) TokenLiteral

func (b *Boolean) TokenLiteral() string

TokenLiteral returns a token literal of boolean value.

type CallExpression

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

CallExpression represents a function call expression.

func (*CallExpression) String

func (ce *CallExpression) String() string

func (*CallExpression) TokenLiteral

func (ce *CallExpression) TokenLiteral() string

TokenLiteral returns a token literal of function call expression.

type Expression

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

Expression represents an expression.

type ExpressionStatement

type ExpressionStatement struct {
	Token      token.Token // the first token of the expression
	Expression Expression
}

ExpressionStatement represents an expression statement.

func (*ExpressionStatement) String

func (es *ExpressionStatement) String() string

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

TokenLiteral returns a token literal of expression statement.

type FloatLiteral

type FloatLiteral struct {
	Token token.Token
	Value float64
}

FloatLiteral represents a floating point number literal.

func (*FloatLiteral) String

func (fl *FloatLiteral) String() string

func (*FloatLiteral) TokenLiteral

func (fl *FloatLiteral) TokenLiteral() string

TokenLiteral returns a token literal of floating point number.

type FunctionLiteral

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

FunctionLiteral represents a fuction literal.

func (*FunctionLiteral) String

func (fl *FunctionLiteral) String() string

func (*FunctionLiteral) TokenLiteral

func (fl *FunctionLiteral) TokenLiteral() string

TokenLiteral returns a token literal of function.

type HashLiteral

type HashLiteral struct {
	Token token.Token // the '{' 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

TokenLiteral returns a token literal of hash.

type Ident

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

Ident represents an identifier.

func (*Ident) String

func (i *Ident) String() string

func (*Ident) TokenLiteral

func (i *Ident) TokenLiteral() string

TokenLiteral returns a token literal of an identifier.

type IfExpression

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

IfExpression represents an if expression.

func (*IfExpression) String

func (ie *IfExpression) String() string

func (*IfExpression) TokenLiteral

func (ie *IfExpression) TokenLiteral() string

TokenLiteral returns a token literal of if expression.

type IndexExpression

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

IndexExpression represents an expression in array index operator.

func (*IndexExpression) String

func (ie *IndexExpression) String() string

func (*IndexExpression) TokenLiteral

func (ie *IndexExpression) TokenLiteral() string

TokenLiteral returns a token literal of array.

type InfixExpression

type InfixExpression struct {
	Token    token.Token // The operator token, e.g. +
	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

TokenLiteral returns a token literal.

type IntegerLiteral

type IntegerLiteral struct {
	Token token.Token
	Value int64
}

IntegerLiteral represents an integer literal.

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

TokenLiteral returns a token literal of integer.

type LetStatement

type LetStatement struct {
	Token token.Token // the token.LET token
	Name  *Ident
	Value Expression
}

LetStatement represents a let statement.

func (*LetStatement) String

func (ls *LetStatement) String() string

func (*LetStatement) TokenLiteral

func (ls *LetStatement) TokenLiteral() string

TokenLiteral returns a token literal of let statement.

type MacroLiteral

type MacroLiteral struct {
	Token      token.Token
	Parameters []*Ident
	Body       *BlockStatement
}

MacroLiteral represents a macro literal.

func (*MacroLiteral) String

func (ml *MacroLiteral) String() string

func (*MacroLiteral) TokenLiteral

func (ml *MacroLiteral) TokenLiteral() string

TokenLiteral returns a token literal of function.

type ModifierFunc

type ModifierFunc func(Node) Node

ModifierFunc represents a function which modifies a node.

type Node

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

Node represents an AST node.

func Modify

func Modify(node Node, modifier ModifierFunc) Node

Modify modifies a `node` using `modifier` function.

type PrefixExpression

type PrefixExpression struct {
	Token    token.Token // The prefix token, e.g. !
	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

TokenLiteral returns a token literal.

type Program

type Program struct {
	Statements []Statement
}

Program is a top-level AST node of a program.

func (*Program) String

func (p *Program) String() string

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

TokenLiteral returns the first token literal of a program.

type ReturnStatement

type ReturnStatement struct {
	Token       token.Token // the token.RETURN token
	ReturnValue Expression
}

ReturnStatement represents a return statement.

func (*ReturnStatement) String

func (rs *ReturnStatement) String() string

func (*ReturnStatement) TokenLiteral

func (rs *ReturnStatement) TokenLiteral() string

TokenLiteral returns a token literal of return statement.

type Statement

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

Statement represents a statement.

type StringLiteral

type StringLiteral struct {
	Token token.Token
	Value string
}

StringLiteral represents a string literal.

func (*StringLiteral) String

func (sl *StringLiteral) String() string

func (*StringLiteral) TokenLiteral

func (sl *StringLiteral) TokenLiteral() string

TokenLiteral returns a token literal of string.

Jump to

Keyboard shortcuts

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