ast

package
v1.24.8 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayLit

type ArrayLit struct {
	Elements []Expr
	LBrack   source.Pos
	RBrack   source.Pos
}

ArrayLit represents an array literal.

func (*ArrayLit) End

func (e *ArrayLit) End() source.Pos

End returns the position of first character immediately after the node.

func (*ArrayLit) Pos

func (e *ArrayLit) Pos() source.Pos

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

func (*ArrayLit) String

func (e *ArrayLit) String() string

type AssignStmt

type AssignStmt struct {
	LHS      []Expr
	RHS      []Expr
	Token    token.Token
	TokenPos source.Pos
}

AssignStmt represents an assignment statement.

func (*AssignStmt) End

func (s *AssignStmt) End() source.Pos

End returns the position of first character immediately after the node.

func (*AssignStmt) Pos

func (s *AssignStmt) Pos() source.Pos

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

func (*AssignStmt) String

func (s *AssignStmt) String() string

type BadExpr

type BadExpr struct {
	From source.Pos
	To   source.Pos
}

BadExpr represents a bad expression.

func (*BadExpr) End

func (e *BadExpr) End() source.Pos

End returns the position of first character immediately after the node.

func (*BadExpr) Pos

func (e *BadExpr) Pos() source.Pos

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

func (*BadExpr) String

func (e *BadExpr) String() string

type BadStmt

type BadStmt struct {
	From source.Pos
	To   source.Pos
}

BadStmt represents a bad statement.

func (*BadStmt) End

func (s *BadStmt) End() source.Pos

End returns the position of first character immediately after the node.

func (*BadStmt) Pos

func (s *BadStmt) Pos() source.Pos

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

func (*BadStmt) String

func (s *BadStmt) String() string

type BinaryExpr

type BinaryExpr struct {
	LHS      Expr
	RHS      Expr
	Token    token.Token
	TokenPos source.Pos
}

BinaryExpr represents a binary operator expression.

func (*BinaryExpr) End

func (e *BinaryExpr) End() source.Pos

End returns the position of first character immediately after the node.

func (*BinaryExpr) Pos

func (e *BinaryExpr) Pos() source.Pos

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

func (*BinaryExpr) String

func (e *BinaryExpr) String() string

type BlockStmt

type BlockStmt struct {
	Stmts  []Stmt
	LBrace source.Pos
	RBrace source.Pos
}

BlockStmt represents a block statement.

func (*BlockStmt) End

func (s *BlockStmt) End() source.Pos

End returns the position of first character immediately after the node.

func (*BlockStmt) Pos

func (s *BlockStmt) Pos() source.Pos

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

func (*BlockStmt) String

func (s *BlockStmt) String() string

type BoolLit

type BoolLit struct {
	Value    bool
	ValuePos source.Pos
	Literal  string
}

BoolLit represents a boolean literal.

func (*BoolLit) End

func (e *BoolLit) End() source.Pos

End returns the position of first character immediately after the node.

func (*BoolLit) Pos

func (e *BoolLit) Pos() source.Pos

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

func (*BoolLit) String

func (e *BoolLit) String() string

type BranchStmt

type BranchStmt struct {
	Token    token.Token
	TokenPos source.Pos
	Label    *Ident
}

BranchStmt represents a branch statement.

func (*BranchStmt) End

func (s *BranchStmt) End() source.Pos

End returns the position of first character immediately after the node.

func (*BranchStmt) Pos

func (s *BranchStmt) Pos() source.Pos

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

func (*BranchStmt) String

func (s *BranchStmt) String() string

type CallExpr

type CallExpr struct {
	Func   Expr
	LParen source.Pos
	Args   []Expr
	RParen source.Pos
}

CallExpr represents a function call expression.

func (*CallExpr) End

func (e *CallExpr) End() source.Pos

End returns the position of first character immediately after the node.

func (*CallExpr) Pos

func (e *CallExpr) Pos() source.Pos

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

func (*CallExpr) String

func (e *CallExpr) String() string

type CharLit

type CharLit struct {
	Value    rune
	ValuePos source.Pos
	Literal  string
}

CharLit represents a character literal.

func (*CharLit) End

func (e *CharLit) End() source.Pos

End returns the position of first character immediately after the node.

func (*CharLit) Pos

func (e *CharLit) Pos() source.Pos

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

func (*CharLit) String

func (e *CharLit) String() string

type CondExpr

type CondExpr struct {
	Cond        Expr
	True        Expr
	False       Expr
	QuestionPos source.Pos
	ColonPos    source.Pos
}

CondExpr represents a ternary conditional expression.

func (*CondExpr) End

func (e *CondExpr) End() source.Pos

End returns the position of first character immediately after the node.

func (*CondExpr) Pos

func (e *CondExpr) Pos() source.Pos

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

func (*CondExpr) String

func (e *CondExpr) String() string

type EmptyStmt

type EmptyStmt struct {
	Semicolon source.Pos
	Implicit  bool
}

EmptyStmt represents an empty statement.

func (*EmptyStmt) End

func (s *EmptyStmt) End() source.Pos

End returns the position of first character immediately after the node.

func (*EmptyStmt) Pos

func (s *EmptyStmt) Pos() source.Pos

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

func (*EmptyStmt) String

func (s *EmptyStmt) String() string

type ErrorExpr

type ErrorExpr struct {
	Expr     Expr
	ErrorPos source.Pos
	LParen   source.Pos
	RParen   source.Pos
}

ErrorExpr represents an error expression

func (*ErrorExpr) End

func (e *ErrorExpr) End() source.Pos

End returns the position of first character immediately after the node.

func (*ErrorExpr) Pos

func (e *ErrorExpr) Pos() source.Pos

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

func (*ErrorExpr) String

func (e *ErrorExpr) String() string

type ExportStmt added in v1.3.0

type ExportStmt struct {
	ExportPos source.Pos
	Result    Expr
}

ExportStmt represents an export statement.

func (*ExportStmt) End added in v1.3.0

func (s *ExportStmt) End() source.Pos

End returns the position of first character immediately after the node.

func (*ExportStmt) Pos added in v1.3.0

func (s *ExportStmt) Pos() source.Pos

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

func (*ExportStmt) String added in v1.3.0

func (s *ExportStmt) String() string

type Expr

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

Expr represents an expression node in the AST.

type ExprStmt

type ExprStmt struct {
	Expr Expr
}

ExprStmt represents an expression statement.

func (*ExprStmt) End

func (s *ExprStmt) End() source.Pos

End returns the position of first character immediately after the node.

func (*ExprStmt) Pos

func (s *ExprStmt) Pos() source.Pos

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

func (*ExprStmt) String

func (s *ExprStmt) String() string

type File

type File struct {
	InputFile *source.File
	Stmts     []Stmt
}

File represents a file unit.

func (*File) End

func (n *File) End() source.Pos

End returns the position of first character immediately after the node.

func (*File) Pos

func (n *File) Pos() source.Pos

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

func (*File) String

func (n *File) String() string

type FloatLit

type FloatLit struct {
	Value    float64
	ValuePos source.Pos
	Literal  string
}

FloatLit represents a floating point literal.

func (*FloatLit) End

func (e *FloatLit) End() source.Pos

End returns the position of first character immediately after the node.

func (*FloatLit) Pos

func (e *FloatLit) Pos() source.Pos

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

func (*FloatLit) String

func (e *FloatLit) String() string

type ForInStmt

type ForInStmt struct {
	ForPos   source.Pos
	Key      *Ident
	Value    *Ident
	Iterable Expr
	Body     *BlockStmt
}

ForInStmt represents a for-in statement.

func (*ForInStmt) End

func (s *ForInStmt) End() source.Pos

End returns the position of first character immediately after the node.

func (*ForInStmt) Pos

func (s *ForInStmt) Pos() source.Pos

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

func (*ForInStmt) String

func (s *ForInStmt) String() string

type ForStmt

type ForStmt struct {
	ForPos source.Pos
	Init   Stmt
	Cond   Expr
	Post   Stmt
	Body   *BlockStmt
}

ForStmt represents a for statement.

func (*ForStmt) End

func (s *ForStmt) End() source.Pos

End returns the position of first character immediately after the node.

func (*ForStmt) Pos

func (s *ForStmt) Pos() source.Pos

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

func (*ForStmt) String

func (s *ForStmt) String() string

type FuncLit

type FuncLit struct {
	Type *FuncType
	Body *BlockStmt
}

FuncLit represents a function literal.

func (*FuncLit) End

func (e *FuncLit) End() source.Pos

End returns the position of first character immediately after the node.

func (*FuncLit) Pos

func (e *FuncLit) Pos() source.Pos

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

func (*FuncLit) String

func (e *FuncLit) String() string

type FuncType

type FuncType struct {
	FuncPos source.Pos
	Params  *IdentList
}

FuncType represents a function type definition.

func (*FuncType) End

func (e *FuncType) End() source.Pos

End returns the position of first character immediately after the node.

func (*FuncType) Pos

func (e *FuncType) Pos() source.Pos

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

func (*FuncType) String

func (e *FuncType) String() string

type Ident

type Ident struct {
	Name    string
	NamePos source.Pos
}

Ident represents an identifier.

func (*Ident) End

func (e *Ident) End() source.Pos

End returns the position of first character immediately after the node.

func (*Ident) Pos

func (e *Ident) Pos() source.Pos

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

func (*Ident) String

func (e *Ident) String() string

type IdentList

type IdentList struct {
	LParen  source.Pos
	VarArgs bool
	List    []*Ident
	RParen  source.Pos
}

IdentList represents a list of identifiers.

func (*IdentList) End

func (n *IdentList) End() source.Pos

End returns the position of first character immediately after the node.

func (*IdentList) NumFields

func (n *IdentList) NumFields() int

NumFields returns the number of fields.

func (*IdentList) Pos

func (n *IdentList) Pos() source.Pos

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

func (*IdentList) String

func (n *IdentList) String() string

type IfStmt

type IfStmt struct {
	IfPos source.Pos
	Init  Stmt
	Cond  Expr
	Body  *BlockStmt
	Else  Stmt // else branch; or nil
}

IfStmt represents an if statement.

func (*IfStmt) End

func (s *IfStmt) End() source.Pos

End returns the position of first character immediately after the node.

func (*IfStmt) Pos

func (s *IfStmt) Pos() source.Pos

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

func (*IfStmt) String

func (s *IfStmt) String() string

type ImmutableExpr

type ImmutableExpr struct {
	Expr     Expr
	ErrorPos source.Pos
	LParen   source.Pos
	RParen   source.Pos
}

ImmutableExpr represents an immutable expression

func (*ImmutableExpr) End

func (e *ImmutableExpr) End() source.Pos

End returns the position of first character immediately after the node.

func (*ImmutableExpr) Pos

func (e *ImmutableExpr) Pos() source.Pos

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

func (*ImmutableExpr) String

func (e *ImmutableExpr) String() string

type ImportExpr

type ImportExpr struct {
	ModuleName string
	Token      token.Token
	TokenPos   source.Pos
}

ImportExpr represents an import expression

func (*ImportExpr) End

func (e *ImportExpr) End() source.Pos

End returns the position of first character immediately after the node.

func (*ImportExpr) Pos

func (e *ImportExpr) Pos() source.Pos

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

func (*ImportExpr) String

func (e *ImportExpr) String() string

type IncDecStmt

type IncDecStmt struct {
	Expr     Expr
	Token    token.Token
	TokenPos source.Pos
}

IncDecStmt represents increment or decrement statement.

func (*IncDecStmt) End

func (s *IncDecStmt) End() source.Pos

End returns the position of first character immediately after the node.

func (*IncDecStmt) Pos

func (s *IncDecStmt) Pos() source.Pos

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

func (*IncDecStmt) String

func (s *IncDecStmt) String() string

type IndexExpr

type IndexExpr struct {
	Expr   Expr
	LBrack source.Pos
	Index  Expr
	RBrack source.Pos
}

IndexExpr represents an index expression.

func (*IndexExpr) End

func (e *IndexExpr) End() source.Pos

End returns the position of first character immediately after the node.

func (*IndexExpr) Pos

func (e *IndexExpr) Pos() source.Pos

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

func (*IndexExpr) String

func (e *IndexExpr) String() string

type IntLit

type IntLit struct {
	Value    int64
	ValuePos source.Pos
	Literal  string
}

IntLit represents an integer literal.

func (*IntLit) End

func (e *IntLit) End() source.Pos

End returns the position of first character immediately after the node.

func (*IntLit) Pos

func (e *IntLit) Pos() source.Pos

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

func (*IntLit) String

func (e *IntLit) String() string

type MapElementLit

type MapElementLit struct {
	Key      string
	KeyPos   source.Pos
	ColonPos source.Pos
	Value    Expr
}

MapElementLit represents a map element.

func (*MapElementLit) End

func (e *MapElementLit) End() source.Pos

End returns the position of first character immediately after the node.

func (*MapElementLit) Pos

func (e *MapElementLit) Pos() source.Pos

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

func (*MapElementLit) String

func (e *MapElementLit) String() string

type MapLit

type MapLit struct {
	LBrace   source.Pos
	Elements []*MapElementLit
	RBrace   source.Pos
}

MapLit represents a map literal.

func (*MapLit) End

func (e *MapLit) End() source.Pos

End returns the position of first character immediately after the node.

func (*MapLit) Pos

func (e *MapLit) Pos() source.Pos

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

func (*MapLit) String

func (e *MapLit) String() string

type Node

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

Node represents a node in the AST.

type ParenExpr

type ParenExpr struct {
	Expr   Expr
	LParen source.Pos
	RParen source.Pos
}

ParenExpr represents a parenthesis wrapped expression.

func (*ParenExpr) End

func (e *ParenExpr) End() source.Pos

End returns the position of first character immediately after the node.

func (*ParenExpr) Pos

func (e *ParenExpr) Pos() source.Pos

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

func (*ParenExpr) String

func (e *ParenExpr) String() string

type ReturnStmt

type ReturnStmt struct {
	ReturnPos source.Pos
	Result    Expr
}

ReturnStmt represents a return statement.

func (*ReturnStmt) End

func (s *ReturnStmt) End() source.Pos

End returns the position of first character immediately after the node.

func (*ReturnStmt) Pos

func (s *ReturnStmt) Pos() source.Pos

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

func (*ReturnStmt) String

func (s *ReturnStmt) String() string

type SelectorExpr

type SelectorExpr struct {
	Expr Expr
	Sel  Expr
}

SelectorExpr represents a selector expression.

func (*SelectorExpr) End

func (e *SelectorExpr) End() source.Pos

End returns the position of first character immediately after the node.

func (*SelectorExpr) Pos

func (e *SelectorExpr) Pos() source.Pos

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

func (*SelectorExpr) String

func (e *SelectorExpr) String() string

type SliceExpr

type SliceExpr struct {
	Expr   Expr
	LBrack source.Pos
	Low    Expr
	High   Expr
	RBrack source.Pos
}

SliceExpr represents a slice expression.

func (*SliceExpr) End

func (e *SliceExpr) End() source.Pos

End returns the position of first character immediately after the node.

func (*SliceExpr) Pos

func (e *SliceExpr) Pos() source.Pos

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

func (*SliceExpr) String

func (e *SliceExpr) String() string

type Stmt

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

Stmt represents a statement in the AST.

type StringLit

type StringLit struct {
	Value    string
	ValuePos source.Pos
	Literal  string
}

StringLit represents a string literal.

func (*StringLit) End

func (e *StringLit) End() source.Pos

End returns the position of first character immediately after the node.

func (*StringLit) Pos

func (e *StringLit) Pos() source.Pos

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

func (*StringLit) String

func (e *StringLit) String() string

type UnaryExpr

type UnaryExpr struct {
	Expr     Expr
	Token    token.Token
	TokenPos source.Pos
}

UnaryExpr represents an unary operator expression.

func (*UnaryExpr) End

func (e *UnaryExpr) End() source.Pos

End returns the position of first character immediately after the node.

func (*UnaryExpr) Pos

func (e *UnaryExpr) Pos() source.Pos

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

func (*UnaryExpr) String

func (e *UnaryExpr) String() string

type UndefinedLit

type UndefinedLit struct {
	TokenPos source.Pos
}

UndefinedLit represents an undefined literal.

func (*UndefinedLit) End

func (e *UndefinedLit) End() source.Pos

End returns the position of first character immediately after the node.

func (*UndefinedLit) Pos

func (e *UndefinedLit) Pos() source.Pos

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

func (*UndefinedLit) String

func (e *UndefinedLit) String() string

Jump to

Keyboard shortcuts

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