syntaxtree

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 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 BlockStatement

type BlockStatement struct {
	// Represents the '{' token
	Token lexer.Token

	// Represents the statements in the code block
	Statements []Statement
}

A structure that represents a block of code statements

func (*BlockStatement) String

func (bs *BlockStatement) String() string

A method of BlockStatement that returns its string representation

func (*BlockStatement) TokenLiteral

func (bs *BlockStatement) TokenLiteral() string

A method of BlockStatement that returns its token literal value

type BooleanLiteral

type BooleanLiteral struct {
	// Represents the lexological token 'TRUE'/'FALSE'
	Token lexer.Token

	// Represents the boolean value
	Value bool
}

A structure that represents a Boolean literal

func (*BooleanLiteral) String

func (b *BooleanLiteral) String() string

A method of BooleanLiteral that returns its string representation

func (*BooleanLiteral) TokenLiteral

func (b *BooleanLiteral) TokenLiteral() string

A method of BooleanLiteral that returns its token literal value

type CallExpression

type CallExpression struct {
	// Represents the ( token
	Token lexer.Token

	// Represents the function identifier
	Function Expression

	// Represents the function arguments
	Arguments []Expression
}

A structure that represents an call expression node on the syntax tree

func (*CallExpression) String

func (ce *CallExpression) String() string

A method of CallExpression that returns its string representation

func (*CallExpression) TokenLiteral

func (ce *CallExpression) TokenLiteral() string

A method of CallExpression that returns its token literal value

type Expression

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

An interface that represents an expression node on the Abstract Syntax Tree

type ExpressionStatement

type ExpressionStatement struct {
	// Represents the first token of the expression
	Token lexer.Token

	// Represents the full Expression
	Expression Expression
}

A structure that represents a statement wrapper for an expression

func (*ExpressionStatement) String

func (es *ExpressionStatement) String() string

A method of ExpressionStatement that returns its string representation

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

A method of ExpressionStatement that returns its token literal value

type FunctionLiteral

type FunctionLiteral struct {
	// Represents the lexological token 'FN'
	Token lexer.Token

	// Represent the list of function parameters
	Parameters []*Identifier

	// Represents the block of statements in the function
	Body *BlockStatement
}

A structure that represents a Function literal

func (*FunctionLiteral) String

func (fl *FunctionLiteral) String() string

A method of FunctionLiteral that returns its string representation

func (*FunctionLiteral) TokenLiteral

func (fl *FunctionLiteral) TokenLiteral() string

A method of FunctionLiteral that returns its token literal value

type Identifier

type Identifier struct {
	// Represents the lexological token 'IDENT'
	Token lexer.Token

	// Represents the identifier name
	Value string
}

A structure that represents an Identifier literal

func (*Identifier) String

func (i *Identifier) String() string

A method of Identifier that returns its string representation

func (*Identifier) TokenLiteral

func (i *Identifier) TokenLiteral() string

A method of Identifier that returns its token literal value

type IfExpression

type IfExpression struct {
	// Represents the IF token
	Token lexer.Token

	// Represents the conditional expression
	Condition Expression

	// Represents the consequent statement if conditional evaulates to true
	Consequence *BlockStatement

	// Represents the alternative consequent statement if conditional evaulates to false
	Alternative *BlockStatement
}

A structure that represents an if expression node on the syntax tree

func (*IfExpression) String

func (ie *IfExpression) String() string

A method of IfExpression that returns its string representation

func (*IfExpression) TokenLiteral

func (ie *IfExpression) TokenLiteral() string

A method of IfExpression that returns its token literal value

type IndexExpression

type IndexExpression struct {
	// Represents the [ token
	Token lexer.Token

	// Represents the indexable expression
	Left Expression

	// Represents the index of the expression
	Index Expression
}

A structure that represents an index expression node on the syntax tree

func (*IndexExpression) String

func (ie *IndexExpression) String() string

A method of IndexExpression that returns its string representation

func (*IndexExpression) TokenLiteral

func (ie *IndexExpression) TokenLiteral() string

A method of IndexExpression that returns its token literal value

type InfixExpression

type InfixExpression struct {
	// Represents the infix operator token
	Token lexer.Token

	// Represents the expression before the operator
	Left Expression

	// Represents the operator literal string
	Operator string

	// Represents the expression after the operator
	Right Expression
}

A structure that represents an infix expression node on the syntax tree

func (*InfixExpression) String

func (ie *InfixExpression) String() string

A method of InfixExpression that returns its string representation

func (*InfixExpression) TokenLiteral

func (ie *InfixExpression) TokenLiteral() string

A method of InfixExpression that returns its token literal value

type IntegerLiteral

type IntegerLiteral struct {
	// Represents the lexological token 'INT'
	Token lexer.Token

	// Represents the integer value
	Value int64
}

A structure that represents an Integer literal

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

A method of IntegerLiteral that returns its string representation

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

A method of IntegerLiteral that returns its token literal value

type LetStatement

type LetStatement struct {
	// Represents the lexological token 'LET'
	Token lexer.Token

	// Represents the identifier in the let statement
	Name *Identifier

	// Represents the value in the let statement
	Value Expression
}

A structure that represents a Let statement token

func (*LetStatement) String

func (ls *LetStatement) String() string

A method of LetStatment that returns its string representation

func (*LetStatement) TokenLiteral

func (ls *LetStatement) TokenLiteral() string

A method of LetStatement that returns its token literal value

type ListLiteral

type ListLiteral struct {
	// Represents the lexological token '['
	Token lexer.Token

	// Represents the slice of list elements
	Elements []Expression
}

A structure that represents a List literal

func (*ListLiteral) String

func (ll *ListLiteral) String() string

A method of ListLiteral that returns its string representation

func (*ListLiteral) TokenLiteral

func (ll *ListLiteral) TokenLiteral() string

A method of ListLiteral that returns its token literal value

type MapLiteral

type MapLiteral struct {
	// Represents the lexological token '{'
	Token lexer.Token

	// Represents the key-value pairs of the mapping
	Pairs map[Expression]Expression
}

A structure that represents a Map literal

func (*MapLiteral) String

func (ml *MapLiteral) String() string

A method of MapLiteral that returns its string representation

func (*MapLiteral) TokenLiteral

func (ml *MapLiteral) TokenLiteral() string

A method of MapLiteral that returns its token literal value

type Node

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

An interface that represents a node on the Abstract Syntax Tree

type PrefixExpression

type PrefixExpression struct {
	// Represents the prefix operator token
	Token lexer.Token

	// Represents the operator literal string
	Operator string

	// Represents the expression after the operator
	Right Expression
}

A structure that represents a prefix expression node on the syntax tree

func (*PrefixExpression) String

func (pe *PrefixExpression) String() string

A method of PrefixExpression that returns its string representation

func (*PrefixExpression) TokenLiteral

func (pe *PrefixExpression) TokenLiteral() string

A method of PrefixExpression that returns its token literal value

type Program

type Program struct {
	Statements []Statement
}

A structure that represents the collection of statements in the program

func (*Program) String

func (p *Program) String() string

A method of Program that returns the string representation of the Program by accumulating the string values of each statement in the program into a bytes buffer and returning its string value

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

A method of Program that returns the token literal of the first statement in the program

type ReturnStatement

type ReturnStatement struct {
	// Represents the lexological token 'RETURN'
	Token lexer.Token

	// Represents the value in the return statement
	ReturnValue Expression
}

A structure that represents a Return statement token

func (*ReturnStatement) String

func (rs *ReturnStatement) String() string

A method of ReturnStatement that returns its string representation

func (*ReturnStatement) TokenLiteral

func (rs *ReturnStatement) TokenLiteral() string

A method of ReturnStatement that returns its token literal value

type Statement

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

An interface that represents a statement node on the Abstract Syntax Tree

type StringLiteral

type StringLiteral struct {
	// Represents the lexological token 'STRING'
	Token lexer.Token

	// Represents the string value
	Value string
}

A structure that represents an String literal

func (*StringLiteral) String

func (il *StringLiteral) String() string

A method of StringLiteral that returns its string representation

func (*StringLiteral) TokenLiteral

func (il *StringLiteral) TokenLiteral() string

A method of StringLiteral that returns its token literal value

Jump to

Keyboard shortcuts

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