ast

package
v0.0.0-...-e334538 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tree

func Tree(node Node, indent int, name string) string

Tree returns a tree representation of a node

Types

type Block

type Block struct {
	Value []Statement
	// contains filtered or unexported fields
}

A Block combines multiple statements into an expression.

func (Block) Expr

func (e Block) Expr()

type Boolean

type Boolean struct {
	Value bool
	// contains filtered or unexported fields
}

A Boolean represents a boolean literal.

func (Boolean) Expr

func (e Boolean) Expr()

type Break

type Break struct {
	// contains filtered or unexported fields
}

A Break statement exits out of a loop.

func (Break) Stmt

func (s Break) Stmt()

type Call

type Call struct {
	Function, Argument Expression
	// contains filtered or unexported fields
}

A Call calls a function with the argument. If the argument is a tuple, each element of the tuple is passed as a separate argument.

func (Call) Expr

func (e Call) Expr()

type Export

type Export struct {
	Names Expression
	// contains filtered or unexported fields
}

An Export statement exposes variable(s) to the enclosing scope.

func (Export) Stmt

func (s Export) Stmt()

type Expression

type Expression interface {
	Node
	Expr()
}

An Expression is a node which evaluates to a value, for example a number literal.

type ExpressionStatement

type ExpressionStatement struct {
	Expr Expression
	// contains filtered or unexported fields
}

An ExpressionStatement is an expression which can take the place of a statement.

func (ExpressionStatement) Stmt

func (s ExpressionStatement) Stmt()

type For

type For struct {
	Var, Collection, Body Expression
	// contains filtered or unexported fields
}

A For loop executes Body for each Var in Collection.

func (For) Stmt

func (s For) Stmt()

type Identifier

type Identifier struct {
	Value string
	// contains filtered or unexported fields
}

An Identifier represents a name in the variable store; evaluates to the value of that variable.

func (Identifier) Expr

func (e Identifier) Expr()

type If

type If struct {
	Condition, Consequence, Alternative Expression
	// contains filtered or unexported fields
}

An If expression executes Consequence or Alternative based on Condition.

func (If) Expr

func (e If) Expr()

type Import

type Import struct {
	Path string
	// contains filtered or unexported fields
}

An Import statement imports the file or directory specified into the scope.

func (Import) Stmt

func (s Import) Stmt()

type Infix

type Infix struct {
	Operator    string
	Left, Right Expression
	// contains filtered or unexported fields
}

An Infix is an infix operator expression, such as 1 + 2

func (Infix) Expr

func (e Infix) Expr()

type List

type List struct {
	Value []Expression
	// contains filtered or unexported fields
}

A List is a linked list of items.

func (List) Expr

func (e List) Expr()

type Map

type Map struct {
	Value map[Expression]Expression
	// contains filtered or unexported fields
}

A Map is a hashmap.

func (Map) Expr

func (e Map) Expr()

type Match

type Match struct {
	Input    Expression
	Branches []MatchBranch
	// contains filtered or unexported fields
}

A Match executes a different piece of code based on the input value.

func (Match) Expr

func (e Match) Expr()

type MatchBranch

type MatchBranch struct {
	Condition, Body Expression
}

A MatchBranch is a condition -> body branch for use in a Match expression. Notice a MatchBranch isn't an Expression itself.

type Model

type Model struct {
	Parameters, Parent Expression
	// contains filtered or unexported fields
}

A Model expression defines a new model. Parent is another model, since the syntax is `model dog (name) : animal (name, "dog")`.

func (Model) Expr

func (e Model) Expr()

type Next

type Next struct {
	// contains filtered or unexported fields
}

A Next statement jumps to the next iteration of a loop.

func (Next) Stmt

func (s Next) Stmt()

type Nil

type Nil struct {
	// contains filtered or unexported fields
}

Nil is the nil literal; the absence of a value.

func (Nil) Expr

func (e Nil) Expr()

type Node

type Node interface{}

A Node is the interface from which all AST nodes implement.

type Number

type Number struct {
	Value float64
	// contains filtered or unexported fields
}

A Number represents a number literal.

func (Number) Expr

func (e Number) Expr()

type Prefix

type Prefix struct {
	Operator string
	Right    Expression
	// contains filtered or unexported fields
}

A Prefix is a prefix operator expression, such as -5.

func (Prefix) Expr

func (e Prefix) Expr()

type Program

type Program struct {
	Statements []Statement
}

A Program is a list of statements which, usually, represents an entire file.

func (*Program) Tree

func (p *Program) Tree() string

Tree returns a nicely formatted tree representation of the program.

type Return

type Return struct {
	Value Expression
	// contains filtered or unexported fields
}

A Return statement returns a value from a function.

func (Return) Stmt

func (s Return) Stmt()

type Statement

type Statement interface {
	Node
	Stmt()
}

A Statement is a node which doesn't evaluate to a value, for example a loop.

type String

type String struct {
	Value string
	// contains filtered or unexported fields
}

A String represents a unicode string literal.

func (String) Expr

func (e String) Expr()

type While

type While struct {
	Condition, Body Expression
	// contains filtered or unexported fields
}

A While loop executes Body while Condition is true.

func (While) Stmt

func (s While) Stmt()

Jump to

Keyboard shortcuts

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