ast

package
v0.0.0-...-9834360 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(root Node, child Node) bool

Contains reports whether root contains child or not. It matches child via pointer equality.

func Equal

func Equal(a, b Node) bool

Equal returns true if the nodes are identical in content, false otherwise

func Fprint

func Fprint(w io.Writer, x interface{}, f FieldFilter) error

Fprint prints the (sub-)tree starting at AST node x to w.

A non-nil FieldFilter f may be provided to control the output: struct fields for which f(fieldname, fieldvalue) is true are printed; all others are filtered from the output. Unexported struct fields are never printed.

func Inspect

func Inspect(node Node, f func(Node) bool)

Inspect traverses an AST in depth-first order: It starts by calling f(node); node must not be nil. If f returns true, Inspect invokes f recursively for each of the non-nil children of node, followed by a call of f(nil).

func IsLiteral

func IsLiteral(n Node) bool

IsLiteral returns true if n is a literal node, false otherwise

func NotNilFilter

func NotNilFilter(_ string, v reflect.Value) bool

NotNilFilter returns true for field values that are not nil; it returns false otherwise.

func Path

func Path(root, child Node) (*list.List, bool)

Path returns the path from the root of the AST till the child as a doubly linked list. If child is not found within root, the bool will be false and the list nil.

func Print

func Print(x interface{}) error

Print prints x to standard output, skipping nil fields. Print(x) is the same as Fprint(os.Stdout, x, NotNilFilter).

func Walk

func Walk(v Visitor, node Node)

Walk traverses an AST in depth-first order: It starts by calling v.Visit(node); node must not be nil. If the visitor w returned by v.Visit(node) is not nil, Walk is invoked recursively with visitor w for each of the non-nil children of node, followed by a call of w.Visit(nil).

func WalkEmit

func WalkEmit(root Node) <-chan Node

WalkEmit traverses node in depth-first order and emits each visited node into the channel

Types

type ArrayLiteral

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

ArrayLiteral represents an Array literal within the AST

func (*ArrayLiteral) End

func (al *ArrayLiteral) End() int

End returns the position of first character immediately after the node

func (*ArrayLiteral) Pos

func (al *ArrayLiteral) Pos() int

Pos returns the position of first character belonging to the node

func (*ArrayLiteral) String

func (al *ArrayLiteral) String() string

func (*ArrayLiteral) TokenLiteral

func (al *ArrayLiteral) TokenLiteral() string

TokenLiteral returns the literal of the token token.LBRACKET

type Assignment

type Assignment struct {
	Token token.Token
	Left  Expression
	Right Expression
}

Assignment represents a generic assignment

func (*Assignment) End

func (a *Assignment) End() int

End returns the position of first character immediately after the node

func (*Assignment) Pos

func (a *Assignment) Pos() int

Pos returns the position of first character belonging to the node

func (*Assignment) String

func (a *Assignment) String() string

func (*Assignment) TokenLiteral

func (a *Assignment) TokenLiteral() string

TokenLiteral returns the literal of the ASSIGN token

type BlockCapture

type BlockCapture struct {
	Token token.Token // the `&`
	Name  *Identifier
}

A BlockCapture represents a function scoped variable capturing a block

func (*BlockCapture) End

func (b *BlockCapture) End() int

End returns the position of the last character of Name

func (*BlockCapture) Pos

func (b *BlockCapture) Pos() int

Pos returns the position of the ampersand

func (*BlockCapture) String

func (b *BlockCapture) String() string

func (*BlockCapture) TokenLiteral

func (b *BlockCapture) TokenLiteral() string

TokenLiteral returns the literal of the token

type BlockExpression

type BlockExpression struct {
	Token      token.Token          // token.DO or token.LBRACE
	EndToken   token.Token          // token.END or token.RBRACE
	Parameters []*FunctionParameter // the block parameters
	Body       *BlockStatement      // the block body
}

A BlockExpression represents a Ruby block

func (*BlockExpression) End

func (b *BlockExpression) End() int

End returns the position of the end token

func (*BlockExpression) Pos

func (b *BlockExpression) Pos() int

Pos returns the position of first character belonging to the node

func (*BlockExpression) String

func (b *BlockExpression) String() string

String returns a string representation of the block statement

func (*BlockExpression) TokenLiteral

func (b *BlockExpression) TokenLiteral() string

TokenLiteral returns the literal from the Token

type BlockStatement

type BlockStatement struct {
	// the { token or the first token from the first statement
	Token      token.Token
	EndToken   token.Token // the } token
	Statements []Statement
}

BlockStatement represents a list of statements

func (*BlockStatement) End

func (bs *BlockStatement) End() int

End returns the position of first character immediately after the node

func (*BlockStatement) Pos

func (bs *BlockStatement) Pos() int

Pos returns the position of first character belonging to the node

func (*BlockStatement) String

func (bs *BlockStatement) String() string

func (*BlockStatement) TokenLiteral

func (bs *BlockStatement) TokenLiteral() string

TokenLiteral returns '{' or the first token from the first statement

type Boolean

type Boolean struct {
	Token token.Token
	Value bool
}

Boolean represents a boolean in the AST

func (*Boolean) End

func (b *Boolean) End() int

End returns the position of first character immediately after the node

func (*Boolean) Pos

func (b *Boolean) Pos() int

Pos returns the position of first character belonging to the node

func (*Boolean) String

func (b *Boolean) String() string

func (*Boolean) TokenLiteral

func (b *Boolean) TokenLiteral() string

TokenLiteral returns the literal from the token token.BOOLEAN

type ClassExpression

type ClassExpression struct {
	Token      token.Token // The class keyword
	EndToken   token.Token // The end token
	Name       *Identifier // The class name, will always be a const
	SuperClass *Identifier // The superclass, if any
	Body       *BlockStatement
}

ClassExpression represents a module definition

func (*ClassExpression) End

func (m *ClassExpression) End() int

End returns the position of the `end` token

func (*ClassExpression) Pos

func (m *ClassExpression) Pos() int

Pos returns the position of first character belonging to the node

func (*ClassExpression) String

func (m *ClassExpression) String() string

func (*ClassExpression) TokenLiteral

func (m *ClassExpression) TokenLiteral() string

TokenLiteral returns the literal from token.CLASS

type Comment

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

Comment represents a double quoted string in the AST

func (*Comment) End

func (c *Comment) End() int

End returns the position of first character immediately after the node

func (*Comment) Pos

func (c *Comment) Pos() int

Pos returns the position of first character belonging to the node

func (*Comment) String

func (c *Comment) String() string

func (*Comment) TokenLiteral

func (c *Comment) TokenLiteral() string

TokenLiteral returns the literal from token token.STRING

type ConditionalExpression

type ConditionalExpression struct {
	Token       token.Token // The 'if' or 'unless' token
	EndToken    token.Token // The 'end' token
	Condition   Expression
	Consequence *BlockStatement
	Alternative *BlockStatement
}

ConditionalExpression represents an if expression within the AST

func (*ConditionalExpression) End

func (ce *ConditionalExpression) End() int

End returns the position of first character immediately after the node

func (*ConditionalExpression) IsNegated

func (ce *ConditionalExpression) IsNegated() bool

IsNegated indicates if the condition uses unless, i.e. is negated

func (*ConditionalExpression) Pos

func (ce *ConditionalExpression) Pos() int

Pos returns the position of first character belonging to the node

func (*ConditionalExpression) String

func (ce *ConditionalExpression) String() string

func (*ConditionalExpression) TokenLiteral

func (ce *ConditionalExpression) TokenLiteral() string

TokenLiteral returns the literal from token token.IF or token.UNLESS

type ContextCallExpression

type ContextCallExpression struct {
	Token     token.Token      // The '.' token
	Context   Expression       // The lefthandside expression
	Function  *Identifier      // The function to call
	Arguments []Expression     // The function arguments
	Block     *BlockExpression // The function block
}

A ContextCallExpression represents a method call on a given Context

func (*ContextCallExpression) End

func (ce *ContextCallExpression) End() int

End returns the end position of the block if it exists. If not, it returns the end position of the last argument if any. Otherwise it returns the end of the function identifier

func (*ContextCallExpression) Pos

func (ce *ContextCallExpression) Pos() int

Pos returns the position of first character belonging to the node

func (*ContextCallExpression) String

func (ce *ContextCallExpression) String() string

func (*ContextCallExpression) TokenLiteral

func (ce *ContextCallExpression) TokenLiteral() string

TokenLiteral returns the literal from token.DOT

type ExceptionHandlingBlock

type ExceptionHandlingBlock struct {
	BeginToken token.Token
	EndToken   token.Token
	TryBody    *BlockStatement
	Rescues    []*RescueBlock
}

ExceptionHandlingBlock represents a begin/end block where exceptions are rescued

func (*ExceptionHandlingBlock) End

func (eh *ExceptionHandlingBlock) End() int

End returns the position of first character immediately after the node

func (*ExceptionHandlingBlock) Pos

func (eh *ExceptionHandlingBlock) Pos() int

Pos returns the position of first character belonging to the node

func (*ExceptionHandlingBlock) String

func (eh *ExceptionHandlingBlock) String() string

func (*ExceptionHandlingBlock) TokenLiteral

func (eh *ExceptionHandlingBlock) TokenLiteral() string

TokenLiteral returns the token literal from 'begin'

type Expression

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

An Expression represents an expression within the AST

All expression nodes implement the Expression interface.

type ExpressionList

type ExpressionList []Expression

ExpressionList represents a list of expressions within the AST divided by commas

func (ExpressionList) End

func (el ExpressionList) End() int

End returns End of the last element

func (ExpressionList) Pos

func (el ExpressionList) Pos() int

Pos returns the position of first character from the first expression

func (ExpressionList) String

func (el ExpressionList) String() string

func (ExpressionList) TokenLiteral

func (el ExpressionList) TokenLiteral() string

TokenLiteral returns the literal of the first element

type ExpressionStatement

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

An ExpressionStatement is a Statement wrapping an Expression

func (*ExpressionStatement) End

func (es *ExpressionStatement) End() int

End returns the position of first character immediately after the node

func (*ExpressionStatement) Pos

func (es *ExpressionStatement) Pos() int

Pos returns the position of first character belonging to the node

func (*ExpressionStatement) String

func (es *ExpressionStatement) String() string

func (*ExpressionStatement) TokenLiteral

func (es *ExpressionStatement) TokenLiteral() string

TokenLiteral returns the first token of the Expression

type FieldFilter

type FieldFilter func(name string, value reflect.Value) bool

A FieldFilter may be provided to Fprint to control the output.

type FunctionLiteral

type FunctionLiteral struct {
	Token         token.Token // The 'def' token
	EndToken      token.Token // the 'end' token
	Receiver      *Identifier
	Name          *Identifier
	Parameters    []*FunctionParameter
	CapturedBlock *BlockCapture
	Body          *BlockStatement
	Rescues       []*RescueBlock
}

A FunctionLiteral represents a function definition in the AST

func (*FunctionLiteral) End

func (fl *FunctionLiteral) End() int

End returns the position of the `end` keyword

func (*FunctionLiteral) Pos

func (fl *FunctionLiteral) Pos() int

Pos returns the position of the `def` keyword

func (*FunctionLiteral) String

func (fl *FunctionLiteral) String() string

func (*FunctionLiteral) TokenLiteral

func (fl *FunctionLiteral) TokenLiteral() string

TokenLiteral returns the literal from token.DEF

type FunctionParameter

type FunctionParameter struct {
	Name    *Identifier
	Default Expression
}

A FunctionParameter represents a parameter in a function literal

func (*FunctionParameter) End

func (f *FunctionParameter) End() int

End returns the position of the default end if it exists, otherwise the end position of Name

func (*FunctionParameter) Pos

func (f *FunctionParameter) Pos() int

Pos returns the position of first character belonging to the node

func (*FunctionParameter) String

func (f *FunctionParameter) String() string

func (*FunctionParameter) TokenLiteral

func (f *FunctionParameter) TokenLiteral() string

TokenLiteral returns the token of the parameter name

type Global

type Global struct {
	Token token.Token // the token.GLOBAL token
	Value string
}

Global represents a global in the AST

func (*Global) End

func (g *Global) End() int

End returns the position of first character immediately after the node

func (*Global) Pos

func (g *Global) Pos() int

Pos returns the position of first character belonging to the node

func (*Global) String

func (g *Global) String() string

func (*Global) TokenLiteral

func (g *Global) TokenLiteral() string

TokenLiteral returns the literal of the token.GLOBAL token

type HashLiteral

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

HashLiteral represents an Hash literal within the AST

func (*HashLiteral) End

func (hl *HashLiteral) End() int

End returns the position of the right brace

func (*HashLiteral) Pos

func (hl *HashLiteral) Pos() int

Pos returns the position of the left brace

func (*HashLiteral) String

func (hl *HashLiteral) String() string

func (*HashLiteral) TokenLiteral

func (hl *HashLiteral) TokenLiteral() string

TokenLiteral returns the literal of the token token.LBRACE

type Identifier

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

An Identifier represents an identifier in the program

func (*Identifier) End

func (i *Identifier) End() int

End returns the position of first character immediately after the node

func (*Identifier) IsConstant

func (i *Identifier) IsConstant() bool

IsConstant returns true if the Identifier represents a Constant, false otherwise

func (*Identifier) Pos

func (i *Identifier) Pos() int

Pos returns the position of first character belonging to the node

func (*Identifier) String

func (i *Identifier) String() string

func (*Identifier) TokenLiteral

func (i *Identifier) TokenLiteral() string

TokenLiteral returns the literal of the token.IDENT token

type IndexExpression

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

An IndexExpression represents an array or hash access in the AST

func (*IndexExpression) End

func (ie *IndexExpression) End() int

End returns the position of the last character belonging to the node

func (*IndexExpression) Pos

func (ie *IndexExpression) Pos() int

Pos returns the position of first character belonging to the node

func (*IndexExpression) String

func (ie *IndexExpression) String() string

func (*IndexExpression) TokenLiteral

func (ie *IndexExpression) TokenLiteral() string

TokenLiteral returns the literal from token.LBRACKET

type InfixExpression

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

An InfixExpression represents an infix operator in the AST

func (*InfixExpression) End

func (oe *InfixExpression) End() int

End returns the position of last character belonging to the right node

func (*InfixExpression) IsControlExpression

func (oe *InfixExpression) IsControlExpression() bool

IsControlExpression returns true if the infix is used for control flow, false otherwise

func (*InfixExpression) MustEvaluateRight

func (oe *InfixExpression) MustEvaluateRight() bool

MustEvaluateRight returns true if it is mandatory to evaluate the right side of the operator, false otherwise

func (*InfixExpression) Pos

func (oe *InfixExpression) Pos() int

Pos returns the position of first character belonging to the left node

func (*InfixExpression) String

func (oe *InfixExpression) String() string

func (*InfixExpression) TokenLiteral

func (oe *InfixExpression) TokenLiteral() string

TokenLiteral returns the literal from the infix operator token

type InstanceVariable

type InstanceVariable struct {
	Token token.Token
	Name  *Identifier
}

An InstanceVariable represents an instance variable in the AST

func (*InstanceVariable) End

func (i *InstanceVariable) End() int

End returns the position of first character immediately after the node

func (*InstanceVariable) Pos

func (i *InstanceVariable) Pos() int

Pos returns the position of first character belonging to the node

func (*InstanceVariable) String

func (i *InstanceVariable) String() string

func (*InstanceVariable) TokenLiteral

func (i *InstanceVariable) TokenLiteral() string

TokenLiteral returns the literal of the AT token

type IntegerLiteral

type IntegerLiteral struct {
	Token token.Token
	Value int64
}

IntegerLiteral represents an integer in the AST

func (*IntegerLiteral) End

func (il *IntegerLiteral) End() int

End returns the position of first character immediately after the node

func (*IntegerLiteral) Pos

func (il *IntegerLiteral) Pos() int

Pos returns the position of first character belonging to the node

func (*IntegerLiteral) String

func (il *IntegerLiteral) String() string

func (*IntegerLiteral) TokenLiteral

func (il *IntegerLiteral) TokenLiteral() string

TokenLiteral returns the literal from the token.INT token

type Keyword__FILE__

type Keyword__FILE__ struct {
	Token    token.Token // the token.FILE__ token
	Filename string
}

Keyword__FILE__ represents __FILE__ in the AST

func (*Keyword__FILE__) End

func (f *Keyword__FILE__) End() int

End returns the position of first character immediately after the node

func (*Keyword__FILE__) Pos

func (f *Keyword__FILE__) Pos() int

Pos returns the position of first character belonging to the node

func (*Keyword__FILE__) String

func (f *Keyword__FILE__) String() string

func (*Keyword__FILE__) TokenLiteral

func (f *Keyword__FILE__) TokenLiteral() string

TokenLiteral returns the literal of the token.FILE__ token

type LoopExpression

type LoopExpression struct {
	Token     token.Token // while
	EndToken  token.Token // end
	Condition Expression
	Block     *BlockStatement
}

A LoopExpression represents a loop

func (*LoopExpression) End

func (ce *LoopExpression) End() int

End returns the position of first character immediately after the node

func (*LoopExpression) Pos

func (ce *LoopExpression) Pos() int

Pos returns the position of first character belonging to the node

func (*LoopExpression) String

func (ce *LoopExpression) String() string

func (*LoopExpression) TokenLiteral

func (ce *LoopExpression) TokenLiteral() string

TokenLiteral returns the literal from token token.WHILE

type ModuleExpression

type ModuleExpression struct {
	Token    token.Token // The module keyword
	EndToken token.Token // The end token
	Name     *Identifier // The module name, will always be a const
	Body     *BlockStatement
}

ModuleExpression represents a module definition

func (*ModuleExpression) End

func (m *ModuleExpression) End() int

End returns the position of the `end` token

func (*ModuleExpression) Pos

func (m *ModuleExpression) Pos() int

Pos returns the position of first character belonging to the node

func (*ModuleExpression) String

func (m *ModuleExpression) String() string

func (*ModuleExpression) TokenLiteral

func (m *ModuleExpression) TokenLiteral() string

TokenLiteral returns the literal from token.MODULE

type MultiAssignment

type MultiAssignment struct {
	Variables []*Identifier
	Values    []Expression
}

MultiAssignment represents multiple variables on the lefthand side

func (*MultiAssignment) End

func (m *MultiAssignment) End() int

End returns the position of first character immediately after the node

func (*MultiAssignment) Pos

func (m *MultiAssignment) Pos() int

Pos returns the position of first character belonging to the node

func (*MultiAssignment) String

func (m *MultiAssignment) String() string

func (*MultiAssignment) TokenLiteral

func (m *MultiAssignment) TokenLiteral() string

TokenLiteral returns the literal of the first variable token

type Nil

type Nil struct {
	Token token.Token
}

Nil represents the 'nil' keyword

func (*Nil) End

func (n *Nil) End() int

End returns the position of first character immediately after the node

func (*Nil) Pos

func (n *Nil) Pos() int

Pos returns the position of first character belonging to the node

func (*Nil) String

func (n *Nil) String() string

func (*Nil) TokenLiteral

func (n *Nil) TokenLiteral() string

TokenLiteral returns the literal from the token token.NIL

type Node

type Node interface {
	// Pos returns the position of first character belonging to the node
	Pos() int
	// End returns the position of first character immediately after the node
	End() int
	// TokenLiteral returns the literal of the node
	TokenLiteral() string
	// String returns a string representation of the node
	String() string
}

Node represents a node within the AST

All node types implement the Node interface.

func Parent

func Parent(root, child Node) (Node, bool)

Parent returns the parent node of child. If child is not found within root, or child does not have a parent, i.e. equals root, the bool will be false

type PrefixExpression

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

PrefixExpression represents a prefix operator

func (*PrefixExpression) End

func (pe *PrefixExpression) End() int

End returns the end of the right expression

func (*PrefixExpression) Pos

func (pe *PrefixExpression) Pos() int

Pos returns the position of first character belonging to the node

func (*PrefixExpression) String

func (pe *PrefixExpression) String() string

func (*PrefixExpression) TokenLiteral

func (pe *PrefixExpression) TokenLiteral() string

TokenLiteral returns the literal from the prefix operator token

type Program

type Program struct {
	File       *gotoken.File
	Statements []Statement
	// contains filtered or unexported fields
}

A Program node is the root node within the AST.

func (*Program) End

func (p *Program) End() int

End returns the position of first character immediately after the node

func (*Program) Pos

func (p *Program) Pos() int

Pos returns the position of first character belonging to the node

func (*Program) String

func (p *Program) String() string

func (*Program) TokenLiteral

func (p *Program) TokenLiteral() string

TokenLiteral returns the literal of the first statement and empty string if there is no statement.

type RescueBlock

type RescueBlock struct {
	Token            token.Token
	ExceptionClasses []*Identifier
	Exception        *Identifier
	Body             *BlockStatement
}

A RescueBlock represents a rescue block

func (*RescueBlock) End

func (rb *RescueBlock) End() int

End returns the position of first character immediately after the node

func (*RescueBlock) Pos

func (rb *RescueBlock) Pos() int

Pos returns the position of first character belonging to the node

func (*RescueBlock) String

func (rb *RescueBlock) String() string

func (*RescueBlock) TokenLiteral

func (rb *RescueBlock) TokenLiteral() string

TokenLiteral returns the token literal from 'rescue'

type ReturnStatement

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

A ReturnStatement represents a return node which yields another Expression.

func (*ReturnStatement) End

func (rs *ReturnStatement) End() int

End returns the position of first character immediately after the node

func (*ReturnStatement) Pos

func (rs *ReturnStatement) Pos() int

Pos returns the position of first character belonging to the node

func (*ReturnStatement) String

func (rs *ReturnStatement) String() string

func (*ReturnStatement) TokenLiteral

func (rs *ReturnStatement) TokenLiteral() string

TokenLiteral returns the 'return' token literal

type ScopedIdentifier

type ScopedIdentifier struct {
	Token token.Token // the token.SCOPE
	Outer *Identifier
	Inner Expression
}

ScopedIdentifier represents a scoped Constant declaration

func (*ScopedIdentifier) End

func (i *ScopedIdentifier) End() int

End returns the position of first character immediately after the node

func (*ScopedIdentifier) Pos

func (i *ScopedIdentifier) Pos() int

Pos returns the position of first character belonging to the node

func (*ScopedIdentifier) String

func (i *ScopedIdentifier) String() string

func (*ScopedIdentifier) TokenLiteral

func (i *ScopedIdentifier) TokenLiteral() string

TokenLiteral returns the literal of the token.SCOPE token

type Self

type Self struct {
	Token token.Token // the token.SELF token
}

Self represents self in the current context in the program

func (*Self) End

func (s *Self) End() int

End returns the position of first character immediately after the node

func (*Self) Pos

func (s *Self) Pos() int

Pos returns the position of first character belonging to the node

func (*Self) String

func (s *Self) String() string

func (*Self) TokenLiteral

func (s *Self) TokenLiteral() string

TokenLiteral returns the literal of the token.SELF token

type Statement

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

A Statement represents a statement within the AST

All statement nodes implement the Statement interface.

type StringLiteral

type StringLiteral struct {
	Token token.Token // the '"'
	Value string
}

StringLiteral represents a double quoted string in the AST

func (*StringLiteral) End

func (sl *StringLiteral) End() int

End returns the position of first character immediately after the node

func (*StringLiteral) Pos

func (sl *StringLiteral) Pos() int

Pos returns the position of first character belonging to the node

func (*StringLiteral) String

func (sl *StringLiteral) String() string

func (*StringLiteral) TokenLiteral

func (sl *StringLiteral) TokenLiteral() string

TokenLiteral returns the literal from token token.STRING

type SymbolLiteral

type SymbolLiteral struct {
	Token token.Token // the ':'
	Value Expression
}

SymbolLiteral represents a symbol within the AST

func (*SymbolLiteral) End

func (s *SymbolLiteral) End() int

End returns the position of first character immediately after the node

func (*SymbolLiteral) Pos

func (s *SymbolLiteral) Pos() int

Pos returns the position of first character belonging to the node

func (*SymbolLiteral) String

func (s *SymbolLiteral) String() string

func (*SymbolLiteral) TokenLiteral

func (s *SymbolLiteral) TokenLiteral() string

TokenLiteral returns the literal from token token.SYMBOL

type Visitor

type Visitor interface {
	Visit(node Node) (w Visitor)
}

A Visitor's Visit method is invoked for each node encountered by Walk. If the result visitor w is not nil, Walk visits each of the children of node with the visitor w, followed by a call of w.Visit(nil).

type VisitorFunc

type VisitorFunc func(Node) Visitor

The VisitorFunc type is an adapter to allow the use of ordinary functions as AST Visitors. If f is a function with the appropriate signature, VisitorFunc(f) is a Visitor that calls f.

func (VisitorFunc) Visit

func (f VisitorFunc) Visit(n Node) Visitor

Visit calls f(n)

type YieldExpression

type YieldExpression struct {
	Token     token.Token  // the token.YIELD token
	Arguments []Expression // The arguments to yield
}

YieldExpression represents self in the current context in the program

func (*YieldExpression) End

func (y *YieldExpression) End() int

End returns the position of first character immediately after the node

func (*YieldExpression) Pos

func (y *YieldExpression) Pos() int

Pos returns the position of first character belonging to the node

func (*YieldExpression) String

func (y *YieldExpression) String() string

func (*YieldExpression) TokenLiteral

func (y *YieldExpression) TokenLiteral() string

TokenLiteral returns the literal of the token.YIELD token

Jump to

Keyboard shortcuts

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