ast

package
v0.0.0-...-8c2d49f Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 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 ArgumentPairExpression

type ArgumentPairExpression struct {
	*BaseNode
	Key   Expression
	Value Expression
}

ArgumentPairExpression represents a key/value pair in method parameters or arguments

func (*ArgumentPairExpression) String

func (ape *ArgumentPairExpression) String() string

String .....

func (*ArgumentPairExpression) TokenLiteral

func (ape *ArgumentPairExpression) TokenLiteral() string

TokenLiteral .....

type ArrayExpression

type ArrayExpression struct {
	*BaseNode
	Elements []Expression
}

ArrayExpression defines the array expression literal which contains the node expression and its value

func (*ArrayExpression) String

func (ae *ArrayExpression) String() string

ArrayExpression.String gets the string format of the Array type token

func (*ArrayExpression) TokenLiteral

func (ae *ArrayExpression) TokenLiteral() string

TokenLiteral gets the literal of the Array type token

type AssignExpression

type AssignExpression struct {
	*BaseNode
	Variables []Expression
	Value     Expression
	Optioned  int
}

AssignExpression represents a variable assignment.

func (*AssignExpression) String

func (ae *AssignExpression) String() string

func (*AssignExpression) TokenLiteral

func (ae *AssignExpression) TokenLiteral() string

TokenLiteral returns the literal for an asssignment

type BaseNode

type BaseNode struct {
	Token token.Token
	// contains filtered or unexported fields
}

BaseNode holds the attribute every expression or statement should have

func (*BaseNode) IsExp

func (b *BaseNode) IsExp() bool

IsExp returns if current node should be considered as an expression

func (*BaseNode) IsStmt

func (b *BaseNode) IsStmt() bool

IsStmt returns if current node should be considered as a statement

func (*BaseNode) Line

func (b *BaseNode) Line() int

Line returns node's token's line number

func (*BaseNode) MarkAsExp

func (b *BaseNode) MarkAsExp()

MarkAsExp marks current node to be expression

func (*BaseNode) MarkAsStmt

func (b *BaseNode) MarkAsStmt()

MarkAsStmt marks current node to be statement

type BlockStatement

type BlockStatement struct {
	*BaseNode
	Statements []Statement
}

BlockStatement represents a block

func (*BlockStatement) IsEmpty

func (bs *BlockStatement) IsEmpty() bool

IsEmpty true if this block has no contents

func (*BlockStatement) KeepLastValue

func (bs *BlockStatement) KeepLastValue()

KeepLastValue prevents block's last expression statement to be popped.

func (*BlockStatement) String

func (bs *BlockStatement) String() string

func (*BlockStatement) TokenLiteral

func (bs *BlockStatement) TokenLiteral() string

TokenLiteral returns the token for a block statement

type BooleanExpression

type BooleanExpression struct {
	*BaseNode
	Value bool
}

BooleanExpression defines the boolean expression literal which contains the node expression and its value

func (*BooleanExpression) String

func (b *BooleanExpression) String() string

BooleanExpression.String gets the string format of the Boolean type token

func (*BooleanExpression) TokenLiteral

func (b *BooleanExpression) TokenLiteral() string

TokenLiteral gets the literal of the Boolean type token

type BreakStatement

type BreakStatement struct {
	*BaseNode
}

BreakStatement represents "break" keyword

func (*BreakStatement) String

func (bs *BreakStatement) String() string

func (*BreakStatement) TokenLiteral

func (bs *BreakStatement) TokenLiteral() string

TokenLiteral returns token's literal

type CallExpression

type CallExpression struct {
	*BaseNode
	Receiver       Expression
	Method         string
	Arguments      []Expression
	Block          *BlockStatement
	BlockArguments []*Identifier
}

CallExpression represents a call

func (*CallExpression) String

func (ce *CallExpression) String() string

func (*CallExpression) TokenLiteral

func (ce *CallExpression) TokenLiteral() string

TokenLiteral returns the literal for a call expression

type ClassStatement

type ClassStatement struct {
	*BaseNode
	Name           *Constant
	Body           *BlockStatement
	SuperClass     Expression
	SuperClassName string
}

ClassStatement represents a class statement

func (*ClassStatement) String

func (cs *ClassStatement) String() string

func (*ClassStatement) TokenLiteral

func (cs *ClassStatement) TokenLiteral() string

TokenLiteral returns the token for a class statement

type ConditionalExpression

type ConditionalExpression struct {
	*BaseNode
	Condition   Expression
	Consequence *BlockStatement
}

ConditionalExpression represents if or elsif expression

func (*ConditionalExpression) String

func (ce *ConditionalExpression) String() string

func (*ConditionalExpression) TokenLiteral

func (ce *ConditionalExpression) TokenLiteral() string

TokenLiteral returns `if` or `elsif`

type Constant

type Constant struct {
	*BaseNode
	Value       string
	IsNamespace bool
}

Constant represents a constant

func (*Constant) ReturnValue

func (c *Constant) ReturnValue() string

ReturnValue returns the value of the constant

func (*Constant) String

func (c *Constant) String() string

func (*Constant) TokenLiteral

func (c *Constant) TokenLiteral() string

TokenLiteral returns the token for a constant expression

type ContinueStatement

type ContinueStatement struct {
	*BaseNode
}

ContinueStatement represents "continue" keyword

func (*ContinueStatement) String

func (ns *ContinueStatement) String() string

func (*ContinueStatement) TokenLiteral

func (ns *ContinueStatement) TokenLiteral() string

TokenLiteral returns token's literal

type DefStatement

type DefStatement struct {
	*BaseNode
	Name           *Identifier
	Receiver       Expression
	Parameters     []Expression
	BlockStatement *BlockStatement
}

DefStatement represents a def

func (*DefStatement) String

func (ds *DefStatement) String() string

func (*DefStatement) TokenLiteral

func (ds *DefStatement) TokenLiteral() string

TokenLiteral returns the token for a def statement

type Expression

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

Expression is the AST node for an expression

type ExpressionStatement

type ExpressionStatement struct {
	*BaseNode
	Expression Expression
}

ExpressionStatement represents an expression in statement form

func (*ExpressionStatement) String

func (es *ExpressionStatement) String() string

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

TokenLiteral returns the token for the expression

type FloatLiteral

type FloatLiteral struct {
	*BaseNode
	Value float64
}

FloatLiteral contains the node expression and its value

func (*FloatLiteral) String

func (il *FloatLiteral) String() string

FloatLiteral.String gets the string format of the Float type token

func (*FloatLiteral) TokenLiteral

func (il *FloatLiteral) TokenLiteral() string

TokenLiteral gets the literal of the Float type token

type GetBlockExpression

type GetBlockExpression struct {
	*BaseNode
}

GetBlockExpression represents `block` call in the AST

func (*GetBlockExpression) String

func (gbe *GetBlockExpression) String() string

String ...

func (*GetBlockExpression) TokenLiteral

func (gbe *GetBlockExpression) TokenLiteral() string

TokenLiteral ...

type HasBlockExpression

type HasBlockExpression struct {
	*BaseNode
}

HasBlockExpression represents `block` call in the AST

func (*HasBlockExpression) String

func (gbe *HasBlockExpression) String() string

String ...

func (*HasBlockExpression) TokenLiteral

func (gbe *HasBlockExpression) TokenLiteral() string

TokenLiteral ...

type HashExpression

type HashExpression struct {
	*BaseNode
	Data map[string]Expression
}

HashExpression defines the hash expression literal which contains the node expression and its value

func (*HashExpression) String

func (he *HashExpression) String() string

HashExpression.String gets the string format of the Hash type token

func (*HashExpression) TokenLiteral

func (he *HashExpression) TokenLiteral() string

TokenLiteral gets the literal of the Hash type token

type Identifier

type Identifier struct {
	*BaseNode
	Value string
}

Identifier represents an identifier

func (*Identifier) ReturnValue

func (i *Identifier) ReturnValue() string

ReturnValue returns the value of the identifier

func (*Identifier) String

func (i *Identifier) String() string

func (*Identifier) TokenLiteral

func (i *Identifier) TokenLiteral() string

TokenLiteral returns the token for an identifier expression

type IfExpression

type IfExpression struct {
	*BaseNode
	Conditionals []*ConditionalExpression
	Alternative  *BlockStatement
}

IfExpression represents an if statement

func (*IfExpression) String

func (ie *IfExpression) String() string

func (*IfExpression) TokenLiteral

func (ie *IfExpression) TokenLiteral() string

TokenLiteral returns the literal for an if expression

type InfixExpression

type InfixExpression struct {
	*BaseNode
	Left     Expression
	Operator string
	Right    Expression
}

InfixExpression represents a binary operator

func (*InfixExpression) String

func (ie *InfixExpression) String() string

func (*InfixExpression) TokenLiteral

func (ie *InfixExpression) TokenLiteral() string

TokenLiteral returns the literal for an InfixExpression

type InstanceVariable

type InstanceVariable struct {
	*BaseNode
	Value string
}

InstanceVariable represents an instance variable

func (*InstanceVariable) ReturnValue

func (iv *InstanceVariable) ReturnValue() string

ReturnValue returns the value of the instance variable

func (*InstanceVariable) String

func (iv *InstanceVariable) String() string

func (*InstanceVariable) TokenLiteral

func (iv *InstanceVariable) TokenLiteral() string

TokenLiteral returns the token for a instance variable expression

type IntegerLiteral

type IntegerLiteral struct {
	*BaseNode
	Value int
}

IntegerLiteral contains the node expression and its value

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

IntegerLiteral.String gets the string format of the Integer type token

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

TokenLiteral gets the Integer type token

type ModuleStatement

type ModuleStatement struct {
	*BaseNode
	Name       *Constant
	Body       *BlockStatement
	SuperClass *Constant
}

ModuleStatement represents module node in AST

func (*ModuleStatement) String

func (ms *ModuleStatement) String() string

func (*ModuleStatement) TokenLiteral

func (ms *ModuleStatement) TokenLiteral() string

TokenLiteral returns token's literal

type MultiVariableExpression

type MultiVariableExpression struct {
	*BaseNode
	Variables []Expression
}

MultiVariableExpression is not really an expression, it's just a container that holds multiple Variables

func (*MultiVariableExpression) String

func (m *MultiVariableExpression) String() string

func (*MultiVariableExpression) TokenLiteral

func (m *MultiVariableExpression) TokenLiteral() string

TokenLiteral returns the token for a multivariable expression

type NilExpression

type NilExpression struct {
	*BaseNode
}

NilExpression represents nil node

func (*NilExpression) String

func (n *NilExpression) String() string

String returns `nil`

func (*NilExpression) TokenLiteral

func (n *NilExpression) TokenLiteral() string

TokenLiteral returns `nil`

type PrefixExpression

type PrefixExpression struct {
	*BaseNode
	Operator string
	Right    Expression
}

PrefixExpression struct to represent a prefix operator

func (*PrefixExpression) String

func (pe *PrefixExpression) String() string

func (*PrefixExpression) TokenLiteral

func (pe *PrefixExpression) TokenLiteral() string

TokenLiteral returns the literal for a PrefixExpression

type Program

type Program struct {
	Statements []Statement
}

Program is the root node of entire AST

func (*Program) String

func (p *Program) String() string

String returns the string representation of the program

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

TokenLiteral returns the string literal for this AST node

type RangeExpression

type RangeExpression struct {
	*BaseNode
	Start     Expression
	End       Expression
	Exclusive bool
}

RangeExpression defines the range expression literal which contains the node expression and its start/end value

func (*RangeExpression) String

func (re *RangeExpression) String() string

RangeExpression.String gets the string format of the Range type token

func (*RangeExpression) TokenLiteral

func (re *RangeExpression) TokenLiteral() string

TokenLiteral gets the literal of the Range type token

type ReturnStatement

type ReturnStatement struct {
	*BaseNode
	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 the token for return

type SelfExpression

type SelfExpression struct {
	*BaseNode
	IsSuper bool
}

SelfExpression represents a reference to the object

func (*SelfExpression) String

func (se *SelfExpression) String() string

func (*SelfExpression) TokenLiteral

func (se *SelfExpression) TokenLiteral() string

TokenLiteral returns the literal for a self expression

type Statement

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

Statement is the AST node for a statement

type StringLiteral

type StringLiteral struct {
	*BaseNode
	Value string
}

StringLiteral contains the node expression and its value

func (*StringLiteral) String

func (sl *StringLiteral) String() string

StringLiteral.String gets the string format of the String type token

func (*StringLiteral) TokenLiteral

func (sl *StringLiteral) TokenLiteral() string

TokenLiteral gets the literal of the String type token

type Variable

type Variable interface {
	ReturnValue() string
	Expression
	// contains filtered or unexported methods
}

Variable interface represents assignable nodes, currently these are Identifier, InstanceVariable and Constant

type WhileStatement

type WhileStatement struct {
	*BaseNode
	Condition Expression
	Body      *BlockStatement
}

WhileStatement represents a while statement

func (*WhileStatement) String

func (ws *WhileStatement) String() string

func (*WhileStatement) TokenLiteral

func (ws *WhileStatement) TokenLiteral() string

TokenLiteral returns the token for a while statement

type YieldExpression

type YieldExpression struct {
	*BaseNode
	Arguments []Expression
}

YieldExpression represents a yield

func (*YieldExpression) String

func (ye *YieldExpression) String() string

func (*YieldExpression) TokenLiteral

func (ye *YieldExpression) TokenLiteral() string

TokenLiteral returns the literal for a yield

Jump to

Keyboard shortcuts

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