ast

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KW_And    = "AND"
	KW_Or     = "OR"
	KW_True   = "TRUE"
	KW_False  = "FALSE"
	KW_Var    = "var"
	KW_DBRP   = "dbrp"
	KW_Lambda = "lambda"
)
View Source
const NodeTypeOf = "typeOf"

NodeTypeOf is used by all Node to identify the node duration Marshal and Unmarshal

Variables

View Source
var MissingValue = &Missing{}

Functions

func FindFunctionCalls added in v1.3.0

func FindFunctionCalls(nodes ...Node) []string

FindFunctionCalls walks all nodes and returns a list of name of function calls.

func FindReferenceVariables added in v1.3.0

func FindReferenceVariables(nodes ...Node) []string

FindReferenceVariables walks all nodes and returns a list of name from reference variables.

func Format added in v1.3.0

func Format(n Node) string

func IsCompOperator

func IsCompOperator(typ TokenType) bool

True if token type is an operator used in comparisons.

func IsExprOperator

func IsExprOperator(typ TokenType) bool

True if token type is an operator used in mathematical or boolean expressions.

func IsLogicalOperator

func IsLogicalOperator(typ TokenType) bool

func IsMathOperator

func IsMathOperator(typ TokenType) bool

True if token type is an operator used in mathematical expressions.

func ZeroValue

func ZeroValue(t ValueType) interface{}

Types

type BinaryNode

type BinaryNode struct {
	Left      Node
	Right     Node
	Operator  TokenType
	Comment   *CommentNode
	Parens    bool
	MultiLine bool
	// contains filtered or unexported fields
}

binaryNode holds two arguments and an operator.

func (BinaryNode) Char

func (p BinaryNode) Char() int

func (*BinaryNode) Equal

func (n *BinaryNode) Equal(o interface{}) bool

func (*BinaryNode) Format

func (n *BinaryNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (BinaryNode) Line

func (p BinaryNode) Line() int

func (*BinaryNode) MarshalJSON added in v1.4.0

func (n *BinaryNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (BinaryNode) Position

func (p BinaryNode) Position() int

func (*BinaryNode) SetComment

func (n *BinaryNode) SetComment(c *CommentNode)

func (*BinaryNode) String

func (n *BinaryNode) String() string

func (*BinaryNode) UnmarshalJSON added in v1.4.0

func (n *BinaryNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a BinaryNode

type BoolNode

type BoolNode struct {
	Bool    bool
	Comment *CommentNode
	// contains filtered or unexported fields
}

boolNode holds one argument and an operator.

func (BoolNode) Char

func (p BoolNode) Char() int

func (*BoolNode) Equal

func (n *BoolNode) Equal(o interface{}) bool

func (*BoolNode) Format

func (n *BoolNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (BoolNode) Line

func (p BoolNode) Line() int

func (*BoolNode) MarshalJSON added in v1.4.0

func (n *BoolNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (BoolNode) Position

func (p BoolNode) Position() int

func (*BoolNode) SetComment

func (n *BoolNode) SetComment(c *CommentNode)

func (*BoolNode) String

func (n *BoolNode) String() string

func (*BoolNode) UnmarshalJSON added in v1.4.0

func (n *BoolNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a BoolNode

type ChainNode

type ChainNode struct {
	Left     Node
	Right    Node
	Operator TokenType
	Comment  *CommentNode
	// contains filtered or unexported fields
}

func (ChainNode) Char

func (p ChainNode) Char() int

func (*ChainNode) Equal

func (n *ChainNode) Equal(o interface{}) bool

func (*ChainNode) Format

func (n *ChainNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (ChainNode) Line

func (p ChainNode) Line() int

func (*ChainNode) MarshalJSON added in v1.4.0

func (n *ChainNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (ChainNode) Position

func (p ChainNode) Position() int

func (*ChainNode) SetComment

func (n *ChainNode) SetComment(c *CommentNode)

func (*ChainNode) String

func (n *ChainNode) String() string

func (*ChainNode) TypeOf added in v1.4.0

func (n *ChainNode) TypeOf() string

TypeOf returns the unique name for this type of node

func (*ChainNode) UnmarshalJSON added in v1.4.0

func (n *ChainNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a ChainNode

type CommentNode

type CommentNode struct {
	Comments []string
	// contains filtered or unexported fields
}

Hold the contents of a comment

func (CommentNode) Char

func (p CommentNode) Char() int

func (*CommentNode) CommentString

func (n *CommentNode) CommentString() string

func (*CommentNode) Equal

func (n *CommentNode) Equal(o interface{}) bool

func (*CommentNode) Format

func (n *CommentNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (CommentNode) Line

func (p CommentNode) Line() int

func (*CommentNode) MarshalJSON added in v1.4.0

func (n *CommentNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (CommentNode) Position

func (p CommentNode) Position() int

func (*CommentNode) String

func (n *CommentNode) String() string

func (*CommentNode) UnmarshalJSON added in v1.4.0

func (n *CommentNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a CommentNode

type DBRPNode added in v1.4.0

type DBRPNode struct {
	Comment *CommentNode
	DB      *ReferenceNode
	RP      *ReferenceNode
	// contains filtered or unexported fields
}

func (DBRPNode) Char added in v1.4.0

func (p DBRPNode) Char() int

func (*DBRPNode) DBRP added in v1.4.0

func (d *DBRPNode) DBRP() string

func (*DBRPNode) Equal added in v1.4.0

func (d *DBRPNode) Equal(o interface{}) bool

func (*DBRPNode) Format added in v1.4.0

func (s *DBRPNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (DBRPNode) Line added in v1.4.0

func (p DBRPNode) Line() int

func (*DBRPNode) MarshalJSON added in v1.4.0

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

MarshalJSON converts the node to JSON with an additional typeOf field.

func (DBRPNode) Position added in v1.4.0

func (p DBRPNode) Position() int

func (*DBRPNode) String added in v1.4.0

func (n *DBRPNode) String() string

func (*DBRPNode) UnmarshalJSON added in v1.4.0

func (d *DBRPNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a DBRPNode

type DeclarationNode

type DeclarationNode struct {
	Left    *IdentifierNode
	Right   Node
	Comment *CommentNode
	// contains filtered or unexported fields
}

func (DeclarationNode) Char

func (p DeclarationNode) Char() int

func (*DeclarationNode) Equal

func (n *DeclarationNode) Equal(o interface{}) bool

func (*DeclarationNode) Format

func (n *DeclarationNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (DeclarationNode) Line

func (p DeclarationNode) Line() int

func (*DeclarationNode) MarshalJSON added in v1.4.0

func (n *DeclarationNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (DeclarationNode) Position

func (p DeclarationNode) Position() int

func (*DeclarationNode) SetComment

func (n *DeclarationNode) SetComment(c *CommentNode)

func (*DeclarationNode) String

func (n *DeclarationNode) String() string

func (*DeclarationNode) UnmarshalJSON added in v1.4.0

func (n *DeclarationNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a DeclarationNode

type DurationNode

type DurationNode struct {
	Dur     time.Duration //the duration
	Literal string
	Comment *CommentNode
	// contains filtered or unexported fields
}

durationNode holds a number: signed or unsigned integer or float. The value is parsed and stored under all the types that can represent the value. This simulates in a small amount of code the behavior of Go's ideal constants.

func (DurationNode) Char

func (p DurationNode) Char() int

func (*DurationNode) Equal

func (n *DurationNode) Equal(o interface{}) bool

func (*DurationNode) Format

func (n *DurationNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (DurationNode) Line

func (p DurationNode) Line() int

func (*DurationNode) MarshalJSON added in v1.4.0

func (n *DurationNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (DurationNode) Position

func (p DurationNode) Position() int

func (*DurationNode) SetComment

func (n *DurationNode) SetComment(c *CommentNode)

func (*DurationNode) String

func (n *DurationNode) String() string

func (*DurationNode) UnmarshalJSON added in v1.4.0

func (n *DurationNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a DurationNode.

type FuncType

type FuncType int
const (
	GlobalFunc FuncType = iota
	ChainFunc
	PropertyFunc
	DynamicFunc
)

func NewFuncType added in v1.4.0

func NewFuncType(typ string) (FuncType, error)

func (FuncType) String

func (ft FuncType) String() string

type FunctionNode

type FunctionNode struct {
	Type      FuncType
	Func      string // The identifier
	Args      []Node
	Comment   *CommentNode
	MultiLine bool
	// contains filtered or unexported fields
}

Holds the a function call with its args

func (FunctionNode) Char

func (p FunctionNode) Char() int

func (*FunctionNode) Equal

func (n *FunctionNode) Equal(o interface{}) bool

func (*FunctionNode) Format

func (n *FunctionNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (FunctionNode) Line

func (p FunctionNode) Line() int

func (*FunctionNode) MarshalJSON added in v1.4.0

func (n *FunctionNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (FunctionNode) Position

func (p FunctionNode) Position() int

func (*FunctionNode) SetComment

func (n *FunctionNode) SetComment(c *CommentNode)

func (*FunctionNode) String

func (n *FunctionNode) String() string

func (*FunctionNode) UnmarshalJSON added in v1.4.0

func (n *FunctionNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a FunctionNode

type IdentifierNode

type IdentifierNode struct {
	Ident   string // The identifier
	Comment *CommentNode
	// contains filtered or unexported fields
}

Holds the textual representation of an identifier

func (IdentifierNode) Char

func (p IdentifierNode) Char() int

func (*IdentifierNode) Equal

func (n *IdentifierNode) Equal(o interface{}) bool

func (*IdentifierNode) Format

func (n *IdentifierNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (IdentifierNode) Line

func (p IdentifierNode) Line() int

func (*IdentifierNode) MarshalJSON added in v1.4.0

func (n *IdentifierNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (IdentifierNode) Position

func (p IdentifierNode) Position() int

func (*IdentifierNode) SetComment

func (n *IdentifierNode) SetComment(c *CommentNode)

func (*IdentifierNode) String

func (n *IdentifierNode) String() string

func (*IdentifierNode) UnmarshalJSON added in v1.4.0

func (n *IdentifierNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a IdentifierNode

type JSONNode added in v1.4.0

type JSONNode map[string]interface{}

JSONNode is the intermediate type between Node and JSON serialization

func (JSONNode) Bool added in v1.4.0

func (j JSONNode) Bool(field string) (bool, error)

Bool reads the field for a boolean value

func (JSONNode) CheckTypeOf added in v1.4.0

func (j JSONNode) CheckTypeOf(typ string) error

CheckTypeOf tests that the typeOf field is correctly set to typ.

func (JSONNode) Duration added in v1.4.0

func (j JSONNode) Duration(field string) (time.Duration, error)

Duration reads the field and assumes the string is in InfluxQL Duration format.

func (JSONNode) Field added in v1.4.0

func (j JSONNode) Field(field string) (interface{}, error)

Field returns expected field or error if field doesn't exist

func (JSONNode) Float64 added in v1.4.0

func (j JSONNode) Float64(field string) (float64, error)

Float64 reads the field for a float64 value

func (JSONNode) FunctionType added in v1.4.0

func (j JSONNode) FunctionType(field string) (FuncType, error)

FunctionType reads the field for an FuncType value

func (JSONNode) Has added in v1.4.0

func (j JSONNode) Has(field string) bool

Has returns true if field exists

func (JSONNode) IDNode added in v1.4.0

func (j JSONNode) IDNode(field string) (*IdentifierNode, error)

IDNode reads an IdentifierNode from the field

func (JSONNode) Int64 added in v1.4.0

func (j JSONNode) Int64(field string) (int64, error)

Int64 reads the field for a int64 value

func (JSONNode) Node added in v1.4.0

func (j JSONNode) Node(field string) (Node, error)

Node reads the field for a node

func (JSONNode) NodeList added in v1.4.0

func (j JSONNode) NodeList(field string) ([]Node, error)

NodeList reads the field for a list of nodes

func (JSONNode) Operator added in v1.4.0

func (j JSONNode) Operator(field string) (TokenType, error)

Operator reads the field for an TokenType operator value

func (JSONNode) RefNode added in v1.4.0

func (j JSONNode) RefNode(field string) (*ReferenceNode, error)

RefNode reads a ReferenceNode from the field

func (JSONNode) Regex added in v1.4.0

func (j JSONNode) Regex(field string) (*regexp.Regexp, error)

Regex reads the field and assumes the string is a regular expression.

func (JSONNode) Set added in v1.4.0

func (j JSONNode) Set(key string, value interface{}) JSONNode

Set adds the key/value to the JSONNode

func (JSONNode) SetDuration added in v1.4.0

func (j JSONNode) SetDuration(key string, value time.Duration) JSONNode

SetDuration adds key to the JSONNode but formats the duration in InfluxQL style

func (JSONNode) SetFunctionType added in v1.4.0

func (j JSONNode) SetFunctionType(key string, fn FuncType) JSONNode

SetFunctionType adds key to JSONNode but formats the function type as a string

func (JSONNode) SetOperator added in v1.4.0

func (j JSONNode) SetOperator(key string, op TokenType) JSONNode

SetOperator adds key to JSONNode but formats the operator as a string

func (JSONNode) SetRegex added in v1.4.0

func (j JSONNode) SetRegex(key string, value *regexp.Regexp) JSONNode

SetRegex adds key to the JSONNode but formats the regex as a string

func (JSONNode) String added in v1.4.0

func (j JSONNode) String(field string) (string, error)

String reads the field for a string value

func (JSONNode) Strings added in v1.4.0

func (j JSONNode) Strings(field string) ([]string, error)

Strings reads the field an array of strings

func (JSONNode) Type added in v1.4.0

func (j JSONNode) Type(typ string) JSONNode

Type adds the Node type information

func (JSONNode) TypeOf added in v1.4.0

func (j JSONNode) TypeOf() (string, error)

TypeOf returns the type of the node

type LambdaNode

type LambdaNode struct {
	Expression Node
	Comment    *CommentNode
	// contains filtered or unexported fields
}

Represents the beginning of a lambda expression

func ParseLambda

func ParseLambda(text string) (*LambdaNode, error)

Parse returns a LambdaNode, created by parsing a lambda expression.

func (LambdaNode) Char

func (p LambdaNode) Char() int

func (*LambdaNode) Equal

func (n *LambdaNode) Equal(o interface{}) bool

func (*LambdaNode) ExpressionString

func (n *LambdaNode) ExpressionString() string

func (*LambdaNode) Format

func (n *LambdaNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (LambdaNode) Line

func (p LambdaNode) Line() int

func (*LambdaNode) MarshalJSON added in v1.4.0

func (n *LambdaNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (LambdaNode) Position

func (p LambdaNode) Position() int

func (*LambdaNode) SetComment

func (n *LambdaNode) SetComment(c *CommentNode)

func (*LambdaNode) String

func (n *LambdaNode) String() string

func (*LambdaNode) Unmarshal added in v1.4.0

func (n *LambdaNode) Unmarshal(props map[string]interface{}) error

Unmarshal deserializes the props map into this LambdaNode

func (*LambdaNode) UnmarshalJSON added in v1.4.0

func (n *LambdaNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a LambdaNode

type ListNode

type ListNode struct {
	Nodes   []Node
	Comment *CommentNode
	// contains filtered or unexported fields
}

Holds the list of other nodes

func (ListNode) Char

func (p ListNode) Char() int

func (*ListNode) Equal

func (n *ListNode) Equal(o interface{}) bool

func (*ListNode) Format

func (n *ListNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (ListNode) Line

func (p ListNode) Line() int

func (*ListNode) MarshalJSON added in v1.4.0

func (n *ListNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (ListNode) Position

func (p ListNode) Position() int

func (*ListNode) SetComment

func (n *ListNode) SetComment(c *CommentNode)

func (*ListNode) String

func (n *ListNode) String() string

func (*ListNode) UnmarshalJSON added in v1.4.0

func (n *ListNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a ListNode

type Missing added in v1.3.0

type Missing struct{}

type Node

type Node interface {
	Position
	String() string
	Format(buf *bytes.Buffer, indent string, onNewLine bool)
	// Report whether to nodes are functionally equal, ignoring position and comments
	Equal(interface{}) bool

	json.Marshaler
	json.Unmarshaler
	// contains filtered or unexported methods
}

func Parse

func Parse(text string) (Node, error)

Parse returns a Node, created by parsing the DSL described in the argument string. If an error is encountered, parsing stops and a nil Node is returned with the error.

func ValueToLiteralNode

func ValueToLiteralNode(pos Position, v interface{}) (Node, error)

Convert raw value to literal node, for all supported basic types.

func Walk added in v1.3.0

func Walk(root Node, f func(n Node) (Node, error)) (Node, error)

Walk calls f on all nodes reachable from the root node. The node returned will replace the node provided within the AST. Returning an error from f will stop the walking process and f will not be called on any other nodes.

type NumberNode

type NumberNode struct {
	IsInt   bool    // Number has an integral value.
	IsFloat bool    // Number has a floating-point value.
	Int64   int64   // The integer value.
	Float64 float64 // The floating-point value.
	Base    int     // The base of an integer value.
	Comment *CommentNode
	// contains filtered or unexported fields
}

numberNode holds a number: signed or unsigned integer or float. The value is parsed and stored under all the types that can represent the value. This simulates in a small amount of code the behavior of Go's ideal constants.

func (NumberNode) Char

func (p NumberNode) Char() int

func (*NumberNode) Equal

func (n *NumberNode) Equal(o interface{}) bool

func (*NumberNode) Format

func (n *NumberNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (NumberNode) Line

func (p NumberNode) Line() int

func (*NumberNode) MarshalJSON added in v1.4.0

func (n *NumberNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (NumberNode) Position

func (p NumberNode) Position() int

func (*NumberNode) SetComment

func (n *NumberNode) SetComment(c *CommentNode)

func (*NumberNode) String

func (n *NumberNode) String() string

func (*NumberNode) UnmarshalJSON added in v1.4.0

func (n *NumberNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a Number node.

type Position

type Position interface {
	Position() int // byte position of start of node in full original input string
	Line() int
	Char() int
}

type ProgramNode

type ProgramNode struct {
	Nodes []Node
	// contains filtered or unexported fields
}

Holds a function call with its args

func (*ProgramNode) Add

func (n *ProgramNode) Add(node Node)

func (ProgramNode) Char

func (p ProgramNode) Char() int

func (*ProgramNode) Equal

func (n *ProgramNode) Equal(o interface{}) bool

func (*ProgramNode) Format

func (n *ProgramNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (ProgramNode) Line

func (p ProgramNode) Line() int

func (*ProgramNode) MarshalJSON added in v1.4.0

func (n *ProgramNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (ProgramNode) Position

func (p ProgramNode) Position() int

func (*ProgramNode) String

func (n *ProgramNode) String() string

func (*ProgramNode) UnmarshalJSON added in v1.4.0

func (n *ProgramNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a ProgramNode

type ReferenceNode

type ReferenceNode struct {
	Reference string // The field reference
	Comment   *CommentNode
	// contains filtered or unexported fields
}

Holds the textual representation of an identifier

func (ReferenceNode) Char

func (p ReferenceNode) Char() int

func (*ReferenceNode) Equal

func (n *ReferenceNode) Equal(o interface{}) bool

func (*ReferenceNode) Format

func (n *ReferenceNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (ReferenceNode) Line

func (p ReferenceNode) Line() int

func (*ReferenceNode) MarshalJSON added in v1.4.0

func (n *ReferenceNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (ReferenceNode) Position

func (p ReferenceNode) Position() int

func (*ReferenceNode) SetComment

func (n *ReferenceNode) SetComment(c *CommentNode)

func (*ReferenceNode) String

func (n *ReferenceNode) String() string

func (*ReferenceNode) UnmarshalJSON added in v1.4.0

func (n *ReferenceNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a ReferenceNode

type RegexNode

type RegexNode struct {
	Regex   *regexp.Regexp
	Literal string
	Comment *CommentNode
	// contains filtered or unexported fields
}

Holds the textual representation of a regex literal

func (RegexNode) Char

func (p RegexNode) Char() int

func (*RegexNode) Equal

func (n *RegexNode) Equal(o interface{}) bool

func (*RegexNode) Format

func (n *RegexNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (RegexNode) Line

func (p RegexNode) Line() int

func (*RegexNode) MarshalJSON added in v1.4.0

func (n *RegexNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (RegexNode) Position

func (p RegexNode) Position() int

func (*RegexNode) SetComment

func (n *RegexNode) SetComment(c *CommentNode)

func (*RegexNode) String

func (n *RegexNode) String() string

func (*RegexNode) UnmarshalJSON added in v1.4.0

func (n *RegexNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a RegexNode

type StarNode

type StarNode struct {
	Comment *CommentNode
	// contains filtered or unexported fields
}

Represents a standalone '*' token.

func (StarNode) Char

func (p StarNode) Char() int

func (*StarNode) Equal

func (n *StarNode) Equal(o interface{}) bool

func (*StarNode) Format

func (n *StarNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (StarNode) Line

func (p StarNode) Line() int

func (*StarNode) MarshalJSON added in v1.4.0

func (n *StarNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (StarNode) Position

func (p StarNode) Position() int

func (*StarNode) SetComment

func (n *StarNode) SetComment(c *CommentNode)

func (*StarNode) String

func (n *StarNode) String() string

func (*StarNode) UnmarshalJSON added in v1.4.0

func (n *StarNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a StarNode

type StringNode

type StringNode struct {
	Literal      string // The string literal
	TripleQuotes bool
	Comment      *CommentNode
	// contains filtered or unexported fields
}

Holds the textual representation of a string literal

func (StringNode) Char

func (p StringNode) Char() int

func (*StringNode) Equal

func (n *StringNode) Equal(o interface{}) bool

func (*StringNode) Format

func (n *StringNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (StringNode) Line

func (p StringNode) Line() int

func (*StringNode) MarshalJSON added in v1.4.0

func (n *StringNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (StringNode) Position

func (p StringNode) Position() int

func (*StringNode) SetComment

func (n *StringNode) SetComment(c *CommentNode)

func (*StringNode) String

func (n *StringNode) String() string

func (*StringNode) UnmarshalJSON added in v1.4.0

func (n *StringNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a StringNode

type TokenType

type TokenType int
const (
	TokenError TokenType = iota
	TokenEOF
	TokenVar
	TokenDBRP
	TokenAsgn
	TokenDot
	TokenPipe
	TokenAt
	TokenIdent
	TokenReference
	TokenLambda
	TokenNumber
	TokenString
	TokenDuration
	TokenLParen
	TokenRParen
	TokenLSBracket
	TokenRSBracket
	TokenComma
	TokenNot
	TokenTrue
	TokenFalse
	TokenRegex
	TokenComment
	TokenStar

	TokenPlus
	TokenMinus
	TokenMult
	TokenDiv
	TokenMod

	TokenAnd
	TokenOr

	TokenEqual
	TokenNotEqual
	TokenLess
	TokenGreater
	TokenLessEqual
	TokenGreaterEqual
	TokenRegexEqual
	TokenRegexNotEqual
)

func NewTokenType added in v1.4.0

func NewTokenType(token string) (TokenType, error)

NewTokenType converts string to TokenType

func (TokenType) String

func (t TokenType) String() string

String representation of an TokenType

type TypeDeclarationNode

type TypeDeclarationNode struct {
	Node    *IdentifierNode
	Type    *IdentifierNode
	Comment *CommentNode
	// contains filtered or unexported fields
}

func (TypeDeclarationNode) Char

func (p TypeDeclarationNode) Char() int

func (*TypeDeclarationNode) Equal

func (n *TypeDeclarationNode) Equal(o interface{}) bool

func (*TypeDeclarationNode) Format

func (n *TypeDeclarationNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (TypeDeclarationNode) Line

func (p TypeDeclarationNode) Line() int

func (*TypeDeclarationNode) MarshalJSON added in v1.4.0

func (n *TypeDeclarationNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (TypeDeclarationNode) Position

func (p TypeDeclarationNode) Position() int

func (*TypeDeclarationNode) SetComment

func (n *TypeDeclarationNode) SetComment(c *CommentNode)

func (*TypeDeclarationNode) String

func (n *TypeDeclarationNode) String() string

func (*TypeDeclarationNode) UnmarshalJSON added in v1.4.0

func (n *TypeDeclarationNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a TypeDeclarationNode

type UnaryNode

type UnaryNode struct {
	Node     Node
	Operator TokenType
	Comment  *CommentNode
	// contains filtered or unexported fields
}

unaryNode holds one argument and an operator.

func (UnaryNode) Char

func (p UnaryNode) Char() int

func (*UnaryNode) Equal

func (n *UnaryNode) Equal(o interface{}) bool

func (*UnaryNode) Format

func (n *UnaryNode) Format(buf *bytes.Buffer, indent string, onNewLine bool)

func (UnaryNode) Line

func (p UnaryNode) Line() int

func (*UnaryNode) MarshalJSON added in v1.4.0

func (n *UnaryNode) MarshalJSON() ([]byte, error)

MarshalJSON converts the node to JSON with an additional typeOf field.

func (UnaryNode) Position

func (p UnaryNode) Position() int

func (*UnaryNode) SetComment

func (n *UnaryNode) SetComment(c *CommentNode)

func (*UnaryNode) String

func (n *UnaryNode) String() string

func (*UnaryNode) UnmarshalJSON added in v1.4.0

func (n *UnaryNode) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON bytes to a UnaryNode

type ValueType

type ValueType uint8
const (
	InvalidType ValueType = iota
	TFloat
	TInt
	TString
	TBool
	TRegex
	TTime
	TDuration
	TLambda
	TList
	TStar
	TMissing
)

func TypeOf

func TypeOf(v interface{}) ValueType

func (ValueType) String

func (v ValueType) String() string

Jump to

Keyboard shortcuts

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