ast

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayType

type ArrayType struct {
	Pos     lexer.Pos
	Less    lexer.Pos // <
	T       Type
	Size    Expr
	Greater lexer.Pos // >
}

array<T,Size>

func (*ArrayType) Begin

func (at *ArrayType) Begin() lexer.Pos

func (*ArrayType) Ident

func (t *ArrayType) Ident() *Ident

type BadDecl

type BadDecl struct {
	From lexer.Pos
	To   lexer.Pos
}

func (*BadDecl) Begin

func (bd *BadDecl) Begin() lexer.Pos

type BadExpr

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

func (*BadExpr) Begin

func (be *BadExpr) Begin() lexer.Pos

type BasicLit

type BasicLit struct {
	TokPos lexer.Pos
	Tok    lexer.Token
	Value  string
}

basic literal node

func (*BasicLit) Begin

func (bl *BasicLit) Begin() lexer.Pos

func (*BasicLit) IsString added in v0.1.3

func (bl *BasicLit) IsString() (bool, string)

type BasicType

type BasicType struct {
	Name *Ident
}

builtin basic types(int,uint,string,bool,...)

func (*BasicType) Begin

func (bt *BasicType) Begin() lexer.Pos

func (*BasicType) Ident

func (t *BasicType) Ident() *Ident

type BeanDecl

type BeanDecl struct {
	Kind    string // struct or protocol
	Pos     lexer.Pos
	Doc     *CommentGroup
	Name    *Ident
	Extends []Type
	Tag     *BasicLit
	Fields  *FieldList
}

bean declaration node: struct or protocol

func (*BeanDecl) Begin

func (bd *BeanDecl) Begin() lexer.Pos

type Comment

type Comment struct {
	Slash lexer.Pos
	Text  string
	Values
}

func (*Comment) Begin

func (c *Comment) Begin() lexer.Pos

type CommentGroup

type CommentGroup struct {
	List []*Comment
}

func (*CommentGroup) Begin

func (g *CommentGroup) Begin() lexer.Pos

func (*CommentGroup) Text

func (g *CommentGroup) Text() string

type ConstSpec

type ConstSpec struct {
	Doc     *CommentGroup // doc or nil
	Name    *Ident        // name
	Value   Expr          // value node
	Comment *CommentGroup // line comments or nil
}

func (*ConstSpec) Begin

func (cs *ConstSpec) Begin() lexer.Pos

type Decl

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

----------- Decl node -----------

type Expr

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

----------- expr node -----------

type Field

type Field struct {
	Doc     *CommentGroup // doc comment or nil
	Options []*Ident      // required/optional etc, maybe nil
	Type    Type          // Field type
	Names   []*Ident      // Field is a placeholder if len(Names) == 0
	Default Expr          // default node or nil
	Tag     *BasicLit     // tag or nil
	Comment *CommentGroup // line comment or nil
}

Field node

func (*Field) Begin

func (f *Field) Begin() lexer.Pos

type FieldList

type FieldList struct {
	Opening lexer.Pos // {
	List    []*Field
	Closing lexer.Pos // }
}

FieldList node

func (*FieldList) Begin

func (fl *FieldList) Begin() lexer.Pos

type File

type File struct {
	Filename   string
	Doc        *CommentGroup   // associated documentation; or nil
	Package    lexer.Pos       // position of "package" keyword
	Name       *Ident          // package name
	Decls      []Decl          // top-level declarations; or nil
	Scope      *Scope          // package scope (this file only)
	Imports    []*ImportSpec   // imports in this file
	Unresolved []*Ident        // unresolved identifiers in this file
	Comments   []*CommentGroup // list of all comments in the source file
}

File node

func (*File) Begin

func (f *File) Begin() lexer.Pos

type FuncType

type FuncType struct {
	Func   lexer.Pos
	Params *FieldList // arguments
	Result Type       // return type or nil
}

func (*FuncType) Begin

func (ft *FuncType) Begin() lexer.Pos

func (*FuncType) Ident

func (t *FuncType) Ident() *Ident

type GenDecl

type GenDecl struct {
	Doc    *CommentGroup // doc or nil
	TokPos lexer.Pos
	Tok    lexer.Token // import or const
	Lparen lexer.Pos   // (
	Specs  []Spec
	Rparen lexer.Pos // )
}

generic declaration node

func (*GenDecl) Begin

func (gd *GenDecl) Begin() lexer.Pos

type GroupDecl added in v0.1.3

type GroupDecl struct {
	Pos   lexer.Pos
	Doc   *CommentGroup
	Name  *Ident
	Tag   *BasicLit
	Decls []Decl
}

func (*GroupDecl) Begin added in v0.1.3

func (gd *GroupDecl) Begin() lexer.Pos

type Ident

type Ident struct {
	Pos  lexer.Pos
	Name string
	Obj  *Object
}

Ident node

func (*Ident) Begin

func (ident *Ident) Begin() lexer.Pos

type ImportSpec

type ImportSpec struct {
	Doc     *CommentGroup // doc or nil
	Name    *Ident        // local name or nil
	Package *BasicLit     // package path
	Comment *CommentGroup // line comments or nil
}

func (*ImportSpec) Begin

func (is *ImportSpec) Begin() lexer.Pos

type MapType

type MapType struct {
	Pos     lexer.Pos
	Less    lexer.Pos // <
	K       Type
	V       Type
	Greater lexer.Pos // >
}

map<K,V>

func (*MapType) Begin

func (mt *MapType) Begin() lexer.Pos

func (*MapType) Ident

func (t *MapType) Ident() *Ident

type Node

type Node interface {
	Begin() lexer.Pos
}

type ObjKind

type ObjKind int
const (
	Bad ObjKind = iota
	Pkg
	Const
	Var
	Bean
	Fun
)

func (ObjKind) String

func (kind ObjKind) String() string

type Object

type Object struct {
	Kind ObjKind
	Name string
	Decl interface{} // Field,Spec,Decl or Scope
	Data interface{}
}

func NewObj

func NewObj(kind ObjKind, name string) *Object

NewObj creates a new object of a given kind and name.

func (*Object) Begin

func (obj *Object) Begin() lexer.Pos

type Package

type Package struct {
	Name    string             // package name
	Scope   *Scope             // package scope across all files
	Imports map[string]*Object // map of package id -> package object
	Files   map[string]*File   // source files by filename
}

Package node

func (*Package) Begin

func (p *Package) Begin() lexer.Pos

type Scope

type Scope struct {
	Outer   *Scope
	Objects map[string]*Object
}

A Scope maintains the set of named language entities declared in the scope and a link to the immediately surrounding (outer) scope.

func NewScope

func NewScope(outer *Scope) *Scope

NewScope creates a new scope nested in the outer scope.

func (*Scope) Insert

func (s *Scope) Insert(obj *Object) (alt *Object)

Insert attempts to insert a named object obj into the scope s. If the scope already contains an object alt with the same name, Insert leaves the scope unchanged and returns alt. Otherwise it inserts obj and returns nil.

func (*Scope) Lookup

func (s *Scope) Lookup(name string) *Object

Lookup returns the object with the given name if it is found in scope s, otherwise it returns nil. Outer scopes are ignored.

func (*Scope) String

func (s *Scope) String() string

Debugging support

type Spec

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

----------- spec node -----------

type StructType

type StructType struct {
	Package *Ident // package or nil
	Name    *Ident
}

struct/protocol

func (*StructType) Begin

func (st *StructType) Begin() lexer.Pos

func (*StructType) Ident

func (t *StructType) Ident() *Ident

type Type

type Type interface {
	Expr

	Ident() *Ident
	// contains filtered or unexported methods
}

----------- Type node -----------

type Values

type Values map[string][]string

func (Values) Exist

func (v Values) Exist(key string) bool

func (Values) Get

func (v Values) Get(key string) []string

type VectorType

type VectorType struct {
	Pos     lexer.Pos
	Less    lexer.Pos // <
	T       Type
	Greater lexer.Pos // >
}

vector<T>

func (*VectorType) Begin

func (vt *VectorType) Begin() lexer.Pos

func (*VectorType) Ident

func (t *VectorType) Ident() *Ident

type Visitor

type Visitor interface {
	Visit(Node) Visitor
	In()
	Out()
}

func Walk

func Walk(node Node, visitor Visitor) Visitor

Jump to

Keyboard shortcuts

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