ast

package
v0.0.0-...-defdebb Latest Latest
Warning

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

Go to latest
Published: May 3, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ast : Statement and Expression node definitions used to build an Abstract Syntax Tree for Monkey programs

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
}

ArrayLiteral : Expression node representing an array of elements

func (*ArrayLiteral) String

func (al *ArrayLiteral) String() string

func (*ArrayLiteral) TokenLiteral

func (al *ArrayLiteral) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type AssignStatement

type AssignStatement struct {
	Token token.Token
	Name  *Identifier
	Value Expression
}

AssignStatement : Statement node representing assigning a value to an existing object

func (*AssignStatement) String

func (as *AssignStatement) String() string

func (*AssignStatement) TokenLiteral

func (as *AssignStatement) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type BlockStatement

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

BlockStatement : Statement node representing a block of statements

func (*BlockStatement) String

func (bs *BlockStatement) String() string

func (*BlockStatement) TokenLiteral

func (bs *BlockStatement) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type Boolean

type Boolean struct {
	Token token.Token
	Value bool
}

Boolean : Expression node representing a boolean literal

func (*Boolean) String

func (b *Boolean) String() string

func (*Boolean) TokenLiteral

func (b *Boolean) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type CallExpression

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

CallExpression : Expression node representing calling a function and passing it arguments

func (*CallExpression) String

func (ce *CallExpression) String() string

func (*CallExpression) TokenLiteral

func (ce *CallExpression) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type CharacterLiteral

type CharacterLiteral struct {
	Token token.Token
	Value byte
}

CharacterLiteral : Expression node representing a character literal

func (*CharacterLiteral) String

func (cl *CharacterLiteral) String() string

func (*CharacterLiteral) TokenLiteral

func (cl *CharacterLiteral) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type Expression

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

Expression : Generic AST expression node

type ExpressionStatement

type ExpressionStatement struct {
	Token      token.Token
	Expression Expression
}

ExpressionStatement : Statement node representing a high-level expression

func (*ExpressionStatement) String

func (es *ExpressionStatement) String() string

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type FloatLiteral

type FloatLiteral struct {
	Token token.Token
	Value float64
}

FloatLiteral : Expression node representing an float literal

func (*FloatLiteral) String

func (fl *FloatLiteral) String() string

func (*FloatLiteral) TokenLiteral

func (fl *FloatLiteral) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type FunctionLiteral

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

FunctionLiteral : Expression node representing a function literal including its parameters and body statements

func (*FunctionLiteral) String

func (fl *FunctionLiteral) String() string

func (*FunctionLiteral) TokenLiteral

func (fl *FunctionLiteral) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type HashLiteral

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

HashLiteral : Expression node representing a map of key-value pairs

func (*HashLiteral) String

func (hl *HashLiteral) String() string

func (*HashLiteral) TokenLiteral

func (hl *HashLiteral) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type Identifier

type Identifier struct {
	Token token.Token
	Value string
}

Identifier : Expression node representing an identifier literal

func (*Identifier) String

func (i *Identifier) String() string

func (*Identifier) TokenLiteral

func (i *Identifier) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type IfExpression

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

IfExpression : Expression node representing an if/else block

func (*IfExpression) String

func (ie *IfExpression) String() string

func (*IfExpression) TokenLiteral

func (ie *IfExpression) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type IndexExpression

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

IndexExpression : Expression node representing finding the index of an array

func (*IndexExpression) String

func (ie *IndexExpression) String() string

func (*IndexExpression) TokenLiteral

func (ie *IndexExpression) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type InfixExpression

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

InfixExpression : Expression node representing infix expressions such as arithmetic and comparisons

func (*InfixExpression) String

func (ie *InfixExpression) String() string

func (*InfixExpression) TokenLiteral

func (ie *InfixExpression) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type IntegerLiteral

type IntegerLiteral struct {
	Token token.Token
	Value int64
}

IntegerLiteral : Expression node representing an integer literal

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type LetStatement

type LetStatement struct {
	Token token.Token
	Name  *Identifier
	Value Expression
}

LetStatement : Statement node representing variable declaration and assignment

func (*LetStatement) String

func (ls *LetStatement) String() string

func (*LetStatement) TokenLiteral

func (ls *LetStatement) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type Node

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

Node : Generic AST node

type PostfixExpression

type PostfixExpression struct {
	Token    token.Token
	Left     Expression
	Operator string
}

PostfixExpression : Expression node representing postfix expressions like incrementing and decrementing

func (*PostfixExpression) String

func (pe *PostfixExpression) String() string

func (*PostfixExpression) TokenLiteral

func (pe *PostfixExpression) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type PrefixExpression

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

PrefixExpression : Expression node representing prefix expressions like negative numbers, negation, and prefix incrementing/decrementing

func (*PrefixExpression) String

func (pe *PrefixExpression) String() string

func (*PrefixExpression) TokenLiteral

func (pe *PrefixExpression) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type Program

type Program struct {
	Statements []Statement
}

Program : Top level construct containing all parsed AST nodes

func (*Program) String

func (p *Program) String() string

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

TokenLiteral : Returns the literal representations of the tokens for each of the program's statements

type ReturnStatement

type ReturnStatement struct {
	Token       token.Token
	ReturnValue Expression
}

ReturnStatement : Statement node representing returning a value

func (*ReturnStatement) String

func (rs *ReturnStatement) String() string

func (*ReturnStatement) TokenLiteral

func (rs *ReturnStatement) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type ShortcutAssignStatement

type ShortcutAssignStatement struct {
	Token    token.Token
	Name     *Identifier
	Value    Expression
	Operator string
}

ShortcutAssignStatement : Statement node representing doing an operator to the existing object and assigning that new value

func (*ShortcutAssignStatement) String

func (sas *ShortcutAssignStatement) String() string

func (*ShortcutAssignStatement) TokenLiteral

func (sas *ShortcutAssignStatement) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type Statement

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

Statement : Generic AST statement node

type StringLiteral

type StringLiteral struct {
	Token token.Token
	Value string
}

StringLiteral : Expression node representing a string literal

func (*StringLiteral) String

func (sl *StringLiteral) String() string

func (*StringLiteral) TokenLiteral

func (sl *StringLiteral) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

type WhileExpression

type WhileExpression struct {
	Token     token.Token
	Condition Expression
	Block     *BlockStatement
}

WhileExpression : Expression node representing a while loop

func (*WhileExpression) String

func (we *WhileExpression) String() string

func (*WhileExpression) TokenLiteral

func (we *WhileExpression) TokenLiteral() string

TokenLiteral : Returns the literal representation of the token

Jump to

Keyboard shortcuts

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