ast

package
v0.0.0-...-fb456ee Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: Apache-2.0 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 {
	Token    token.Token
	Elements []Expression
}

ArrayLiteral represents an array containing a list of expressions.

func (*ArrayLiteral) String

func (a *ArrayLiteral) String() string

func (*ArrayLiteral) TokenLiteral

func (a *ArrayLiteral) TokenLiteral() string

type BlockStatement

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

BlockStatement represents block statement within `{}`.

func (*BlockStatement) String

func (bs *BlockStatement) String() string

func (*BlockStatement) TokenLiteral

func (bs *BlockStatement) TokenLiteral() string

type BooleanLiteral

type BooleanLiteral struct {
	Token token.Token
	Value bool
}

BooleanLiteral represents string representation of boolean.

func (*BooleanLiteral) String

func (b *BooleanLiteral) String() string

func (*BooleanLiteral) TokenLiteral

func (b *BooleanLiteral) TokenLiteral() string

type CallExpression

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

CallExpression represents function call.

func (*CallExpression) String

func (ce *CallExpression) String() string

func (*CallExpression) TokenLiteral

func (ce *CallExpression) TokenLiteral() string

type Expression

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

Expression describes AST expression that produces a value.

type ExpressionStatement

type ExpressionStatement struct {
	Token      token.Token
	Expression Expression
}

ExpressionStatement represents expression statement.

func (*ExpressionStatement) String

func (e *ExpressionStatement) String() string

func (*ExpressionStatement) TokenLiteral

func (e *ExpressionStatement) TokenLiteral() string

type FunctionLiteral

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

FunctionLiteral represents function definition.

func (*FunctionLiteral) String

func (fl *FunctionLiteral) String() string

func (*FunctionLiteral) TokenLiteral

func (fl *FunctionLiteral) TokenLiteral() string

type HashLiteral

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

HashLiteral represents hash literal: { <expression>: <expression> }.

func (*HashLiteral) String

func (hl *HashLiteral) String() string

func (*HashLiteral) TokenLiteral

func (hl *HashLiteral) TokenLiteral() string

type Identifier

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

Identifier represents statement's identifier.

func (*Identifier) String

func (i *Identifier) String() string

func (*Identifier) TokenLiteral

func (i *Identifier) TokenLiteral() string

type IfExpression

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

IfExpression represents `if-else` expression.

func (*IfExpression) String

func (ie *IfExpression) String() string

func (*IfExpression) TokenLiteral

func (ie *IfExpression) TokenLiteral() string

type IndexExpression

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

IndexExpression represents index expression: <left-expression>[<index-expression>].

func (*IndexExpression) String

func (ie *IndexExpression) String() string

func (*IndexExpression) TokenLiteral

func (ie *IndexExpression) TokenLiteral() string

type InfixExpression

type InfixExpression struct {
	Token    token.Token // The operator token, e.g. +
	Left     Expression
	Operator string
	Right    Expression
}

InfixExpression represents infix expressions, e.x: 5 + 5.

func (*InfixExpression) String

func (oe *InfixExpression) String() string

func (*InfixExpression) TokenLiteral

func (oe *InfixExpression) TokenLiteral() string

type IntegerLiteral

type IntegerLiteral struct {
	Token token.Token
	Value int64
}

IntegerLiteral represents string representation of an integer.

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

type LetStatement

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

LetStatement represents `let` statement.

func (*LetStatement) String

func (l *LetStatement) String() string

func (*LetStatement) TokenLiteral

func (l *LetStatement) TokenLiteral() string

type Node

type Node interface {
	fmt.Stringer
	TokenLiteral() string
}

Node describes a minimal entity of AST.

type PrefixExpression

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

PrefixExpression represents prefix expression e.x: -5, !IsValid(some) and etc.

func (*PrefixExpression) String

func (pe *PrefixExpression) String() string

func (*PrefixExpression) TokenLiteral

func (pe *PrefixExpression) TokenLiteral() string

type ReturnStatement

type ReturnStatement struct {
	Token token.Token
	Value Expression
}

ReturnStatement represents `return` statement.

func (*ReturnStatement) String

func (r *ReturnStatement) String() string

func (*ReturnStatement) TokenLiteral

func (r *ReturnStatement) TokenLiteral() string

type Root

type Root struct {
	Statements []Statement
}

Root represents a root node of program's AST.

func (*Root) String

func (r *Root) String() string

func (*Root) TokenLiteral

func (r *Root) TokenLiteral() string

type Statement

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

Statement describes AST statement e.x: variable and etc.

type StringLiteral

type StringLiteral struct {
	Token token.Token
	Value string
}

StringLiteral represents string.

func (*StringLiteral) String

func (sl *StringLiteral) String() 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