ast

package
v0.0.0-...-4cc5765 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Atom

type Atom struct {
	Tok     token.Token
	Lit     string
	TokPos  token.Pos
	TokEnd  token.Pos
	Comment []string
}

func (*Atom) At

func (a *Atom) At(_ int) Node

func (*Atom) Comments

func (a *Atom) Comments() []string

func (*Atom) End

func (a *Atom) End() token.Pos

func (*Atom) Len

func (a *Atom) Len() int

func (*Atom) Op

func (a *Atom) Op() token.Token

func (*Atom) Pos

func (a *Atom) Pos() token.Pos

func (*Atom) String

func (a *Atom) String() string

func (*Atom) WriteTo

func (a *Atom) WriteTo(out io.StringWriter)

type Bad

type Bad struct {
	Atom // contains expected token
	Node Node
	Err  error
}

func (*Bad) At

func (b *Bad) At(i int) Node

func (*Bad) End

func (b *Bad) End() token.Pos

func (*Bad) Len

func (b *Bad) Len() int

func (*Bad) String

func (b *Bad) String() string

func (*Bad) WriteTo

func (b *Bad) WriteTo(out io.StringWriter)

type Binary

type Binary struct {
	Atom
	X Node
	Y Node
}

*

  • Node with two children. Used for binary expressions, closures, types,
  • RANGE, SEND and other two-argument statements. *
  • LAMBDA content is: functype funcbody
  • RANGE content is: init block
  • SEND content is: channel expr

func (*Binary) At

func (b *Binary) At(i int) (ret Node)

func (*Binary) End

func (b *Binary) End() (pos token.Pos)

func (*Binary) Len

func (b *Binary) Len() int

func (*Binary) String

func (b *Binary) String() string

func (*Binary) WriteTo

func (b *Binary) WriteTo(out io.StringWriter)

type Dir

type Dir struct {
	Atom
	Files   []*File
	FileSet *token.FileSet
}

func (*Dir) At

func (d *Dir) At(i int) (child Node)

func (*Dir) End

func (d *Dir) End() token.Pos

func (*Dir) Len

func (d *Dir) Len() int

func (*Dir) PkgName

func (d *Dir) PkgName() string

PkgName returns package name

func (*Dir) PkgPath

func (d *Dir) PkgPath() string

PkgPath returns package path

func (*Dir) String

func (d *Dir) String() string

func (*Dir) WriteTo

func (d *Dir) WriteTo(out io.StringWriter)

type Field

type Field struct {
	Atom
	Names *List
	Type  Node
	Tag   *Atom
}

func (*Field) At

func (f *Field) At(i int) (child Node)

func (*Field) End

func (f *Field) End() token.Pos

func (*Field) Len

func (f *Field) Len() int

func (*Field) String

func (f *Field) String() string

func (*Field) WriteTo

func (f *Field) WriteTo(out io.StringWriter)

type File

type File struct {
	Atom
	Package *Unary
	Imports *List
	Decls   *List
	File    *token.File
}

func (*File) At

func (f *File) At(i int) (child Node)

func (*File) End

func (f *File) End() token.Pos

func (*File) Len

func (f *File) Len() int

func (*File) PkgName

func (f *File) PkgName() string

func (*File) String

func (f *File) String() string

func (*File) WriteTo

func (f *File) WriteTo(out io.StringWriter)

type FuncDecl

type FuncDecl struct {
	Atom       // always token.FUNC
	Recv *List // nil for functions, non-nil for methods
	Name Node
	Type Node // *ast.FunctType or *ast.GenericType
	Body *List
}

func (*FuncDecl) At

func (f *FuncDecl) At(i int) (child Node)

func (*FuncDecl) End

func (f *FuncDecl) End() token.Pos

func (*FuncDecl) Len

func (f *FuncDecl) Len() int

func (*FuncDecl) String

func (f *FuncDecl) String() string

func (*FuncDecl) WriteTo

func (f *FuncDecl) WriteTo(out io.StringWriter)

type FuncType

type FuncType struct {
	Atom    // always token.FUNC
	Params  *List
	Results *List
}

func (*FuncType) At

func (f *FuncType) At(i int) (child Node)

func (*FuncType) End

func (f *FuncType) End() token.Pos

func (*FuncType) Len

func (f *FuncType) Len() int

func (*FuncType) String

func (f *FuncType) String() string

func (*FuncType) WriteTo

func (f *FuncType) WriteTo(out io.StringWriter)

type GenericType

type GenericType struct {
	Atom   // always token.GENERIC
	Params *List
	Type   Node
}

func (*GenericType) At

func (g *GenericType) At(i int) (child Node)

func (*GenericType) End

func (g *GenericType) End() token.Pos

func (*GenericType) Len

func (g *GenericType) Len() int

func (*GenericType) String

func (g *GenericType) String() string

func (*GenericType) WriteTo

func (g *GenericType) WriteTo(out io.StringWriter)

type List

type List struct {
	Atom
	Nodes []Node
}

*

  • List of nodes. Used for all variable-sized array of nodes,
  • and also for many fixed-size array of nodes, including:
  • BLOCK, CALL, COMPOSITE_LIT, FOR, IF, INDEX, RETURN, SELECT, SWITCH. *
  • BLOCK content is: [stmt0 [stmt1 [...]]
  • CALL content is: fun [arg0 [arg1 [...]]]
  • COMPOSITE_LIT content is: type [elem0 [elem1 [...]]]
  • FOR content is: init cond post block
  • IF content is: init cond then else
  • INDEX content is: expr [arg0 [arg1 [...]]]
  • RETURN content is: [expr0 [expr1 [...]]]
  • SELECT content is: [clause0 [clause1 [...]]
  • SWITCH content is: init expr [case0 [case1 [...]]

func (*List) At

func (l *List) At(i int) Node

func (*List) End

func (l *List) End() token.Pos

func (*List) Len

func (l *List) Len() int

func (*List) String

func (l *List) String() string

func (*List) WriteTo

func (l *List) WriteTo(out io.StringWriter)

type Node

type Node interface {
	Op() token.Token
	Len() int      // return number of children
	At(i int) Node // get i-th child
	Pos() token.Pos
	End() token.Pos
	Comments() []string
	String() string
	WriteTo(out io.StringWriter)
}

type Unary

type Unary struct {
	Atom
	X Node
}

*

  • Node with one children. Used for unary expressions, types,
  • DEC, DEFER, GO, GOTO, INC and other one-argument statements.

func (*Unary) At

func (u *Unary) At(i int) Node

func (*Unary) End

func (u *Unary) End() token.Pos

func (*Unary) Len

func (u *Unary) Len() int

func (*Unary) String

func (u *Unary) String() string

func (*Unary) WriteTo

func (u *Unary) WriteTo(out io.StringWriter)

type ValueSpec

type ValueSpec struct {
	Atom
	Names  *List
	Type   Node
	Values *List
}

func (*ValueSpec) At

func (v *ValueSpec) At(i int) (child Node)

func (*ValueSpec) End

func (v *ValueSpec) End() token.Pos

func (*ValueSpec) Len

func (v *ValueSpec) Len() int

func (*ValueSpec) String

func (v *ValueSpec) String() string

func (*ValueSpec) WriteTo

func (v *ValueSpec) WriteTo(out io.StringWriter)

Jump to

Keyboard shortcuts

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