ast

package
v0.0.0-...-237ceba Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigType            = "type"
	ConfigTypeSubscribe   = "subscribe"
	ConfigTypeUnsubscribe = "unsubscribe"
	ConfigCallback        = "callback"
	ConfigChannel         = "channel"
)

Function configuration constants.

Variables

This section is empty.

Functions

func MarshalJSON

func MarshalJSON(n jsonNode) ([]byte, error)

MarshalJSON implements the Marshaler interface.

Types

type Alternative

type Alternative struct {
	Name string    `json:"name"`
	Cmd  string    `json:"cmd"`
	Type TypeNode  `json:"type"`
	List FieldList `json:"list"`
}

Alternative represents a set of alternative fields.

func (*Alternative) MarshalJSON

func (alt *Alternative) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

func (*Alternative) NodeCmd

func (alt *Alternative) NodeCmd() string

NodeCmd implements FieldNode interface.

func (*Alternative) NodeName

func (alt *Alternative) NodeName() string

NodeName implements FieldNode interface.

func (*Alternative) NodeType

func (alt *Alternative) NodeType() TypeNode

NodeType implements FieldNode interface.

func (*Alternative) UnmarshalJSON

func (alt *Alternative) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the Unmarshaler interface.

type AlternativeAlias

type AlternativeAlias Alternative

AlternativeAlias is the alias type for Alternative.

type BaseType

type BaseType struct {
	Name string `json:"name"`
}

BaseType represents a base type (like string, int64, ...).

func (*BaseType) MarshalJSON

func (t *BaseType) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

func (*BaseType) String

func (t *BaseType) String() string

TypeNode Stringer interface

type BaseTypeAlias

type BaseTypeAlias BaseType

BaseTypeAlias is the alias type for BaseType.

type DataType

type DataType struct {
	Name string `json:"name"`
}

DataType represents a structure.

func (*DataType) MarshalJSON

func (t *DataType) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

func (*DataType) String

func (t *DataType) String() string

type DataTypeAlias

type DataTypeAlias DataType

DataTypeAlias is the alias type for DataType.

type DeclNode

type DeclNode interface {
	// contains filtered or unexported methods
}

DeclNode represents a declaration.

type DeclNodeList

type DeclNodeList []DeclNode

DeclNodeList is a sclice ao all declaration nodes.

func (*DeclNodeList) UnmarshalJSON

func (l *DeclNodeList) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the Unmarshaler interface.

type DeclNodes

type DeclNodes map[string]DeclNode

DeclNodes is a map of declaration nodes with key name.

func (*DeclNodes) UnmarshalJSON

func (n *DeclNodes) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the Unmarshaler interface.

type EllipsisType

type EllipsisType struct {
	Node TypeNode `json:"node"`
}

EllipsisType represents a variadic attribute.

func (*EllipsisType) MarshalJSON

func (t *EllipsisType) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

func (*EllipsisType) String

func (t *EllipsisType) String() string

func (*EllipsisType) UnmarshalJSON

func (t *EllipsisType) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the Unmarshaler interface.

type EllipsisTypeAlias

type EllipsisTypeAlias EllipsisType

EllipsisTypeAlias is the alias type for EllipsisType.

type EnumBoolType

type EnumBoolType struct {
	Values []string `json:"values"`
}

EnumBoolType represents an one or two element enumeration.

func (*EnumBoolType) BaseType

func (t *EnumBoolType) BaseType() TypeNode

BaseType returns the base type of an EnumBoolType.

func (*EnumBoolType) MarshalJSON

func (t *EnumBoolType) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

func (*EnumBoolType) String

func (t *EnumBoolType) String() string

type EnumBoolTypeAlias

type EnumBoolTypeAlias EnumBoolType

EnumBoolTypeAlias is the alias type for EnumBoolType.

type EnumDecl

type EnumDecl struct {
	Name   string   `json:"name"`
	Values []string `json:"values"`
}

EnumDecl represents an enumeration declaration.

func NewEnumDecl

func NewEnumDecl(name string, values []string) *EnumDecl

NewEnumDecl is the EnumDecl constructor.

func (*EnumDecl) MarshalJSON

func (d *EnumDecl) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

type EnumDeclAlias

type EnumDeclAlias EnumDecl

EnumDeclAlias is the alias type for EnumDecl.

type Field

type Field struct {
	Name string   `json:"name"`
	Cmd  string   `json:"cmd"`
	Type TypeNode `json:"type"`
}

Field represents an AST field.

func (*Field) MarshalJSON

func (f *Field) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

func (*Field) NodeCmd

func (f *Field) NodeCmd() string

NodeCmd implements FieldNode interface.

func (*Field) NodeName

func (f *Field) NodeName() string

NodeName implements FieldNode interface.

func (*Field) NodeType

func (f *Field) NodeType() TypeNode

NodeType implements FieldNode interface.

func (*Field) UnmarshalJSON

func (f *Field) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the Unmarshaler interface.

type FieldAlias

type FieldAlias Field

FieldAlias is the alias type for Field.

type FieldList

type FieldList []FieldNode

FieldList is a list of field definitions.

func (*FieldList) UnmarshalJSON

func (l *FieldList) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the Unmarshaler interface.

func (FieldList) WalkNode

func (list FieldList) WalkNode(fct WalkNodeFct)

WalkNode iterates through all nodes of the list.

type FieldNode

type FieldNode interface {
	NodeName() string
	NodeCmd() string
	NodeType() TypeNode
	// contains filtered or unexported methods
}

FieldNode represents a field definition.

type FuncAttr

type FuncAttr struct {
	Name       string `json:"name"`
	Summary    string `json:"summary"`
	Complexity string `json:"complexity"`
	Since      string `json:"since"`
	Group      string `json:"group"`
}

FuncAttr represents a function attribute declaration.

func NewFuncAttr

func NewFuncAttr(name, summary, complexity, since, group string) *FuncAttr

NewFuncAttr is the FuncAttr constructor.

func (*FuncAttr) MarshalJSON

func (d *FuncAttr) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

type FuncAttrAlias

type FuncAttrAlias FuncAttr

FuncAttrAlias is the alias type for FuncAttr.

type FuncConfig

type FuncConfig struct {
	Name   string            `json:"name"`
	Config map[string]string `json:"config"`
}

FuncConfig represents a function configuration declaration

func (*FuncConfig) MarshalJSON

func (d *FuncConfig) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

type FuncConfigAlias

type FuncConfigAlias FuncConfig

FuncConfigAlias is the alias type for FuncConfig.

type FuncDecl

type FuncDecl struct {
	Name  string    `json:"name"`
	Skip  bool      `json:"skip"`
	Attr  string    `json:"attr"`
	Token []string  `json:"token"`
	List  FieldList `json:"list"`
}

FuncDecl represents a function declaration.

func NewFuncDecl

func NewFuncDecl(name, attr string, token []string) *FuncDecl

NewFuncDecl is the FuncDecl constructor.

func (*FuncDecl) MarshalJSON

func (d *FuncDecl) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

type FuncDeclAlias

type FuncDeclAlias FuncDecl

FuncDeclAlias is the alias type for FuncDecl.

type NodeKind

type NodeKind struct {
	Kind string `json:"_type"`
}

NodeKind is a helper structure to unmarshall the node kind.

type PointerType

type PointerType struct {
	Node TypeNode `json:"node"`
}

PointerType represents an optinal attribute.

func (*PointerType) MarshalJSON

func (t *PointerType) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

func (*PointerType) String

func (t *PointerType) String() string

func (*PointerType) UnmarshalJSON

func (t *PointerType) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the Unmarshaler interface.

type PointerTypeAlias

type PointerTypeAlias PointerType

PointerTypeAlias is the alias type for PointerType.

type RawAlternative

type RawAlternative struct {
	Name string          `json:"name"`
	Cmd  string          `json:"cmd"`
	Type json.RawMessage `json:"type"`
	List FieldList       `json:"list"`
}

RawAlternative is a helper structure to unmarshal an alternative and it's type in raw json format.

type RawEllipsisType

type RawEllipsisType struct {
	Node json.RawMessage `json:"node"`
}

RawEllipsisType is a helper structure to unmarshal an ellipsis.

type RawField

type RawField struct {
	Name string          `json:"name"`
	Cmd  string          `json:"cmd"`
	Type json.RawMessage `json:"type"`
}

RawField is a helper structure to unmarshal a field and it's type in raw json format.

type RawPointerType

type RawPointerType struct {
	Node json.RawMessage `json:"node"`
}

RawPointerType is a helper structure to unmarshal a pointer.

type RawSliceType

type RawSliceType struct {
	AllowNil bool
	Node     json.RawMessage `json:"node"`
}

RawSliceType is a helper structure to unmarshal a slice.

type Scope

type Scope struct {
	// contains filtered or unexported fields
}

Scope represents an AST scope.

func NewScope

func NewScope(list DeclNodeList) *Scope

NewScope is the Scope constructor.

func (*Scope) InsertDecl

func (s *Scope) InsertDecl(decl DeclNode) bool

InsertDecl inserts a declaration node in scope.

func (*Scope) Lookup

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

Lookup searches and returns a declaration by name.

func (*Scope) LookupFuncAttr

func (s *Scope) LookupFuncAttr(name string) *FuncAttr

LookupFuncAttr searches and returns a function attribute declaration by name.

func (*Scope) LookupFuncConfig

func (s *Scope) LookupFuncConfig(name string) *FuncConfig

LookupFuncConfig searches and returns a function configuration declaration by name.

func (*Scope) LoopEnum

func (s *Scope) LoopEnum(f func(*EnumDecl))

LoopEnum iterates through all enumeration declarations.

func (*Scope) LoopFunc

func (s *Scope) LoopFunc(f func(*FuncDecl))

LoopFunc iterates through all function declarations.

func (*Scope) LoopStruct

func (s *Scope) LoopStruct(f func(*StructDecl))

LoopStruct iterates through all structure declarations.

func (*Scope) NodeList

func (s *Scope) NodeList() DeclNodeList

NodeList return all declaration nodes.

func (*Scope) Nodes

func (s *Scope) Nodes() DeclNodes

Nodes returns a map of declaration nodes.

type SliceType

type SliceType struct {
	AllowNil bool
	Node     TypeNode `json:"node"`
}

SliceType represents a multi-value attribute.

func (*SliceType) MarshalJSON

func (t *SliceType) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

func (*SliceType) String

func (t *SliceType) String() string

func (*SliceType) UnmarshalJSON

func (t *SliceType) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the Unmarshaler interface.

type SliceTypeAlias

type SliceTypeAlias SliceType

SliceTypeAlias is the alias type for SliceType.

type StructDecl

type StructDecl struct {
	Name string    `json:"name"`
	List FieldList `json:"list"`
}

StructDecl represent a structure declaration.

func NewStructDecl

func NewStructDecl(name string) *StructDecl

NewStructDecl is the StructDecl constructor.

func (*StructDecl) MarshalJSON

func (d *StructDecl) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

type StructDeclAlias

type StructDeclAlias StructDecl

StructDeclAlias is the alias type for StructDecl.

type TypeNode

type TypeNode interface {
	String() string
	// contains filtered or unexported methods
}

TypeNode represents a node with type information.

var (
	// KeyType represents a key.
	KeyType TypeNode = &BaseType{Name: "interface{}"}
	// InterfaceType represents a generic type.
	InterfaceType TypeNode = &BaseType{Name: "interface{}"}
	// StringType represents a string.
	StringType TypeNode = &BaseType{Name: "string"}
	// IntegerType represents an integer.
	IntegerType TypeNode = &BaseType{Name: "int64"}
	// FloatType represents a float.
	FloatType TypeNode = &BaseType{Name: "float64"}
	// BoolType represents a boolean.
	BoolType TypeNode = &BaseType{Name: "bool"}
	// TimeType represents a time.
	TimeType TypeNode = &BaseType{Name: "time.Time"}

	// StringPointerType represents a pointer to a string
	StringPointerType TypeNode = &PointerType{Node: StringType}
	// IntegerPointerType represents a pointer to an integer.
	IntegerPointerType TypeNode = &PointerType{Node: IntegerType}

	// StringSliceType represents a slice of string.
	StringSliceType TypeNode = &SliceType{Node: StringType}
)

type WalkNodeFct

type WalkNodeFct func(level int, node FieldNode)

WalkNodeFct is the callback function definition for node visitor WalkNode.

Jump to

Keyboard shortcuts

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