ast

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: GPL-3.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 Array

type Array struct {
	Token    token.Token // the '[' token
	Elements []Expression
}

func (*Array) String

func (array *Array) String() string

func (*Array) TokenLiteral

func (array *Array) TokenLiteral() string

type AssignExpression

type AssignExpression struct {
	Token token.Token // The token.ASSIGN token
	Ident *Identifier
	Value Expression
}

func (*AssignExpression) String

func (assignExpression *AssignExpression) String() string

func (*AssignExpression) TokenLiteral

func (assignExpression *AssignExpression) TokenLiteral() string

type BlockStatement

type BlockStatement struct {
	Token      token.Token // token.LEFTBRAC and token.RIGHTBRAC
	Statements []Statement
}

func (*BlockStatement) String

func (blockStatement *BlockStatement) String() string

func (*BlockStatement) TokenLiteral

func (blockStatement *BlockStatement) TokenLiteral() string

type Boolean

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

func (*Boolean) String

func (boolean *Boolean) String() string

func (*Boolean) TokenLiteral

func (b *Boolean) TokenLiteral() string

type BreakStatement added in v0.0.3

type BreakStatement struct {
	Token token.Token // token.BREAK
}

func (*BreakStatement) String added in v0.0.3

func (breakStatement *BreakStatement) String() string

func (*BreakStatement) TokenLiteral added in v0.0.3

func (breakStatement *BreakStatement) TokenLiteral() string

type CallFunction

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

func (*CallFunction) String

func (callFunction *CallFunction) String() string

func (*CallFunction) TokenLiteral

func (callFunction *CallFunction) TokenLiteral() string

type ConstStatement

type ConstStatement struct {
	Token token.Token // token.CONST
	Name  *Identifier
	Value Expression
}

func (*ConstStatement) String

func (constStatement *ConstStatement) String() string

func (*ConstStatement) TokenLiteral

func (cs *ConstStatement) TokenLiteral() string

type DuringExpression added in v0.0.3

type DuringExpression struct {
	Token     token.Token // token.DURING
	Condition Expression
	Body      *BlockStatement // during body
}

func (*DuringExpression) String added in v0.0.3

func (duringExpression *DuringExpression) String() string

func (*DuringExpression) TokenLiteral added in v0.0.3

func (duringExpression *DuringExpression) TokenLiteral() string

type Expression

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

type ExpressionStatement

type ExpressionStatement struct {
	// We need this because sometimes we have an expression act like a statement
	// e.g let x = 5;
	// x + 10; // this is an expression but it acts like a statement
	Token      token.Token // the first token of the expression
	Expression Expression
}

func (*ExpressionStatement) String

func (expressionStatement *ExpressionStatement) String() string

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

type Float added in v0.0.5

type Float struct {
	Token token.Token // token.Float
	Value float64
}

func (*Float) String added in v0.0.5

func (float *Float) String() string

func (*Float) TokenLiteral added in v0.0.5

func (float *Float) TokenLiteral() string

type ForStatement added in v0.0.4

type ForStatement struct {
	Token      token.Token     // The token.FOR
	IdxIdent   *Identifier     // The index identifier of the loop
	VarIdent   *Identifier     // The variable identifier of the loop
	Expression Expression      // The expression to iterate over
	Body       *BlockStatement // The body of the loop
}

func (*ForStatement) String added in v0.0.4

func (fs *ForStatement) String() string

func (*ForStatement) TokenLiteral added in v0.0.4

func (fs *ForStatement) TokenLiteral() string

type Function

type Function struct {
	Token      token.Token // the 'fun' token
	Parameters []*Identifier
	Body       *BlockStatement
}

func (*Function) String

func (f *Function) String() string

func (*Function) TokenLiteral

func (f *Function) TokenLiteral() string

type Hash

type Hash struct {
	Token token.Token // The '{' token
	Pairs map[Expression]Expression
}

func (*Hash) String

func (hash *Hash) String() string

func (*Hash) TokenLiteral

func (hash *Hash) TokenLiteral() string

type Identifier

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

func (*Identifier) String

func (identifier *Identifier) String() string

func (*Identifier) TokenLiteral

func (i *Identifier) TokenLiteral() string

type IfExpression

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

func (*IfExpression) String

func (ifExpression *IfExpression) String() string

func (*IfExpression) TokenLiteral

func (ifExpression *IfExpression) TokenLiteral() string

type IndexExpression

type IndexExpression struct {
	Token token.Token // The [ token
	Ident Expression
	Index Expression
	Value Expression
}

func (*IndexExpression) String

func (idx *IndexExpression) String() string

func (*IndexExpression) TokenLiteral

func (idx *IndexExpression) TokenLiteral() string

type InfixExpression

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

func (*InfixExpression) String

func (infixExpression *InfixExpression) String() string

func (*InfixExpression) TokenLiteral

func (infixExpression *InfixExpression) TokenLiteral() string

type Integer added in v0.0.5

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

func (*Integer) String added in v0.0.5

func (integer *Integer) String() string

func (*Integer) TokenLiteral added in v0.0.5

func (integer *Integer) TokenLiteral() string

type LetStatement

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

func (*LetStatement) String

func (letStatement *LetStatement) String() string

func (*LetStatement) TokenLiteral

func (ls *LetStatement) TokenLiteral() string

type Node

type Node interface {
	TokenLiteral() string
	String() string // This will allow us to print AST nodes for debugging and to compare them with other AST nodes.
}

type PrefixExpression

type PrefixExpression struct {
	Token    token.Token // The prefix token, e.g. !
	Operator string
	Right    Expression
}

func (*PrefixExpression) String

func (prefixExpression *PrefixExpression) String() string

func (*PrefixExpression) TokenLiteral

func (pe *PrefixExpression) TokenLiteral() string

type Program

type Program struct {
	Statements []Statement
}

func (*Program) String

func (p *Program) String() string

This will allow us to print AST nodes for debugging and to compare them with other AST nodes.

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

type ReturnStatement

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

func (*ReturnStatement) String

func (returnStatement *ReturnStatement) String() string

func (*ReturnStatement) TokenLiteral

func (rs *ReturnStatement) TokenLiteral() string

type SkipStatement added in v0.0.3

type SkipStatement struct {
	Token token.Token // the 'skip' token
}

func (*SkipStatement) String added in v0.0.3

func (ls *SkipStatement) String() string

func (*SkipStatement) TokenLiteral added in v0.0.3

func (ls *SkipStatement) 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 (stringLiteral *StringLiteral) String() string

func (*StringLiteral) TokenLiteral

func (stringLiteral *StringLiteral) TokenLiteral() string

type VariableStatement

type VariableStatement struct {
	Token token.Token // token.LET or token.CONST
	Type  string      // "let" or "const"
	Name  *Identifier
	Value Expression
}

Jump to

Keyboard shortcuts

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