interpreter

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: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExpectingStructFindOthers          = "expecting struct but find %s"
	ExpectingStructInPointerFindOthers = "expecting struct inside pointer but find %s"
	ExpectingArrayInPointerFindOthers  = "expecting array inside pointer but find %s"
	VariableNotFound                   = "variable value for %s not found"
	FieldTypeNotMatchAST               = "field type %s is not of ast collection node type"
	KVKindNotMatch                     = "expect %s as key but value is not :%#v"
	FieldNotValid                      = "field not valid %s"
	FieldNotFound                      = "field with tag %s not found"
)

Variables

View Source
var (
	ErrorInterpreSymbolFailure           = errors.New("have symbol not consumed")
	ErrorInterpretVariable               = errors.New("error when interpret variable values")
	ErrorInternalInterpreterOutdated     = errors.New("interpreter not update as the ast grows")
	ErrorKeyStringVariableNotResolve     = errors.New("find string variable as object key, but the variable value is missing")
	ErrorVariableValueNotJsonValueType   = errors.New("variable value should be json value type")
	ErrorVariableValueNotFound           = errors.New("variable value is not found")
	ErrorInternalGetPrimitiveValue       = errors.New("try to get primitive value from none-primitive type")
	ErrorInternalShouldBeArrayOrSlice    = errors.New("should be array or slice")
	ErrorInternalUnsupportedMapKeyKind   = fmt.Errorf("unsupported map key to continue")
	ErrorInternalMapKeyTypeNotMatchValue = fmt.Errorf("expect bool as key but value is not bool")

	ErrorStringVariableNotResolveOnKeyLocation         = errors.New("object key contain string variable that has no variable value")
	ErrorInternalExpectingPrimitive                    = errors.New("expecting primitive values but find others")
	ErrorInternalPtrToArrayFindNotArray                = errors.New("expecting pointer to array, but underlying object not array")
	ErrorInternalExpectingArrayLikeObject              = errors.New("expecting array like object but find others")
	ErrSliceOrArrayNotInit                             = errors.New("slice/array not init")
	ErrorUnmarshalStackNoKV                            = errors.New("there should not be kv pair in stack")
	ErrorInternalNoneResolvable                        = errors.New("expecting dependendent element to resolve")
	ErrorPrimitiveTypeCannotResolveDependency          = errors.New("pritimive type cannot resolve dependency")
	ErrorNotSupportedASTNode                           = errors.New("not supported ast node")
	ErrorInternalDependentResolverHasOnResolveLocation = errors.New("dependent value has no idex or object key set to resolve")
	ErrorInvalidUnmarshalResult                        = errors.New("invalid unmarshal result")
	ErrorInternalSymbolStackIncorrect                  = errors.New("interpret symbol stack invalid")
)
View Source
var (
	ErrorReflectNotObject     = errors.New("out element is not map nor struct")
	ErrorReflectInvalidMapKey = errors.New("map key type should be string")
	ErrOutNotPointer          = errors.New("out is not pointer")
	ErrOutNotNilPointer       = errors.New("out is nil pointer")
)
View Source
var (
	ErrorUnmarshalNotSlice = errors.New("unmarshal to a non-slice variable")
)

Functions

func InterpretAST added in v0.3.2

func InterpretAST(node ast.JsonNode, variables map[string]interface{}) ([]byte, error)

func NewErrFieldCannotSetOrNotfound added in v0.3.0

func NewErrFieldCannotSetOrNotfound(fieldName string) error

func NewErrorFieldNotFound added in v0.3.1

func NewErrorFieldNotFound(field string) error

func NewErrorFieldNotValid added in v0.3.0

func NewErrorFieldNotValid(field string) error

func NewErrorFiledNotFound added in v0.3.0

func NewErrorFiledNotFound(fieldName string) error

func NewErrorInternalExpectingArrayInsidePointerButFindOthers added in v0.3.0

func NewErrorInternalExpectingArrayInsidePointerButFindOthers(kind string) error

func NewErrorInternalExpectingStructButFindOthers added in v0.3.0

func NewErrorInternalExpectingStructButFindOthers(kind string) error

func NewErrorInternalExpectingStructInsidePointerButFindOthers added in v0.3.0

func NewErrorInternalExpectingStructInsidePointerButFindOthers(kind string) error

func NewErrorInternalFieldTypeNotMatchAST added in v0.3.0

func NewErrorInternalFieldTypeNotMatchAST(kind string) error

func NewErrorInternalMapKeyValueKindNotMatch added in v0.3.0

func NewErrorInternalMapKeyValueKindNotMatch(kind string, value interface{}) error

func NewInterpreter

func NewInterpreter(variables map[string]interface{}) *standardVisitor

func NewPPInterpreter added in v0.3.2

func NewPPInterpreter(variables map[string]interface{}) *prettyPrintVisitor

func NewUnMarshallOptions added in v0.3.0

func NewUnMarshallOptions(variables map[string]interface{}) *unmarshallOptions

func NewVariableNotFound added in v0.3.0

func NewVariableNotFound(variable string) error

func PrettyInterpret added in v0.3.2

func PrettyInterpret(node ast.JsonNode, variables map[string]interface{}) ([]byte, error)

func UnmarshallAST added in v0.3.0

func UnmarshallAST(node ast.JsonNode, variables map[string]interface{}, out interface{}) error

Types

type JsonVisitor

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

Jump to

Keyboard shortcuts

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