monkey-lang: github.com/prologic/monkey-lang/ast Index | Files

package ast

import "github.com/prologic/monkey-lang/ast"

Index

Package Files

ast.go

type ArrayLiteral Uses

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

ArrayLiteral represents the array literal and holds a list of expressions

func (*ArrayLiteral) String Uses

func (al *ArrayLiteral) String() string

String returns a stringified version of the AST for debugging

func (*ArrayLiteral) TokenLiteral Uses

func (al *ArrayLiteral) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type AssignmentExpression Uses

type AssignmentExpression struct {
    Token token.Token // The = token
    Left  Expression
    Value Expression
}

AssignmentExpression represents an assignment expression of the form: x = 1 or xs[1] = 2

func (*AssignmentExpression) String Uses

func (ae *AssignmentExpression) String() string

String returns a stringified version of the AST for debugging

func (*AssignmentExpression) TokenLiteral Uses

func (ae *AssignmentExpression) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type BindExpression Uses

type BindExpression struct {
    Token token.Token // The := token
    Left  Expression
    Value Expression
}

BindExpression represents a binding expression of the form: x := 1

func (*BindExpression) String Uses

func (be *BindExpression) String() string

String returns a stringified version of the AST for debugging

func (*BindExpression) TokenLiteral Uses

func (be *BindExpression) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type BlockStatement Uses

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

BlockStatement represents a block statement and holds one or more other statements

func (*BlockStatement) String Uses

func (bs *BlockStatement) String() string

String returns a stringified version of the AST for debugging

func (*BlockStatement) TokenLiteral Uses

func (bs *BlockStatement) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type Boolean Uses

type Boolean struct {
    Token token.Token
    Value bool
}

Boolean represents a boolean value and holds the underlying boolean value

func (*Boolean) String Uses

func (b *Boolean) String() string

String returns a stringified version of the AST for debugging

func (*Boolean) TokenLiteral Uses

func (b *Boolean) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type CallExpression Uses

type CallExpression struct {
    Token     token.Token // The '(' token
    Function  Expression  // Identifier or FunctionLiteral
    Arguments []Expression
}

CallExpression represents a call expression and holds the function to be called as well as the arguments to be passed to that function

func (*CallExpression) String Uses

func (ce *CallExpression) String() string

String returns a stringified version of the AST for debugging

func (*CallExpression) TokenLiteral Uses

func (ce *CallExpression) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type Comment Uses

type Comment struct {
    Token token.Token // the token.COMMENT token
    Value string
}

Comment a comment

func (*Comment) String Uses

func (c *Comment) String() string

String returns a stringified version of the AST for debugging

func (*Comment) TokenLiteral Uses

func (c *Comment) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type Expression Uses

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

Expression defines the interface for all expression nodes.

type ExpressionStatement Uses

type ExpressionStatement struct {
    Token      token.Token // the first token of the expression
    Expression Expression
}

ExpressionStatement represents an expression statement and holds an expression

func (*ExpressionStatement) String Uses

func (es *ExpressionStatement) String() string

String returns a stringified version of the AST for debugging

func (*ExpressionStatement) TokenLiteral Uses

func (es *ExpressionStatement) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type FunctionLiteral Uses

type FunctionLiteral struct {
    Token      token.Token // The 'fn' token
    Name       string
    Parameters []*Identifier
    Body       *BlockStatement
}

FunctionLiteral represents a literal functions and holds the function's formal parameters and boy of the function as a block statement

func (*FunctionLiteral) String Uses

func (fl *FunctionLiteral) String() string

String returns a stringified version of the AST for debugging

func (*FunctionLiteral) TokenLiteral Uses

func (fl *FunctionLiteral) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type HashLiteral Uses

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

HashLiteral represents a hash map or dictionary literal, a set of key/value pairs.

func (*HashLiteral) String Uses

func (hl *HashLiteral) String() string

String returns a stringified version of the AST for debugging

func (*HashLiteral) TokenLiteral Uses

func (hl *HashLiteral) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type Identifier Uses

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

Identifier represents an identiifer and holds the name of the identifier

func (*Identifier) String Uses

func (i *Identifier) String() string

String returns a stringified version of the AST for debugging

func (*Identifier) TokenLiteral Uses

func (i *Identifier) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type IfExpression Uses

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

IfExpression represents an `if` expression and holds the condition, consequence and alternative expressions

func (*IfExpression) String Uses

func (ie *IfExpression) String() string

String returns a stringified version of the AST for debugging

func (*IfExpression) TokenLiteral Uses

func (ie *IfExpression) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type ImportExpression Uses

type ImportExpression struct {
    Token token.Token // The 'import' token
    Name  Expression
}

ImportExpression represents an `import` expression and holds the name of the module being imported.

func (*ImportExpression) String Uses

func (ie *ImportExpression) String() string

String returns a stringified version of the AST for debugging

func (*ImportExpression) TokenLiteral Uses

func (ie *ImportExpression) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type IndexExpression Uses

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

IndexExpression represents an index operator expression, e.g: xs[2] and holds the left expression and index expression

func (*IndexExpression) String Uses

func (ie *IndexExpression) String() string

String returns a stringified version of the AST for debugging

func (*IndexExpression) TokenLiteral Uses

func (ie *IndexExpression) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type InfixExpression Uses

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

InfixExpression represents an infix expression and holds the left-hand expression, operator and right-hand expression

func (*InfixExpression) String Uses

func (ie *InfixExpression) String() string

String returns a stringified version of the AST for debugging

func (*InfixExpression) TokenLiteral Uses

func (ie *InfixExpression) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type IntegerLiteral Uses

type IntegerLiteral struct {
    Token token.Token
    Value int64
}

IntegerLiteral represents a literal integare and holds an integer value

func (*IntegerLiteral) String Uses

func (il *IntegerLiteral) String() string

String returns a stringified version of the AST for debugging

func (*IntegerLiteral) TokenLiteral Uses

func (il *IntegerLiteral) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type Node Uses

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

Node defines an interface for all nodes in the AST.

type Null Uses

type Null struct {
    Token token.Token
}

Null represents a null value

func (*Null) String Uses

func (n *Null) String() string

String returns a stringified version of the AST for debugging

func (*Null) TokenLiteral Uses

func (n *Null) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type PrefixExpression Uses

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

PrefixExpression represents a prefix expression and holds the operator as well as the right-hand side expression

func (*PrefixExpression) String Uses

func (pe *PrefixExpression) String() string

String returns a stringified version of the AST for debugging

func (*PrefixExpression) TokenLiteral Uses

func (pe *PrefixExpression) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type Program Uses

type Program struct {
    Statements []Statement
}

Program is the root node. All programs consist of a slice of Statement(s)

func (*Program) String Uses

func (p *Program) String() string

String returns a stringified version of the AST for debugging

func (*Program) TokenLiteral Uses

func (p *Program) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type ReturnStatement Uses

type ReturnStatement struct {
    Token       token.Token // the 'return' token
    ReturnValue Expression
}

ReturnStatement represenets the `return` statement node

func (*ReturnStatement) String Uses

func (rs *ReturnStatement) String() string

String returns a stringified version of the AST for debugging

func (*ReturnStatement) TokenLiteral Uses

func (rs *ReturnStatement) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type Statement Uses

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

Statement defines the interface for all statement nodes.

type StringLiteral Uses

type StringLiteral struct {
    Token token.Token
    Value string
}

StringLiteral represents a literal string and holds a string value

func (*StringLiteral) String Uses

func (sl *StringLiteral) String() string

String returns a stringified version of the AST for debugging

func (*StringLiteral) TokenLiteral Uses

func (sl *StringLiteral) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

type WhileExpression Uses

type WhileExpression struct {
    Token       token.Token // The 'while' token
    Condition   Expression
    Consequence *BlockStatement
}

WhileExpression represents an `while` expression and holds the condition, and consequence expression

func (*WhileExpression) String Uses

func (we *WhileExpression) String() string

String returns a stringified version of the AST for debugging

func (*WhileExpression) TokenLiteral Uses

func (we *WhileExpression) TokenLiteral() string

TokenLiteral prints the literal value of the token associated with this node

Package ast imports 4 packages (graph) and is imported by 4 packages. Updated 2019-04-05. Refresh now. Tools for package owners.