ast

package
v0.0.0-...-99c6562 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package ast contains abstract syntax tree node types.

Index

Constants

View Source
const (
	MinBinaryPrecedence = 1
	MaxBinaryPrecedence = 5
	UltimatePrecedence  = 6
)

Special precedence levels.

View Source
const (
	OpAdd       = BinaryOp(token.Plus)
	OpSubtract  = BinaryOp(token.Minus)
	OpMultiply  = BinaryOp(token.Asterisk)
	OpDivide    = BinaryOp(token.Slash)
	OpRemainder = BinaryOp(token.Percent)

	OpLogicalAnd = BinaryOp(token.LogicalAnd)
	OpLogicalOr  = BinaryOp(token.LogicalOr)

	OpAndNot      = BinaryOp(token.AndNot)
	OpAnd         = BinaryOp(token.Ampersand)
	OpOr          = BinaryOp(token.Pipe)
	OpExclusiveOr = BinaryOp(token.Caret)

	OpShiftLeft  = BinaryOp(token.ShiftLeft)
	OpShiftRight = BinaryOp(token.ShiftRight)

	OpEqual          = BinaryOp(token.Equal)
	OpNotEqual       = BinaryOp(token.NotEqual)
	OpLessOrEqual    = BinaryOp(token.LessOrEqual)
	OpGreaterOrEqual = BinaryOp(token.GreaterOrEqual)
	OpLess           = BinaryOp(token.Less)
	OpGreater        = BinaryOp(token.Greater)
)
View Source
const (
	OpIdentity   = UnaryOp(token.Plus)
	OpNegate     = UnaryOp(token.Minus)
	OpComplement = UnaryOp(token.Caret)
	OpNot        = UnaryOp(token.Exclamation)
)

Variables

This section is empty.

Functions

func IsComment

func IsComment(node Node) bool

func VisitAssignListChild

func VisitAssignListChild(x AssignListChild,
	visitAssigner func(AssignerDereference),
	visitCall func(Call),
	visitIndex func(Index),
	visitSelector func(Selector),
)

func VisitBlockChild

func VisitBlockChild(x BlockChild,
	visitAssign func(Assign),
	visitBlock func(Block),
	visitBreak func(Break),
	visitComment func(Comment),
	visitContinue func(Continue),
	visitExpression func(Expression),
	visitFor func(For),
	visitIf func(If),
	visitImport func(Import),
	visitReturn func(Return),
	visitVariableDecl func(VariableDecl),
	visitVariableDef func(VariableDef),
)

func VisitExpr

func VisitExpr(x ExprChild,
	visitAddress func(Address),
	visitBinary func(Binary),
	visitBoolean func(Boolean),
	visitCall func(Call),
	visitCharacter func(Character),
	visitClone func(Clone),
	visitIndex func(Index),
	visitInteger func(Integer),
	visitNil func(Nil),
	visitPointer func(PointerDereference),
	visitSelector func(Selector),
	visitString func(String),
	visitUnary func(Unary),
	visitZero func(Zero),
)

func VisitExprListChild

func VisitExprListChild(x ExprListChild,
	visitAssigner func(AssignerDereference),
	visitComment func(Comment),
	visitExpression func(Expression),
)

func VisitFieldListChild

func VisitFieldListChild(x FieldListChild,
	visitComment func(Comment),
	visitField func(Field),
	visitImport func(Import),
)

func VisitFileChild

func VisitFileChild(x FileChild,
	visitComment func(Comment),
	visitConstant func(ConstantDef),
	visitFunction func(FunctionDef),
	visitImport func(Import),
	visitImports func(Imports),
	visitType func(TypeDef),
)

func VisitIdentListChild

func VisitIdentListChild(x IdentListChild,
	visitComment func(Comment),
	visitIdentifier func(Identifier),
)

func VisitImportListChild

func VisitImportListChild(x ImportListChild,
	visitComment func(Comment),
	visitImport func(Import),
)

func VisitParamListChild

func VisitParamListChild(x ParamListChild,
	visitComment func(Comment),
	visitParameter func(Parameter),
)

func VisitTypeListChild

func VisitTypeListChild(x TypeListChild,
	visitComment func(Comment),
	visitType func(TypeSpec),
)

Types

type Address

type Address struct {
	source.Position
	Expr ExprChild
	End  source.Position
}

func (Address) EndPos

func (x Address) EndPos() source.Position

func (Address) Node

func (Address) Node() string

func (Address) Pos

func (x Address) Pos() source.Position

func (Address) String

func (x Address) String() string

type Assign

type Assign struct {
	source.Position
	Objects  []AssignListChild
	Subjects []ExprListChild
	End      source.Position
}

func (Assign) EndPos

func (x Assign) EndPos() source.Position

func (Assign) Node

func (Assign) Node() string

func (Assign) Pos

func (x Assign) Pos() source.Position

func (Assign) String

func (x Assign) String() string

type AssignListChild

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

type AssignerDereference

type AssignerDereference struct {
	source.Position
	Name string
	End  source.Position
}

func (AssignerDereference) EndPos

func (x AssignerDereference) EndPos() source.Position

func (AssignerDereference) Node

func (AssignerDereference) Node() string

func (AssignerDereference) Pos

func (AssignerDereference) String

func (x AssignerDereference) String() string

type Binary

type Binary struct {
	Left  ExprChild
	Op    BinaryOp
	Right ExprChild
	End   source.Position
}

func (Binary) EndPos

func (x Binary) EndPos() source.Position

func (Binary) Node

func (Binary) Node() string

func (Binary) Pos

func (x Binary) Pos() source.Position

func (Binary) String

func (x Binary) String() string

type BinaryOp

type BinaryOp token.Kind

func (BinaryOp) Precedence

func (op BinaryOp) Precedence() int

Precedence level of the binary operator.

func (BinaryOp) String

func (op BinaryOp) String() string

type Block

type Block struct {
	source.Position
	Body []BlockChild
	End  source.Position
}

func (Block) EndPos

func (x Block) EndPos() source.Position

func (Block) Node

func (Block) Node() string

func (Block) Pos

func (x Block) Pos() source.Position

func (Block) String

func (x Block) String() string

type BlockChild

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

type Boolean

type Boolean struct {
	source.Position
	Value bool
	End   source.Position
}

func (Boolean) EndPos

func (x Boolean) EndPos() source.Position

func (Boolean) Node

func (Boolean) Node() string

func (Boolean) Pos

func (x Boolean) Pos() source.Position

func (Boolean) String

func (x Boolean) String() string

type Break

type Break struct {
	source.Position
	End source.Position
}

func (Break) EndPos

func (x Break) EndPos() source.Position

func (Break) Node

func (Break) Node() string

func (Break) Pos

func (x Break) Pos() source.Position

func (Break) String

func (Break) String() string

type Call

type Call struct {
	Name Selector
	Args []ExprListChild
	End  source.Position
}

func (Call) EndPos

func (x Call) EndPos() source.Position

func (Call) Node

func (Call) Node() string

func (Call) Pos

func (x Call) Pos() source.Position

func (Call) String

func (x Call) String() string

type Character

type Character struct {
	source.Position
	Source string
	End    source.Position
}

func (Character) EndPos

func (x Character) EndPos() source.Position

func (Character) Node

func (Character) Node() string

func (Character) Pos

func (x Character) Pos() source.Position

func (Character) String

func (x Character) String() string

type Clone

type Clone struct {
	source.Position
	Expr ExprChild
	End  source.Position
}

func (Clone) EndPos

func (x Clone) EndPos() source.Position

func (Clone) Node

func (Clone) Node() string

func (Clone) Pos

func (x Clone) Pos() source.Position

func (Clone) String

func (x Clone) String() string

type Comment

type Comment struct {
	source.Position
	Source string
}

func (Comment) EndPos

func (x Comment) EndPos() source.Position

func (Comment) Node

func (Comment) Node() string

func (Comment) Pos

func (x Comment) Pos() source.Position

func (Comment) String

func (x Comment) String() string

type ConstantDef

type ConstantDef struct {
	source.Position
	Public    bool
	ConstName string
	Value     ExprChild
	End       source.Position
}

func (ConstantDef) EndPos

func (x ConstantDef) EndPos() source.Position

func (ConstantDef) Name

func (x ConstantDef) Name() string

func (ConstantDef) Node

func (ConstantDef) Node() string

func (ConstantDef) Pos

func (x ConstantDef) Pos() source.Position

func (ConstantDef) String

func (x ConstantDef) String() string

type Continue

type Continue struct {
	source.Position
	End source.Position
}

func (Continue) EndPos

func (x Continue) EndPos() source.Position

func (Continue) Node

func (Continue) Node() string

func (Continue) Pos

func (x Continue) Pos() source.Position

func (Continue) String

func (Continue) String() string

type ExprChild

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

type ExprListChild

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

type Expression

type Expression struct {
	Expr ExprChild
}

func (Expression) EndPos

func (x Expression) EndPos() source.Position

func (Expression) Node

func (Expression) Node() string

func (Expression) Pos

func (x Expression) Pos() source.Position

func (Expression) String

func (x Expression) String() string

type Field

type Field struct {
	source.Position
	FieldName string
	Type      TypeSpec
	Access    field.Access
	End       source.Position
}

func (Field) EndPos

func (x Field) EndPos() source.Position

func (Field) Name

func (x Field) Name() string

func (Field) Node

func (Field) Node() string

func (Field) Pos

func (x Field) Pos() source.Position

func (Field) String

func (x Field) String() string

type FieldListChild

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

type FileChild

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

type For

type For struct {
	source.Position
	Test    ExprChild // Nil if infinite loop.
	BodyPos source.Position
	Body    []BlockChild
	End     source.Position
}

func (For) EndPos

func (x For) EndPos() source.Position

func (For) Node

func (For) Node() string

func (For) Pos

func (x For) Pos() source.Position

func (For) String

func (x For) String() string

type FunctionDef

type FunctionDef struct {
	source.Position
	Public       bool
	ReceiverName string
	ReceiverType *TypeSpec
	FuncName     string
	Params       []ParamListChild
	ParamsEnd    source.Position
	Results      []TypeListChild
	BodyPos      source.Position
	Body         []BlockChild
	End          source.Position
}

func (FunctionDef) EndPos

func (x FunctionDef) EndPos() source.Position

func (FunctionDef) Name

func (x FunctionDef) Name() string

func (FunctionDef) Node

func (FunctionDef) Node() string

func (FunctionDef) Pos

func (x FunctionDef) Pos() source.Position

func (FunctionDef) String

func (x FunctionDef) String() string

type IdentListChild

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

type Identifier

type Identifier struct {
	source.Position
	Name QualifiedName
	End  source.Position
}

func (Identifier) EndPos

func (x Identifier) EndPos() source.Position

func (Identifier) Node

func (Identifier) Node() string

func (Identifier) Pos

func (x Identifier) Pos() source.Position

func (Identifier) String

func (x Identifier) String() string

type If

type If struct {
	source.Position
	Test    ExprChild
	ThenPos source.Position
	Then    []BlockChild
	ThenEnd source.Position
	Else    []BlockChild
	End     source.Position
}

func (If) EndPos

func (x If) EndPos() source.Position

func (If) Node

func (If) Node() string

func (If) Pos

func (x If) Pos() source.Position

func (If) String

func (x If) String() string

type Import

type Import struct {
	source.Position
	Path  string
	Names []IdentListChild
	End   source.Position
}

func (Import) EndPos

func (x Import) EndPos() source.Position

func (Import) Node

func (Import) Node() string

func (Import) Pos

func (x Import) Pos() source.Position

func (Import) String

func (x Import) String() string

type ImportListChild

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

type Imports

type Imports struct {
	source.Position
	Imports []ImportListChild
	End     source.Position
}

func (Imports) EndPos

func (x Imports) EndPos() source.Position

func (Imports) Node

func (Imports) Node() string

func (Imports) Pos

func (x Imports) Pos() source.Position

func (Imports) String

func (x Imports) String() string

type Index

type Index struct {
	Name  Selector
	Index ExprChild
	End   source.Position
}

func (Index) EndPos

func (x Index) EndPos() source.Position

func (Index) Node

func (Index) Node() string

func (Index) Pos

func (x Index) Pos() source.Position

func (Index) String

func (x Index) String() string

type Integer

type Integer struct {
	source.Position
	Source string
	End    source.Position
}

func (Integer) EndPos

func (x Integer) EndPos() source.Position

func (Integer) Node

func (Integer) Node() string

func (Integer) Pos

func (x Integer) Pos() source.Position

func (Integer) String

func (x Integer) String() string

type Nil

type Nil struct {
	source.Position
	End source.Position
}

func (Nil) EndPos

func (x Nil) EndPos() source.Position

func (Nil) Node

func (Nil) Node() string

func (Nil) Pos

func (x Nil) Pos() source.Position

func (Nil) String

func (Nil) String() string

type Node

type Node interface {
	Node() string
	Pos() source.Position
	EndPos() source.Position
	String() string
}

type ParamListChild

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

type Parameter

type Parameter struct {
	source.Position
	ParamName string
	Type      TypeSpec
	End       source.Position
}

func (Parameter) EndPos

func (x Parameter) EndPos() source.Position

func (Parameter) Name

func (x Parameter) Name() string

func (Parameter) Node

func (Parameter) Node() string

func (Parameter) Pos

func (x Parameter) Pos() source.Position

func (Parameter) String

func (x Parameter) String() string

type PointerDereference

type PointerDereference struct {
	source.Position
	Expr ExprChild
	End  source.Position
}

func (PointerDereference) EndPos

func (x PointerDereference) EndPos() source.Position

func (PointerDereference) Node

func (PointerDereference) Node() string

func (PointerDereference) Pos

func (PointerDereference) String

func (x PointerDereference) String() string

type QualifiedName

type QualifiedName []string

func (QualifiedName) Namespace

func (name QualifiedName) Namespace() string

func (QualifiedName) Short

func (name QualifiedName) Short() string

func (QualifiedName) String

func (name QualifiedName) String() string

type Return

type Return struct {
	source.Position
	Values []ExprListChild
	End    source.Position
}

func (Return) EndPos

func (x Return) EndPos() source.Position

func (Return) Node

func (Return) Node() string

func (Return) Pos

func (x Return) Pos() source.Position

func (Return) String

func (x Return) String() string

type Selector

type Selector struct {
	source.Position
	Name []string
	End  source.Position
}

func (Selector) EndPos

func (x Selector) EndPos() source.Position

func (Selector) Node

func (Selector) Node() string

func (Selector) Pos

func (x Selector) Pos() source.Position

func (Selector) String

func (x Selector) String() string

type String

type String struct {
	source.Position
	Source string
	End    source.Position
}

func (String) EndPos

func (x String) EndPos() source.Position

func (String) Node

func (String) Node() string

func (String) Pos

func (x String) Pos() source.Position

func (String) String

func (x String) String() string

type Type

type Type struct {
	Assigner  bool
	Pointer   bool
	Reference bool
	Shared    bool
	Item      *Type         // Non-nil if array.
	Name      QualifiedName // Empty if array.
}

func (Type) Equal

func (t Type) Equal(other Type) bool

func (Type) String

func (t Type) String() string

type TypeDef

type TypeDef struct {
	source.Position
	Public   bool
	TypeName string
	Fields   []FieldListChild
	End      source.Position
}

func (TypeDef) EndPos

func (x TypeDef) EndPos() source.Position

func (TypeDef) Name

func (x TypeDef) Name() string

func (TypeDef) Node

func (TypeDef) Node() string

func (TypeDef) Pos

func (x TypeDef) Pos() source.Position

func (TypeDef) String

func (x TypeDef) String() string

type TypeListChild

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

type TypeSpec

type TypeSpec struct {
	source.Position
	Type
	End source.Position
}

func (TypeSpec) EndPos

func (x TypeSpec) EndPos() source.Position

func (TypeSpec) Node

func (TypeSpec) Node() string

func (TypeSpec) Pos

func (x TypeSpec) Pos() source.Position

func (TypeSpec) String

func (x TypeSpec) String() string

type Unary

type Unary struct {
	source.Position
	Op   UnaryOp
	Expr ExprChild
	End  source.Position
}

func (Unary) EndPos

func (x Unary) EndPos() source.Position

func (Unary) Node

func (Unary) Node() string

func (Unary) Pos

func (x Unary) Pos() source.Position

func (Unary) String

func (x Unary) String() string

type UnaryOp

type UnaryOp token.Kind

func (UnaryOp) String

func (op UnaryOp) String() string

type VariableDecl

type VariableDecl struct {
	source.Position
	Names []string
	Type  *TypeSpec // Nil if auto.
	End   source.Position
}

func (VariableDecl) EndPos

func (x VariableDecl) EndPos() source.Position

func (VariableDecl) Node

func (VariableDecl) Node() string

func (VariableDecl) Pos

func (x VariableDecl) Pos() source.Position

func (VariableDecl) String

func (x VariableDecl) String() string

type VariableDef

type VariableDef struct {
	source.Position
	Names  []string
	Values []ExprListChild
	End    source.Position
}

func (VariableDef) EndPos

func (x VariableDef) EndPos() source.Position

func (VariableDef) Node

func (VariableDef) Node() string

func (VariableDef) Pos

func (x VariableDef) Pos() source.Position

func (VariableDef) String

func (x VariableDef) String() string

type Zero

type Zero struct {
	source.Position
	End source.Position
}

func (Zero) EndPos

func (x Zero) EndPos() source.Position

func (Zero) Node

func (Zero) Node() string

func (Zero) Pos

func (x Zero) Pos() source.Position

func (Zero) String

func (Zero) String() string

Jump to

Keyboard shortcuts

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