ast

package
v0.0.0-...-89ea315 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 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 ArrayLiteral

type ArrayLiteral struct {
	Token    token.Token // token.BRACKET
	Elements []Expression
}

func (*ArrayLiteral) String

func (al *ArrayLiteral) String() string

func (*ArrayLiteral) TokenLiteral

func (al *ArrayLiteral) TokenLiteral() string

type AssignmentStatement

type AssignmentStatement struct {
	Token              token.Token // token.LET
	AssignmentOperator token.Token
	Name               *Identifier
	Value              Expression
}

LET STATEMENT -> "let <identifier> = <expression>;"

func (*AssignmentStatement) String

func (aStatement *AssignmentStatement) String() string

func (*AssignmentStatement) TokenLiteral

func (aStatement *AssignmentStatement) TokenLiteral() string

type BlockStatement

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

BLOCK STATEMENT: A SERIES OF STATEMENTS

func (*BlockStatement) String

func (bs *BlockStatement) String() string

func (*BlockStatement) TokenLiteral

func (bs *BlockStatement) TokenLiteral() string

type Boolean

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

func (*Boolean) String

func (b *Boolean) String() string

func (*Boolean) TokenLiteral

func (b *Boolean) TokenLiteral() string

type CallExpression

type CallExpression struct {
	Token     token.Token // token.LPAREN
	Function  Expression  // Identifier of function OR FunctionLiteral
	Arguments []Expression
}

FUNCTION CALL EXPRESSION -> <expression>(<comma seperated expressions>)

func (*CallExpression) String

func (ce *CallExpression) String() string

func (*CallExpression) TokenLiteral

func (ce *CallExpression) TokenLiteral() string

type DotExpression

type DotExpression struct {
	Token     token.Token // token.DOT
	Left      Expression
	Attribute Expression
}

func (*DotExpression) String

func (de *DotExpression) String() string

func (*DotExpression) TokenLiteral

func (de *DotExpression) TokenLiteral() string

type Expression

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

type ExpressionStatement

type ExpressionStatement struct {
	Token      token.Token
	Expression Expression
}

EXPRESSION STATEMENT -> "<expression>;"

func (*ExpressionStatement) String

func (exp *ExpressionStatement) String() string

func (*ExpressionStatement) TokenLiteral

func (exp *ExpressionStatement) TokenLiteral() string

type FunctionLiteral

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

func (*FunctionLiteral) String

func (fl *FunctionLiteral) String() string

func (*FunctionLiteral) TokenLiteral

func (fl *FunctionLiteral) TokenLiteral() string

type HashLiteral

type HashLiteral struct {
	Token token.Token // token.LBRACE
	Pairs map[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
}

func (*Identifier) String

func (ident *Identifier) String() string

func (*Identifier) TokenLiteral

func (ident *Identifier) TokenLiteral() string

type IfExpression

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

IF EXPRESSION -> "if (<condition>) <consequence> else <alternative>"

func (*IfExpression) String

func (ifexp *IfExpression) String() string

func (*IfExpression) TokenLiteral

func (ifexp *IfExpression) TokenLiteral() string

type IndexExpression

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

INDEX EXPRESSION -> <expression>[<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 // Infix Operator Token
	Operator string
	Right    Expression
	Left     Expression
}

INFIX EXPRESSION -> <right expression> <operator> <left expression>

func (*InfixExpression) String

func (inexp *InfixExpression) String() string

func (*InfixExpression) TokenLiteral

func (inexp *InfixExpression) TokenLiteral() string

type IntegerLiteral

type IntegerLiteral struct {
	Token token.Token // token.INT
	Value int64
}

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

type Node

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

type PrefixExpression

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

PREFIX EXPRESSION -> <prefix operator> <expression>

func (*PrefixExpression) String

func (prexp *PrefixExpression) String() string

func (*PrefixExpression) TokenLiteral

func (prexp *PrefixExpression) TokenLiteral() string

type Program

type Program struct {
	Statements []Statement
}

Program will be the root node of every AST

func (*Program) String

func (p *Program) String() string

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

type ReturnStatement

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

RETURN STATEMENT -> "return <expression>;"

func (*ReturnStatement) String

func (rS *ReturnStatement) String() string

func (*ReturnStatement) TokenLiteral

func (rS *ReturnStatement) TokenLiteral() string

type Statement

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

type StringLiteral

type StringLiteral struct {
	Token token.Token // Token.STRING
	Value string
}

func (*StringLiteral) String

func (sl *StringLiteral) String() string

func (*StringLiteral) TokenLiteral

func (sl *StringLiteral) TokenLiteral() string

type WhileExpression

type WhileExpression struct {
	Token     token.Token // token.WHILE
	Condition Expression
	Body      *BlockStatement
}

WHILE EXPRESSION -> "while (<condition>) <consequence> "

func (*WhileExpression) String

func (whileExp *WhileExpression) String() string

func (*WhileExpression) TokenLiteral

func (whileExp *WhileExpression) TokenLiteral() string

Jump to

Keyboard shortcuts

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