ast

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AST_STATE_INIT astState = iota
	AST_STATE_INTERMIDIEATE
	AST_STATE_FINISHED
)

Variables

View Source
var (
	ErrorASTComplete                   = errors.New("cannot create new ast node when the ast has finished")
	ErrorASTStackInvalidElement        = errors.New("ast trace stack will only contain: kv, array, object, no primitive values")
	ErrorASTUnexpectedElement          = errors.New("unexecpted stack element type")
	ErrorASTUnexpectedOwnerElement     = errors.New("unexecpted stack owner element type")
	ErrorASTStackEmpty                 = errors.New("unexecpted stack empty")
	ErrorASTEncloseElementType         = errors.New("enclose element type must be array or object")
	ErrorASTIncorrectNodeType          = errors.New("incorrect node type")
	ErrorASTKeyValuePairNotStringAsKey = errors.New("object key should be string")
)

Functions

This section is empty.

Types

type AST_NODETYPE

type AST_NODETYPE byte
const (
	AST_NODE_TYPE_BOUNDARY AST_NODETYPE = 200
	AST_ARRAY              AST_NODETYPE = 201
	AST_OBJECT             AST_NODETYPE = 202
	AST_KVPAIR             AST_NODETYPE = 203
	AST_VARIABLE           AST_NODETYPE = 204
	AST_STRING_VARIABLE    AST_NODETYPE = 205
	AST_STRING             AST_NODETYPE = 206
	AST_NUMBER             AST_NODETYPE = 207
	AST_BOOLEAN            AST_NODETYPE = 208
	AST_NULL               AST_NODETYPE = 209
	AST_NODE_UNDEFINED     AST_NODETYPE = 210
)

func (AST_NODETYPE) Byte added in v0.3.2

func (a AST_NODETYPE) Byte() byte

type JsonArrayNode

type JsonArrayNode struct {
	Value []JsonNode
}

func (*JsonArrayNode) Append

func (node *JsonArrayNode) Append(n JsonNode)

func (*JsonArrayNode) GetNodeType

func (node *JsonArrayNode) GetNodeType() AST_NODETYPE

func (*JsonArrayNode) Length added in v0.3.0

func (node *JsonArrayNode) Length() int

func (*JsonArrayNode) Visit

func (node *JsonArrayNode) Visit(visitor JsonVisitor) error

type JsonBooleanNode

type JsonBooleanNode struct {
	Value bool
}

func (*JsonBooleanNode) GetNodeType

func (node *JsonBooleanNode) GetNodeType() AST_NODETYPE

func (*JsonBooleanNode) Visit

func (node *JsonBooleanNode) Visit(visitor JsonVisitor) error

type JsonCollectionNode added in v0.3.0

type JsonCollectionNode interface {
	JsonNode
	Length() int
}

type JsonExtendedStringWIthVariableNode

type JsonExtendedStringWIthVariableNode struct {
	JsonStringNode
	Variables map[string][]byte
}

func (*JsonExtendedStringWIthVariableNode) GetNodeType

func (*JsonExtendedStringWIthVariableNode) GetValue added in v0.3.0

func (node *JsonExtendedStringWIthVariableNode) GetValue() string

func (*JsonExtendedStringWIthVariableNode) Visit

type JsonExtendedVariableNode

type JsonExtendedVariableNode struct {
	Value    []byte
	Variable string
}

func (*JsonExtendedVariableNode) GetNodeType

func (node *JsonExtendedVariableNode) GetNodeType() AST_NODETYPE

func (*JsonExtendedVariableNode) Visit

func (node *JsonExtendedVariableNode) Visit(visitor JsonVisitor) error

type JsonKeyValuePairNode

type JsonKeyValuePairNode struct {
	Key   JsonStringValueNode
	Value JsonNode
}

func (*JsonKeyValuePairNode) GetNodeType

func (node *JsonKeyValuePairNode) GetNodeType() AST_NODETYPE

func (*JsonKeyValuePairNode) IsFilled

func (node *JsonKeyValuePairNode) IsFilled() bool

func (*JsonKeyValuePairNode) Visit

func (node *JsonKeyValuePairNode) Visit(visitor JsonVisitor) error

type JsonNode

type JsonNode interface {
	GetNodeType() AST_NODETYPE
	Visit(visitor JsonVisitor) error
}

type JsonNullNode

type JsonNullNode struct {
	Value interface{}
}

func (*JsonNullNode) GetNodeType

func (node *JsonNullNode) GetNodeType() AST_NODETYPE

func (*JsonNullNode) Visit

func (node *JsonNullNode) Visit(visitor JsonVisitor) error

type JsonNumberNode

type JsonNumberNode struct {
	Value float64
}

func (*JsonNumberNode) GetNodeType

func (node *JsonNumberNode) GetNodeType() AST_NODETYPE

func (*JsonNumberNode) Visit

func (node *JsonNumberNode) Visit(visitor JsonVisitor) error

type JsonObjectNode

type JsonObjectNode struct {
	Value []*JsonKeyValuePairNode
}

func (*JsonObjectNode) Append

func (node *JsonObjectNode) Append(kvNode *JsonKeyValuePairNode)

func (*JsonObjectNode) GetNodeType

func (node *JsonObjectNode) GetNodeType() AST_NODETYPE

func (*JsonObjectNode) Length added in v0.3.0

func (node *JsonObjectNode) Length() int

func (*JsonObjectNode) Visit

func (node *JsonObjectNode) Visit(visitor JsonVisitor) error

type JsonStringNode

type JsonStringNode struct {
	Value []byte
}

func (*JsonStringNode) GetNodeType

func (node *JsonStringNode) GetNodeType() AST_NODETYPE

func (*JsonStringNode) GetValue added in v0.3.0

func (node *JsonStringNode) GetValue() string

func (*JsonStringNode) ToArrayNode added in v0.3.0

func (node *JsonStringNode) ToArrayNode() (*JsonArrayNode, error)

func (*JsonStringNode) Visit

func (node *JsonStringNode) Visit(visitor JsonVisitor) error

type JsonStringValueNode added in v0.3.0

type JsonStringValueNode interface {
	JsonNode
	GetValue() string
}

type JsonVisitor

type JsonVisitor interface {
	VisitStringNode(node *JsonStringNode) error
	VisitNumberNode(node *JsonNumberNode) error
	VisitBooleanNode(node *JsonBooleanNode) error
	VisitNullNode(node *JsonNullNode) error
	VisitArrayNode(node *JsonArrayNode) error
	VisitKeyValuePairNode(node *JsonKeyValuePairNode) error
	VisitObjectNode(node *JsonObjectNode) error
	VisitVariableNode(node *JsonExtendedVariableNode) error
	VisitStringWithVariableNode(node *JsonExtendedStringWIthVariableNode) error
}

type JsonextAST added in v0.3.2

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

func NewJsonextAST added in v0.3.2

func NewJsonextAST() *JsonextAST

func (*JsonextAST) CreateNewASTNode added in v0.3.2

func (i *JsonextAST) CreateNewASTNode(t AST_NODETYPE, value interface{}) error

func (*JsonextAST) CreateNewNodeForArrayObject added in v0.3.2

func (i *JsonextAST) CreateNewNodeForArrayObject(owner *JsonArrayNode, t AST_NODETYPE, value interface{}) error

func (*JsonextAST) CreateNewNodeForObject added in v0.3.2

func (i *JsonextAST) CreateNewNodeForObject(owner *JsonObjectNode, t AST_NODETYPE, value interface{}) error

func (*JsonextAST) CreateRootNode added in v0.3.2

func (i *JsonextAST) CreateRootNode(t AST_NODETYPE, value interface{}) error

func (*JsonextAST) CreateValueNodeForKVPairs added in v0.3.2

func (i *JsonextAST) CreateValueNodeForKVPairs(owner *JsonKeyValuePairNode, t AST_NODETYPE, value interface{}) error

func (*JsonextAST) EncloseLatestElements added in v0.3.2

func (i *JsonextAST) EncloseLatestElements(currentOffset int) error

func (*JsonextAST) FinlizeKVPair added in v0.3.2

func (i *JsonextAST) FinlizeKVPair() error

2 reason to finalise, enclose of kv pair due to `,`, enclose of kv pair due to `}` {"1":2,"3":4}

func (*JsonextAST) GetAST added in v0.3.2

func (i *JsonextAST) GetAST() JsonNode

func (*JsonextAST) HasComplete added in v0.3.2

func (i *JsonextAST) HasComplete() bool

func (*JsonextAST) HasOpenElement added in v0.3.2

func (i *JsonextAST) HasOpenElement() bool

func (*JsonextAST) StoreFinlizedItemToOwner added in v0.3.2

func (i *JsonextAST) StoreFinlizedItemToOwner(itemToFinalize JsonNode, currentOffset int) error

func (*JsonextAST) TopElementType added in v0.3.2

func (i *JsonextAST) TopElementType() (AST_NODETYPE, error)

Jump to

Keyboard shortcuts

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