Documentation ¶
Overview ¶
Package ast declares the types used to represent the syntax tree for Flux source code.
Index ¶
- Constants
- Variables
- func BooleanFromLiteral(lit *BooleanLiteral) bool
- func Check(root Node) int
- func DateTimeFromLiteral(lit *DateTimeLiteral) time.Time
- func DurationFrom(l *DurationLiteral, _ time.Time) (time.Duration, error)
- func FloatFromLiteral(lit *FloatLiteral) float64
- func Format(n Node) string
- func GetError(n Node) error
- func GetErrors(n Node) (errs []error)
- func IntegerFromLiteral(lit *IntegerLiteral) int64
- func PrintErrors(w io.Writer, root Node)
- func RegexpFromLiteral(lit *RegexpLiteral) *regexp.Regexp
- func StringFromLiteral(lit *StringLiteral) string
- func UnsignedIntegerFromLiteral(lit *UnsignedIntegerLiteral) uint64
- func Visit(node Node, f func(Node))
- func Walk(v Visitor, node Node)
- type ArrayExpression
- type ArrayType
- type Assignment
- type BadStatement
- type BaseNode
- type BinaryExpression
- type Block
- type BooleanLiteral
- type BuiltinStatement
- type CallExpression
- type ConditionalExpression
- func (e *ConditionalExpression) Copy() Node
- func (e ConditionalExpression) FromBuf(buf *fbast.ConditionalExpression) *ConditionalExpression
- func (e *ConditionalExpression) MarshalJSON() ([]byte, error)
- func (*ConditionalExpression) Type() string
- func (e *ConditionalExpression) UnmarshalJSON(data []byte) error
- type DateTimeLiteral
- type DictExpression
- type DictItem
- type DictType
- type Duration
- type DurationLiteral
- type Error
- type Expression
- type ExpressionStatement
- type File
- type FloatLiteral
- type FunctionExpression
- type FunctionType
- type Identifier
- type ImportDeclaration
- type IndexExpression
- type IntegerLiteral
- type InterpolatedPart
- type Literal
- type LogicalExpression
- type LogicalOperatorKind
- type MemberAssignment
- type MemberExpression
- type MonoType
- type NamedType
- type Node
- type ObjectExpression
- type OperatorKind
- type OptionStatement
- type Package
- type PackageClause
- type ParameterKind
- type ParameterType
- type ParenExpression
- type PipeExpression
- type PipeLiteral
- type Position
- type Property
- type PropertyKey
- type PropertyType
- type RecordType
- type RegexpLiteral
- type ReturnStatement
- type SourceLocation
- type Statement
- type StringExpression
- type StringExpressionPart
- type StringLiteral
- type TestCaseStatement
- type TestStatement
- type TextPart
- type TvarType
- type TypeConstraint
- type TypeExpression
- type UnaryExpression
- type UnsignedIntegerLiteral
- func (l *UnsignedIntegerLiteral) Copy() Node
- func (l UnsignedIntegerLiteral) FromBuf(buf *fbast.UnsignedIntegerLiteral) *UnsignedIntegerLiteral
- func (l *UnsignedIntegerLiteral) MarshalJSON() ([]byte, error)
- func (*UnsignedIntegerLiteral) Type() string
- func (l *UnsignedIntegerLiteral) UnmarshalJSON(data []byte) error
- type VariableAssignment
- type Visitor
Constants ¶
const ( NanosecondUnit = "ns" MicrosecondUnit = "us" MillisecondUnit = "ms" SecondUnit = "s" MinuteUnit = "m" HourUnit = "h" DayUnit = "d" WeekUnit = "w" MonthUnit = "mo" YearUnit = "y" )
Variables ¶
var LogicalOperatorTokens = map[LogicalOperatorKind]string{ AndOperator: "and", OrOperator: "or", }
LogicalOperatorTokens converts LogicalOperatorKind to string
var OperatorTokens = map[OperatorKind]string{ MultiplicationOperator: "*", DivisionOperator: "/", ModuloOperator: "%", PowerOperator: "^", AdditionOperator: "+", SubtractionOperator: "-", LessThanEqualOperator: "<=", LessThanOperator: "<", GreaterThanOperator: ">", GreaterThanEqualOperator: ">=", InOperator: "in", NotOperator: "not", ExistsOperator: "exists", NotEmptyOperator: "not empty", EmptyOperator: "empty", StartsWithOperator: "startswith", EqualOperator: "==", NotEqualOperator: "!=", RegexpMatchOperator: "=~", NotRegexpMatchOperator: "!~", }
OperatorTokens converts OperatorKind to string
Functions ¶
func BooleanFromLiteral ¶ added in v0.75.0
func BooleanFromLiteral(lit *BooleanLiteral) bool
func Check ¶ added in v0.13.0
Check will inspect each node and annotate it with any AST errors. It will return the number of errors that were found.
func DateTimeFromLiteral ¶ added in v0.75.0
func DateTimeFromLiteral(lit *DateTimeLiteral) time.Time
func DurationFrom ¶ added in v0.21.0
Duration gives you a DurationLiteral from a time.Duration. Currently this is an approximation, but since we accept time, it can be made exact. TODO: makes this exact and not an approximation. currently the time.Time is ignored
func FloatFromLiteral ¶ added in v0.75.0
func FloatFromLiteral(lit *FloatLiteral) float64
func Format ¶ added in v0.8.0
Returns a valid script for a given AST rooted at node `n`. Formatting rules:
- In a list of statements, if two statements are of a different type (e.g. an `OptionStatement` followed by an `ExpressionStatement`), they are separated by a double newline.
- In a function call (or object definition), if the arguments (or properties) are more than 3, they are split into multiple lines.
func IntegerFromLiteral ¶ added in v0.75.0
func IntegerFromLiteral(lit *IntegerLiteral) int64
func PrintErrors ¶ added in v0.13.0
PrintErrors will format the errors within the AST and output them to the writer.
func RegexpFromLiteral ¶ added in v0.75.0
func RegexpFromLiteral(lit *RegexpLiteral) *regexp.Regexp
func StringFromLiteral ¶ added in v0.75.0
func StringFromLiteral(lit *StringLiteral) string
func UnsignedIntegerFromLiteral ¶ added in v0.75.0
func UnsignedIntegerFromLiteral(lit *UnsignedIntegerLiteral) uint64
func Walk ¶ added in v0.8.0
Walk recursively visits every children of a given `Node` given a `Visitor`. It performs a pre-order visit of the AST (visit parent node, then visit children from left to right). If a call to `Visit` for a node returns a nil visitor, walk stops and doesn't visit the AST rooted at that node, otherwise it uses the returned visitor to continue walking. Once Walk has finished visiting a node (the node itself and its children), it invokes `Done` on the node's visitor. NOTE: `Walk` doesn't visit `nil` nodes.
Types ¶
type ArrayExpression ¶
type ArrayExpression struct { BaseNode Elements []Expression `json:"elements"` }
ArrayExpression is used to create and directly specify the elements of an array object
func (*ArrayExpression) Copy ¶
func (e *ArrayExpression) Copy() Node
func (ArrayExpression) FromBuf ¶ added in v0.55.0
func (e ArrayExpression) FromBuf(buf *fbast.ArrayExpression) *ArrayExpression
func (*ArrayExpression) MarshalJSON ¶
func (e *ArrayExpression) MarshalJSON() ([]byte, error)
func (*ArrayExpression) UnmarshalJSON ¶
func (e *ArrayExpression) UnmarshalJSON(data []byte) error
type ArrayType ¶ added in v0.77.1
func (ArrayType) MarshalJSON ¶ added in v0.81.0
func (*ArrayType) UnmarshalJSON ¶ added in v0.81.0
type Assignment ¶ added in v0.14.0
type Assignment interface { Statement // contains filtered or unexported methods }
type BadStatement ¶ added in v0.13.0
BadStatement is a placeholder for statements for which no correct statement nodes can be created.
func (*BadStatement) Copy ¶ added in v0.13.0
func (s *BadStatement) Copy() Node
func (BadStatement) FromBuf ¶ added in v0.55.0
func (s BadStatement) FromBuf(buf *fbast.BadStatement) *BadStatement
func (*BadStatement) MarshalJSON ¶ added in v0.13.0
func (s *BadStatement) MarshalJSON() ([]byte, error)
func (*BadStatement) Type ¶ added in v0.13.0
func (*BadStatement) Type() string
Type is the abstract type.
type BaseNode ¶
type BaseNode struct { Loc *SourceLocation `json:"location,omitempty"` Errors []Error `json:"errors,omitempty"` }
BaseNode holds the attributes every expression or statement should have
func (BaseNode) Location ¶
func (b BaseNode) Location() SourceLocation
Location is the source location of the Node
type BinaryExpression ¶
type BinaryExpression struct { BaseNode Operator OperatorKind `json:"operator"` Left Expression `json:"left"` Right Expression `json:"right"` }
BinaryExpression use binary operators act on two operands in an expression. BinaryExpression includes relational and arithmetic operators
func (*BinaryExpression) Copy ¶
func (e *BinaryExpression) Copy() Node
func (BinaryExpression) FromBuf ¶ added in v0.55.0
func (e BinaryExpression) FromBuf(buf *fbast.BinaryExpression) *BinaryExpression
func (*BinaryExpression) MarshalJSON ¶
func (e *BinaryExpression) MarshalJSON() ([]byte, error)
func (*BinaryExpression) UnmarshalJSON ¶
func (e *BinaryExpression) UnmarshalJSON(data []byte) error
type Block ¶ added in v0.8.0
Block is a set of statements
func (*Block) MarshalJSON ¶ added in v0.8.0
func (*Block) UnmarshalJSON ¶ added in v0.8.0
type BooleanLiteral ¶
BooleanLiteral represent boolean values
func BooleanLiteralFromValue ¶ added in v0.75.0
func BooleanLiteralFromValue(v bool) *BooleanLiteral
func (*BooleanLiteral) Copy ¶
func (l *BooleanLiteral) Copy() Node
func (BooleanLiteral) FromBuf ¶ added in v0.55.0
func (l BooleanLiteral) FromBuf(buf *fbast.BooleanLiteral) *BooleanLiteral
func (*BooleanLiteral) MarshalJSON ¶
func (l *BooleanLiteral) MarshalJSON() ([]byte, error)
type BuiltinStatement ¶ added in v0.14.0
type BuiltinStatement struct { BaseNode ID *Identifier `json:"id"` Ty TypeExpression `json:"ty"` }
BuiltinStatement declares a builtin identifier and its type
func (*BuiltinStatement) Copy ¶ added in v0.14.0
func (s *BuiltinStatement) Copy() Node
Copy returns a deep copy of an BuiltinStatement Node
func (BuiltinStatement) FromBuf ¶ added in v0.55.0
func (s BuiltinStatement) FromBuf(buf *fbast.BuiltinStatement) *BuiltinStatement
func (*BuiltinStatement) MarshalJSON ¶ added in v0.14.0
func (s *BuiltinStatement) MarshalJSON() ([]byte, error)
func (*BuiltinStatement) Type ¶ added in v0.14.0
func (*BuiltinStatement) Type() string
Type is the abstract type
func (*BuiltinStatement) UnmarshalJSON ¶ added in v0.83.0
func (d *BuiltinStatement) UnmarshalJSON(data []byte) error
type CallExpression ¶
type CallExpression struct { BaseNode Callee Expression `json:"callee"` Arguments []Expression `json:"arguments,omitempty"` }
CallExpression represents a function call
func (*CallExpression) Copy ¶
func (e *CallExpression) Copy() Node
func (CallExpression) FromBuf ¶ added in v0.55.0
func (e CallExpression) FromBuf(buf *fbast.CallExpression) *CallExpression
func (*CallExpression) MarshalJSON ¶
func (e *CallExpression) MarshalJSON() ([]byte, error)
func (*CallExpression) UnmarshalJSON ¶
func (e *CallExpression) UnmarshalJSON(data []byte) error
type ConditionalExpression ¶
type ConditionalExpression struct { BaseNode Test Expression `json:"test"` Consequent Expression `json:"consequent"` Alternate Expression `json:"alternate"` }
ConditionalExpression selects one of two expressions, `Alternate` or `Consequent` depending on a third, boolean, expression, `Test`.
func (*ConditionalExpression) Copy ¶
func (e *ConditionalExpression) Copy() Node
func (ConditionalExpression) FromBuf ¶ added in v0.55.0
func (e ConditionalExpression) FromBuf(buf *fbast.ConditionalExpression) *ConditionalExpression
func (*ConditionalExpression) MarshalJSON ¶
func (e *ConditionalExpression) MarshalJSON() ([]byte, error)
func (*ConditionalExpression) Type ¶
func (*ConditionalExpression) Type() string
Type is the abstract type
func (*ConditionalExpression) UnmarshalJSON ¶
func (e *ConditionalExpression) UnmarshalJSON(data []byte) error
type DateTimeLiteral ¶
DateTimeLiteral represents an instant in time with nanosecond precision using the syntax of golang's RFC3339 Nanosecond variant TODO: this may be better as a class initialization
func DateTimeLiteralFromValue ¶ added in v0.75.0
func DateTimeLiteralFromValue(v time.Time) *DateTimeLiteral
func (*DateTimeLiteral) Copy ¶
func (l *DateTimeLiteral) Copy() Node
func (DateTimeLiteral) FromBuf ¶ added in v0.55.0
func (l DateTimeLiteral) FromBuf(buf *fbast.DateTimeLiteral) *DateTimeLiteral
func (*DateTimeLiteral) MarshalJSON ¶
func (l *DateTimeLiteral) MarshalJSON() ([]byte, error)
type DictExpression ¶ added in v0.99.0
DictExpression represents dictionary literals
func (*DictExpression) Copy ¶ added in v0.99.0
func (e *DictExpression) Copy() Node
func (*DictExpression) MarshalJSON ¶ added in v0.99.0
func (e *DictExpression) MarshalJSON() ([]byte, error)
func (*DictExpression) Type ¶ added in v0.99.0
func (*DictExpression) Type() string
Type is the abstract type
func (*DictExpression) UnmarshalJSON ¶ added in v0.99.0
func (e *DictExpression) UnmarshalJSON(data []byte) error
type DictItem ¶ added in v0.99.0
type DictItem struct { Key Expression `json:"key"` Val Expression `json:"val"` }
DictItem represents a key value pair of a dictionary literal
func (*DictItem) MarshalJSON ¶ added in v0.99.0
func (*DictItem) UnmarshalJSON ¶ added in v0.99.0
type DictType ¶ added in v0.97.0
func (DictType) MarshalJSON ¶ added in v0.97.0
func (*DictType) UnmarshalJSON ¶ added in v0.97.0
type Duration ¶
Duration is a pair consisting of length of time and the unit of time measured. It is the atomic unit from which all duration literals are composed.
type DurationLiteral ¶
DurationLiteral represents the elapsed time between two instants as an int64 nanosecond count with syntax of golang's time.Duration TODO: this may be better as a class initialization
func (*DurationLiteral) Copy ¶
func (l *DurationLiteral) Copy() Node
func (DurationLiteral) FromBuf ¶ added in v0.55.0
func (l DurationLiteral) FromBuf(buf *fbast.DurationLiteral) *DurationLiteral
func (*DurationLiteral) MarshalJSON ¶
func (l *DurationLiteral) MarshalJSON() ([]byte, error)
type Error ¶ added in v0.13.0
type Error struct {
Msg string `json:"msg"`
}
Error represents an error in the AST construction. The node that this is attached to is not valid.
type Expression ¶
type Expression interface { Node // contains filtered or unexported methods }
Expression represents an action that can be performed by InfluxDB that can be evaluated to a value.
type ExpressionStatement ¶
type ExpressionStatement struct { BaseNode Expression Expression `json:"expression"` }
ExpressionStatement may consist of an expression that does not return a value and is executed solely for its side-effects.
func (*ExpressionStatement) Copy ¶
func (s *ExpressionStatement) Copy() Node
func (ExpressionStatement) FromBuf ¶ added in v0.55.0
func (s ExpressionStatement) FromBuf(buf *fbast.ExpressionStatement) *ExpressionStatement
func (*ExpressionStatement) MarshalJSON ¶
func (s *ExpressionStatement) MarshalJSON() ([]byte, error)
func (*ExpressionStatement) Type ¶
func (*ExpressionStatement) Type() string
Type is the abstract type
func (*ExpressionStatement) UnmarshalJSON ¶
func (s *ExpressionStatement) UnmarshalJSON(data []byte) error
type File ¶ added in v0.13.0
type File struct { BaseNode Name string `json:"name,omitempty"` // name of the file Metadata string `json:"metadata,omitempty"` Package *PackageClause `json:"package"` Imports []*ImportDeclaration `json:"imports"` Body []Statement `json:"body"` }
File represents a source from a single file
func (*File) MarshalJSON ¶ added in v0.13.0
func (*File) UnmarshalJSON ¶ added in v0.13.0
type FloatLiteral ¶
FloatLiteral represent floating point numbers according to the double representations defined by the IEEE-754-1985
func FloatLiteralFromValue ¶ added in v0.75.0
func FloatLiteralFromValue(v float64) *FloatLiteral
func (*FloatLiteral) Copy ¶
func (l *FloatLiteral) Copy() Node
func (FloatLiteral) FromBuf ¶ added in v0.55.0
func (l FloatLiteral) FromBuf(buf *fbast.FloatLiteral) *FloatLiteral
func (*FloatLiteral) MarshalJSON ¶
func (l *FloatLiteral) MarshalJSON() ([]byte, error)
type FunctionExpression ¶ added in v0.8.0
type FunctionExpression struct { BaseNode Params []*Property `json:"params"` Body Node `json:"body"` }
func (*FunctionExpression) Copy ¶ added in v0.8.0
func (e *FunctionExpression) Copy() Node
func (FunctionExpression) FromBuf ¶ added in v0.55.0
func (e FunctionExpression) FromBuf(buf *fbast.FunctionExpression) *FunctionExpression
func (*FunctionExpression) MarshalJSON ¶ added in v0.8.0
func (e *FunctionExpression) MarshalJSON() ([]byte, error)
func (*FunctionExpression) Type ¶ added in v0.8.0
func (*FunctionExpression) Type() string
Type is the abstract type
func (*FunctionExpression) UnmarshalJSON ¶ added in v0.8.0
func (e *FunctionExpression) UnmarshalJSON(data []byte) error
type FunctionType ¶ added in v0.77.1
type FunctionType struct { BaseNode Parameters []*ParameterType `json:"parameters"` Return MonoType `json:"monotype"` }
func (*FunctionType) Copy ¶ added in v0.81.0
func (c *FunctionType) Copy() Node
func (FunctionType) FromBuf ¶ added in v0.77.1
func (t FunctionType) FromBuf(buf *fbast.FunctionType) *FunctionType
func (FunctionType) MarshalJSON ¶ added in v0.81.0
func (fun FunctionType) MarshalJSON() ([]byte, error)
func (FunctionType) Type ¶ added in v0.77.1
func (FunctionType) Type() string
func (*FunctionType) UnmarshalJSON ¶ added in v0.81.0
func (param *FunctionType) UnmarshalJSON(data []byte) error
type Identifier ¶
Identifier represents a name that identifies a unique Node
func (*Identifier) Copy ¶
func (i *Identifier) Copy() Node
func (Identifier) FromBuf ¶ added in v0.55.0
func (i Identifier) FromBuf(buf *fbast.Identifier) *Identifier
func (*Identifier) Key ¶ added in v0.12.0
func (i *Identifier) Key() string
Identifiers are valid object keys
func (*Identifier) MarshalJSON ¶
func (i *Identifier) MarshalJSON() ([]byte, error)
func (*Identifier) UnmarshalJSON ¶ added in v0.81.0
func (i *Identifier) UnmarshalJSON(data []byte) error
type ImportDeclaration ¶ added in v0.8.0
type ImportDeclaration struct { BaseNode As *Identifier `json:"as"` Path *StringLiteral `json:"path"` }
ImportDeclaration declares a single import
func (*ImportDeclaration) Copy ¶ added in v0.8.0
func (d *ImportDeclaration) Copy() Node
func (ImportDeclaration) FromBuf ¶ added in v0.55.0
func (d ImportDeclaration) FromBuf(buf *fbast.ImportDeclaration) *ImportDeclaration
func (*ImportDeclaration) MarshalJSON ¶ added in v0.8.0
func (d *ImportDeclaration) MarshalJSON() ([]byte, error)
func (*ImportDeclaration) Type ¶ added in v0.8.0
func (*ImportDeclaration) Type() string
Type is the abstract type
type IndexExpression ¶ added in v0.7.1
type IndexExpression struct { BaseNode Array Expression `json:"array"` Index Expression `json:"index"` }
IndexExpression represents indexing into an array
func (*IndexExpression) Copy ¶ added in v0.7.1
func (e *IndexExpression) Copy() Node
func (IndexExpression) FromBuf ¶ added in v0.55.0
func (e IndexExpression) FromBuf(buf *fbast.IndexExpression) *IndexExpression
func (*IndexExpression) MarshalJSON ¶ added in v0.7.1
func (e *IndexExpression) MarshalJSON() ([]byte, error)
func (*IndexExpression) Type ¶ added in v0.7.1
func (*IndexExpression) Type() string
func (*IndexExpression) UnmarshalJSON ¶ added in v0.7.1
func (e *IndexExpression) UnmarshalJSON(data []byte) error
type IntegerLiteral ¶
IntegerLiteral represent integer numbers.
func IntegerLiteralFromValue ¶ added in v0.75.0
func IntegerLiteralFromValue(v int64) *IntegerLiteral
func (*IntegerLiteral) Copy ¶
func (l *IntegerLiteral) Copy() Node
func (IntegerLiteral) FromBuf ¶ added in v0.55.0
func (l IntegerLiteral) FromBuf(buf *fbast.IntegerLiteral) *IntegerLiteral
func (*IntegerLiteral) MarshalJSON ¶
func (l *IntegerLiteral) MarshalJSON() ([]byte, error)
func (*IntegerLiteral) UnmarshalJSON ¶
func (l *IntegerLiteral) UnmarshalJSON(data []byte) error
type InterpolatedPart ¶ added in v0.40.0
type InterpolatedPart struct { BaseNode Expression Expression `json:"expression"` }
func (*InterpolatedPart) Copy ¶ added in v0.40.0
func (p *InterpolatedPart) Copy() Node
func (InterpolatedPart) FromBuf ¶ added in v0.55.0
func (p InterpolatedPart) FromBuf(buf *fbast.StringExpressionPart) *InterpolatedPart
func (*InterpolatedPart) MarshalJSON ¶ added in v0.40.0
func (p *InterpolatedPart) MarshalJSON() ([]byte, error)
func (*InterpolatedPart) Type ¶ added in v0.40.0
func (*InterpolatedPart) Type() string
func (*InterpolatedPart) UnmarshalJSON ¶ added in v0.40.0
func (p *InterpolatedPart) UnmarshalJSON(data []byte) error
type Literal ¶
type Literal interface { Expression // contains filtered or unexported methods }
Literal is the lexical form for a literal expression which defines boolean, string, integer, number, duration, datetime or field values. Literals must be coerced explicitly.
type LogicalExpression ¶
type LogicalExpression struct { BaseNode Operator LogicalOperatorKind `json:"operator"` Left Expression `json:"left"` Right Expression `json:"right"` }
LogicalExpression represent the rule conditions that collectively evaluate to either true or false. `or` expressions compute the disjunction of two boolean expressions and return boolean values. `and“ expressions compute the conjunction of two boolean expressions and return boolean values.
func (*LogicalExpression) Copy ¶
func (e *LogicalExpression) Copy() Node
func (LogicalExpression) FromBuf ¶ added in v0.55.0
func (e LogicalExpression) FromBuf(buf *fbast.LogicalExpression) *LogicalExpression
func (*LogicalExpression) MarshalJSON ¶
func (e *LogicalExpression) MarshalJSON() ([]byte, error)
func (*LogicalExpression) UnmarshalJSON ¶
func (e *LogicalExpression) UnmarshalJSON(data []byte) error
type LogicalOperatorKind ¶
type LogicalOperatorKind int
LogicalOperatorKind are used with boolean (logical) values
const ( AndOperator LogicalOperatorKind OrOperator )
func LogicalOperatorLookup ¶
func LogicalOperatorLookup(op string) LogicalOperatorKind
LogicalOperatorLookup converts the operators to LogicalOperatorKind
func (LogicalOperatorKind) MarshalText ¶
func (o LogicalOperatorKind) MarshalText() ([]byte, error)
func (LogicalOperatorKind) String ¶
func (o LogicalOperatorKind) String() string
func (*LogicalOperatorKind) UnmarshalText ¶
func (o *LogicalOperatorKind) UnmarshalText(data []byte) error
type MemberAssignment ¶ added in v0.14.0
type MemberAssignment struct { BaseNode Member *MemberExpression `json:"member"` Init Expression `json:"init"` }
func (*MemberAssignment) Copy ¶ added in v0.14.0
func (a *MemberAssignment) Copy() Node
func (MemberAssignment) FromBuf ¶ added in v0.55.0
func (a MemberAssignment) FromBuf(buf *fbast.MemberAssignment) *MemberAssignment
func (*MemberAssignment) MarshalJSON ¶ added in v0.14.0
func (a *MemberAssignment) MarshalJSON() ([]byte, error)
func (*MemberAssignment) Type ¶ added in v0.14.0
func (*MemberAssignment) Type() string
func (*MemberAssignment) UnmarshalJSON ¶ added in v0.14.0
func (a *MemberAssignment) UnmarshalJSON(data []byte) error
type MemberExpression ¶
type MemberExpression struct { BaseNode Object Expression `json:"object"` Property PropertyKey `json:"property"` }
MemberExpression represents calling a property of a CallExpression
func (*MemberExpression) Copy ¶
func (e *MemberExpression) Copy() Node
func (MemberExpression) FromBuf ¶ added in v0.55.0
func (e MemberExpression) FromBuf(buf *fbast.MemberExpression) *MemberExpression
func (*MemberExpression) MarshalJSON ¶
func (e *MemberExpression) MarshalJSON() ([]byte, error)
func (*MemberExpression) UnmarshalJSON ¶
func (e *MemberExpression) UnmarshalJSON(data []byte) error
type MonoType ¶ added in v0.77.1
type MonoType interface { Node // contains filtered or unexported methods }
func DecodeMonoType ¶ added in v0.77.1
func DecodeMonoType(t *flatbuffers.Table, ty byte) MonoType
type NamedType ¶ added in v0.77.1
type NamedType struct { BaseNode ID *Identifier `json:"name"` }
func (NamedType) MarshalJSON ¶ added in v0.81.0
new types for builtin package
func (*NamedType) UnmarshalJSON ¶ added in v0.81.0
type Node ¶
type Node interface { Type() string // Type property is a string that contains the variant type of the node Location() SourceLocation Errs() []Error Copy() Node // All node must support json marshalling json.Marshaler // contains filtered or unexported methods }
Node represents a node in the InfluxDB abstract syntax tree.
func UnmarshalNode ¶
type ObjectExpression ¶
type ObjectExpression struct { BaseNode With *Identifier `json:"with,omitempty"` Properties []*Property `json:"properties"` }
ObjectExpression allows the declaration of an anonymous object within a declaration.
func (*ObjectExpression) Copy ¶
func (e *ObjectExpression) Copy() Node
func (ObjectExpression) FromBuf ¶ added in v0.55.0
func (e ObjectExpression) FromBuf(buf *fbast.ObjectExpression) *ObjectExpression
func (*ObjectExpression) MarshalJSON ¶
func (e *ObjectExpression) MarshalJSON() ([]byte, error)
type OperatorKind ¶
type OperatorKind int
OperatorKind are Equality and Arithmatic operators. Result of evaluating an equality operator is always of type Boolean based on whether the comparison is true Arithmetic operators take numerical values (either literals or variables) as their operands
and return a single numerical value.
const ( MultiplicationOperator OperatorKind DivisionOperator ModuloOperator PowerOperator AdditionOperator SubtractionOperator LessThanEqualOperator LessThanOperator GreaterThanEqualOperator GreaterThanOperator StartsWithOperator InOperator NotOperator ExistsOperator NotEmptyOperator EmptyOperator EqualOperator NotEqualOperator RegexpMatchOperator NotRegexpMatchOperator )
func OperatorLookup ¶
func OperatorLookup(op string) OperatorKind
OperatorLookup converts the operators to OperatorKind
func (OperatorKind) MarshalText ¶
func (o OperatorKind) MarshalText() ([]byte, error)
func (OperatorKind) String ¶
func (o OperatorKind) String() string
func (*OperatorKind) UnmarshalText ¶
func (o *OperatorKind) UnmarshalText(data []byte) error
type OptionStatement ¶
type OptionStatement struct { BaseNode Assignment Assignment `json:"assignment"` }
OptionStatement syntactically is a single variable declaration
func (*OptionStatement) Copy ¶
func (s *OptionStatement) Copy() Node
Copy returns a deep copy of an OptionStatement Node
func (OptionStatement) FromBuf ¶ added in v0.55.0
func (s OptionStatement) FromBuf(buf *fbast.OptionStatement) *OptionStatement
func (*OptionStatement) MarshalJSON ¶
func (s *OptionStatement) MarshalJSON() ([]byte, error)
func (*OptionStatement) UnmarshalJSON ¶ added in v0.14.0
func (s *OptionStatement) UnmarshalJSON(data []byte) error
type Package ¶ added in v0.13.0
type Package struct { BaseNode Path string `json:"path,omitempty"` Package string `json:"package"` Files []*File `json:"files"` }
Package represents a complete package source tree
func DeserializeFromFlatBuffer ¶ added in v0.59.0
DeserializeFromFlatBuffer takes the given byte slice that is an AST flatbuffer and deserializes it to an AST package.
func (*Package) MarshalJSON ¶ added in v0.13.0
type PackageClause ¶ added in v0.8.0
type PackageClause struct { BaseNode Name *Identifier `json:"name"` }
PackageClause defines the current package identifier.
func (*PackageClause) Copy ¶ added in v0.8.0
func (c *PackageClause) Copy() Node
func (PackageClause) FromBuf ¶ added in v0.55.0
func (c PackageClause) FromBuf(buf *fbast.PackageClause) *PackageClause
func (*PackageClause) MarshalJSON ¶ added in v0.8.0
func (c *PackageClause) MarshalJSON() ([]byte, error)
func (*PackageClause) Type ¶ added in v0.8.0
func (*PackageClause) Type() string
Type is the abstract type
type ParameterKind ¶ added in v0.77.1
type ParameterKind string
const ( Required ParameterKind = "Required" Optional ParameterKind = "Optional" Pipe ParameterKind = "Pipe" )
type ParameterType ¶ added in v0.77.1
type ParameterType struct { BaseNode Name *Identifier `json:"name,omitempty"` Ty MonoType `json:"monotype"` Kind ParameterKind `json:"-"` }
func (*ParameterType) Copy ¶ added in v0.81.0
func (c *ParameterType) Copy() Node
func (ParameterType) FromBuf ¶ added in v0.77.1
func (p ParameterType) FromBuf(buf *fbast.ParameterType) *ParameterType
func (ParameterType) MarshalJSON ¶ added in v0.81.0
func (param ParameterType) MarshalJSON() ([]byte, error)
func (*ParameterType) Type ¶ added in v0.77.1
func (p *ParameterType) Type() string
func (*ParameterType) UnmarshalJSON ¶ added in v0.81.0
func (param *ParameterType) UnmarshalJSON(data []byte) error
type ParenExpression ¶ added in v0.47.0
type ParenExpression struct { BaseNode Expression Expression `json:"expression"` }
ParenExpression represents an expressions that is wrapped in parentheses in the source code. It has no semantic meaning, rather it only communicates information about the syntax of the source code.
func (*ParenExpression) Copy ¶ added in v0.47.0
func (e *ParenExpression) Copy() Node
func (ParenExpression) FromBuf ¶ added in v0.55.0
func (e ParenExpression) FromBuf(buf *fbast.ParenExpression) *ParenExpression
func (*ParenExpression) MarshalJSON ¶ added in v0.47.0
func (e *ParenExpression) MarshalJSON() ([]byte, error)
func (*ParenExpression) Type ¶ added in v0.47.0
func (*ParenExpression) Type() string
func (*ParenExpression) UnmarshalJSON ¶ added in v0.47.0
func (e *ParenExpression) UnmarshalJSON(data []byte) error
type PipeExpression ¶
type PipeExpression struct { BaseNode Argument Expression `json:"argument"` Call *CallExpression `json:"call"` }
func (*PipeExpression) Copy ¶
func (e *PipeExpression) Copy() Node
func (PipeExpression) FromBuf ¶ added in v0.55.0
func (e PipeExpression) FromBuf(buf *fbast.PipeExpression) *PipeExpression
func (*PipeExpression) MarshalJSON ¶
func (e *PipeExpression) MarshalJSON() ([]byte, error)
func (*PipeExpression) UnmarshalJSON ¶
func (e *PipeExpression) UnmarshalJSON(data []byte) error
type PipeLiteral ¶
type PipeLiteral struct {
BaseNode
}
PipeLiteral represents an specialized literal value, indicating the left hand value of a pipe expression.
func (*PipeLiteral) Copy ¶
func (p *PipeLiteral) Copy() Node
func (PipeLiteral) FromBuf ¶ added in v0.55.0
func (p PipeLiteral) FromBuf(buf *fbast.PipeLiteral) *PipeLiteral
func (*PipeLiteral) MarshalJSON ¶
func (p *PipeLiteral) MarshalJSON() ([]byte, error)
type Position ¶
type Position struct { Line int `json:"line"` // Line is the line in the source marked by this position Column int `json:"column"` // Column is the column in the source marked by this position }
Position represents a specific location in the source
type Property ¶
type Property struct { BaseNode Key PropertyKey `json:"key"` Value Expression `json:"value"` }
Property is the value associated with a key. A property's key can be either an identifier or string literal.
func (*Property) MarshalJSON ¶
func (*Property) UnmarshalJSON ¶
type PropertyKey ¶ added in v0.12.0
PropertyKey represents an object key
type PropertyType ¶ added in v0.77.1
type PropertyType struct { BaseNode Name *Identifier `json:"name"` Ty MonoType `json:"monotype"` }
func (*PropertyType) Copy ¶ added in v0.81.0
func (c *PropertyType) Copy() Node
func (PropertyType) FromBuf ¶ added in v0.77.1
func (p PropertyType) FromBuf(buf *fbast.PropertyType) *PropertyType
func (PropertyType) MarshalJSON ¶ added in v0.81.0
func (prop PropertyType) MarshalJSON() ([]byte, error)
func (PropertyType) Type ¶ added in v0.77.1
func (PropertyType) Type() string
func (*PropertyType) UnmarshalJSON ¶ added in v0.81.0
func (nt *PropertyType) UnmarshalJSON(data []byte) error
type RecordType ¶ added in v0.77.1
type RecordType struct { BaseNode Properties []*PropertyType `json:"properties"` Tvar *Identifier `json:"tvar,omitempty"` }
func (*RecordType) Copy ¶ added in v0.81.0
func (c *RecordType) Copy() Node
func (RecordType) FromBuf ¶ added in v0.77.1
func (t RecordType) FromBuf(buf *fbast.RecordType) *RecordType
func (RecordType) MarshalJSON ¶ added in v0.81.0
func (rec RecordType) MarshalJSON() ([]byte, error)
func (RecordType) Type ¶ added in v0.77.1
func (RecordType) Type() string
type RegexpLiteral ¶
RegexpLiteral expressions begin and end with `/` and are regular expressions with syntax accepted by RE2
func RegexpLiteralFromValue ¶ added in v0.75.0
func RegexpLiteralFromValue(v *regexp.Regexp) *RegexpLiteral
func (*RegexpLiteral) Copy ¶
func (l *RegexpLiteral) Copy() Node
func (RegexpLiteral) FromBuf ¶ added in v0.55.0
func (l RegexpLiteral) FromBuf(buf *fbast.RegexpLiteral) *RegexpLiteral
func (*RegexpLiteral) MarshalJSON ¶
func (l *RegexpLiteral) MarshalJSON() ([]byte, error)
func (*RegexpLiteral) UnmarshalJSON ¶
func (l *RegexpLiteral) UnmarshalJSON(data []byte) error
type ReturnStatement ¶
type ReturnStatement struct { BaseNode Argument Expression `json:"argument"` }
ReturnStatement defines an Expression to return
func (*ReturnStatement) Copy ¶
func (s *ReturnStatement) Copy() Node
func (ReturnStatement) FromBuf ¶ added in v0.55.0
func (s ReturnStatement) FromBuf(buf *fbast.ReturnStatement) *ReturnStatement
func (*ReturnStatement) MarshalJSON ¶
func (s *ReturnStatement) MarshalJSON() ([]byte, error)
func (*ReturnStatement) UnmarshalJSON ¶
func (s *ReturnStatement) UnmarshalJSON(data []byte) error
type SourceLocation ¶
type SourceLocation struct { File string `json:"file,omitempty"` Start Position `json:"start"` // Start is the location in the source the node starts End Position `json:"end"` // End is the location in the source the node ends Source string `json:"source,omitempty"` // Source is optional raw source }
SourceLocation represents the location of a node in the AST
func (*SourceLocation) Copy ¶ added in v0.13.0
func (l *SourceLocation) Copy() *SourceLocation
func (SourceLocation) FromBuf ¶ added in v0.55.0
func (l SourceLocation) FromBuf(buf *fbast.SourceLocation) *SourceLocation
func (SourceLocation) IsValid ¶ added in v0.13.0
func (l SourceLocation) IsValid() bool
func (SourceLocation) Less ¶
func (l SourceLocation) Less(o SourceLocation) bool
func (SourceLocation) String ¶
func (l SourceLocation) String() string
type Statement ¶
type Statement interface { Node // contains filtered or unexported methods }
Statement Perhaps we don't even want statements nor expression statements
type StringExpression ¶ added in v0.40.0
type StringExpression struct { BaseNode Parts []StringExpressionPart `json:"parts"` }
func (*StringExpression) Copy ¶ added in v0.40.0
func (e *StringExpression) Copy() Node
func (StringExpression) FromBuf ¶ added in v0.55.0
func (e StringExpression) FromBuf(buf *fbast.StringExpression) *StringExpression
func (*StringExpression) MarshalJSON ¶ added in v0.40.0
func (e *StringExpression) MarshalJSON() ([]byte, error)
func (*StringExpression) Type ¶ added in v0.40.0
func (*StringExpression) Type() string
func (*StringExpression) UnmarshalJSON ¶ added in v0.40.0
func (e *StringExpression) UnmarshalJSON(data []byte) error
type StringExpressionPart ¶ added in v0.40.0
type StringExpressionPart interface { Node // contains filtered or unexported methods }
type StringLiteral ¶
type StringLiteral struct { BaseNode // Value is the unescaped value of the string literal Value string `json:"value"` }
StringLiteral expressions begin and end with double quote marks.
func StringLiteralFromValue ¶ added in v0.75.0
func StringLiteralFromValue(v string) *StringLiteral
func (*StringLiteral) Copy ¶
func (l *StringLiteral) Copy() Node
func (StringLiteral) FromBuf ¶ added in v0.55.0
func (l StringLiteral) FromBuf(buf *fbast.StringLiteral) *StringLiteral
func (*StringLiteral) Key ¶ added in v0.12.0
func (l *StringLiteral) Key() string
StringLiterals are valid object keys
func (*StringLiteral) MarshalJSON ¶
func (l *StringLiteral) MarshalJSON() ([]byte, error)
func (*StringLiteral) Type ¶
func (*StringLiteral) Type() string
type TestCaseStatement ¶ added in v0.98.0
type TestCaseStatement struct { BaseNode ID *Identifier Block *Block }
TestCaseStatement declares a Flux test case
func (*TestCaseStatement) Copy ¶ added in v0.98.0
func (s *TestCaseStatement) Copy() Node
Copy returns a deep copy of a TestCaseStatement Node
func (TestCaseStatement) FromBuf ¶ added in v0.98.0
func (s TestCaseStatement) FromBuf(buf *fbast.TestCaseStatement) *TestCaseStatement
func (*TestCaseStatement) MarshalJSON ¶ added in v0.98.0
func (s *TestCaseStatement) MarshalJSON() ([]byte, error)
func (*TestCaseStatement) Type ¶ added in v0.98.0
func (*TestCaseStatement) Type() string
Type is the abstract type
type TestStatement ¶ added in v0.19.0
type TestStatement struct { BaseNode Assignment *VariableAssignment `json:"assignment"` }
TestStatement declares a Flux test case
func (*TestStatement) Copy ¶ added in v0.19.0
func (s *TestStatement) Copy() Node
Copy returns a deep copy of a TestStatement Node
func (TestStatement) FromBuf ¶ added in v0.55.0
func (s TestStatement) FromBuf(buf *fbast.TestStatement) *TestStatement
func (*TestStatement) MarshalJSON ¶ added in v0.19.0
func (s *TestStatement) MarshalJSON() ([]byte, error)
func (*TestStatement) Type ¶ added in v0.19.0
func (*TestStatement) Type() string
Type is the abstract type
type TextPart ¶ added in v0.40.0
func (TextPart) FromBuf ¶ added in v0.55.0
func (p TextPart) FromBuf(buf *fbast.StringExpressionPart) *TextPart
func (*TextPart) MarshalJSON ¶ added in v0.40.0
func (*TextPart) UnmarshalJSON ¶ added in v0.40.0
type TvarType ¶ added in v0.78.0
type TvarType struct { BaseNode ID *Identifier `json:"name"` }
func (TvarType) MarshalJSON ¶ added in v0.81.0
type TypeConstraint ¶ added in v0.77.1
type TypeConstraint struct { BaseNode Tvar *Identifier `json:"tvar"` Kinds []*Identifier `json:"kinds"` }
func (*TypeConstraint) Copy ¶ added in v0.81.0
func (c *TypeConstraint) Copy() Node
func (TypeConstraint) FromBuf ¶ added in v0.77.1
func (c TypeConstraint) FromBuf(buf *fbast.TypeConstraint) *TypeConstraint
func (TypeConstraint) MarshalJSON ¶ added in v0.81.0
func (typ_con TypeConstraint) MarshalJSON() ([]byte, error)
func (TypeConstraint) Type ¶ added in v0.81.0
func (TypeConstraint) Type() string
func (*TypeConstraint) UnmarshalJSON ¶ added in v0.81.0
func (typ_expr *TypeConstraint) UnmarshalJSON(data []byte) error
type TypeExpression ¶ added in v0.77.1
type TypeExpression struct { BaseNode Ty MonoType `json:"monotype"` Constraints []*TypeConstraint `json:"constraints"` }
func (*TypeExpression) Copy ¶ added in v0.81.0
func (c *TypeExpression) Copy() Node
func (TypeExpression) FromBuf ¶ added in v0.77.1
func (t TypeExpression) FromBuf(buf *fbast.TypeExpression) *TypeExpression
func (TypeExpression) MarshalJSON ¶ added in v0.81.0
func (typ_expr TypeExpression) MarshalJSON() ([]byte, error)
func (TypeExpression) Type ¶ added in v0.77.1
func (TypeExpression) Type() string
func (*TypeExpression) UnmarshalJSON ¶ added in v0.81.0
func (typ_expr *TypeExpression) UnmarshalJSON(data []byte) error
type UnaryExpression ¶
type UnaryExpression struct { BaseNode Operator OperatorKind `json:"operator"` Argument Expression `json:"argument"` }
UnaryExpression use operators act on a single operand in an expression.
func (*UnaryExpression) Copy ¶
func (e *UnaryExpression) Copy() Node
func (UnaryExpression) FromBuf ¶ added in v0.55.0
func (e UnaryExpression) FromBuf(buf *fbast.UnaryExpression) *UnaryExpression
func (*UnaryExpression) MarshalJSON ¶
func (e *UnaryExpression) MarshalJSON() ([]byte, error)
func (*UnaryExpression) UnmarshalJSON ¶
func (e *UnaryExpression) UnmarshalJSON(data []byte) error
type UnsignedIntegerLiteral ¶
UnsignedIntegerLiteral represent integer numbers.
func UnsignedIntegerLiteralFromValue ¶ added in v0.75.0
func UnsignedIntegerLiteralFromValue(v uint64) *UnsignedIntegerLiteral
func (*UnsignedIntegerLiteral) Copy ¶
func (l *UnsignedIntegerLiteral) Copy() Node
func (UnsignedIntegerLiteral) FromBuf ¶ added in v0.55.0
func (l UnsignedIntegerLiteral) FromBuf(buf *fbast.UnsignedIntegerLiteral) *UnsignedIntegerLiteral
func (*UnsignedIntegerLiteral) MarshalJSON ¶
func (l *UnsignedIntegerLiteral) MarshalJSON() ([]byte, error)
func (*UnsignedIntegerLiteral) Type ¶
func (*UnsignedIntegerLiteral) Type() string
Type is the abstract type
func (*UnsignedIntegerLiteral) UnmarshalJSON ¶
func (l *UnsignedIntegerLiteral) UnmarshalJSON(data []byte) error
type VariableAssignment ¶ added in v0.8.0
type VariableAssignment struct { BaseNode ID *Identifier `json:"id"` Init Expression `json:"init"` }
VariableAssignment represents the declaration of a variable
func (*VariableAssignment) Copy ¶ added in v0.8.0
func (d *VariableAssignment) Copy() Node
func (VariableAssignment) FromBuf ¶ added in v0.55.0
func (d VariableAssignment) FromBuf(buf *fbast.VariableAssignment) *VariableAssignment
func (*VariableAssignment) MarshalJSON ¶ added in v0.8.0
func (d *VariableAssignment) MarshalJSON() ([]byte, error)
func (*VariableAssignment) Type ¶ added in v0.8.0
func (*VariableAssignment) Type() string
Type is the abstract type
func (*VariableAssignment) UnmarshalJSON ¶ added in v0.8.0
func (d *VariableAssignment) UnmarshalJSON(data []byte) error
type Visitor ¶ added in v0.8.0
Visitor implements the visitor pattern.
When used with the Walk function, Visit will be called for every node in depth-first order. After all children for a Node have been visted, Done is called on that Node to signal that we are done with that Node.
If Visit returns nil, Walk will not recurse on the children. Neither Visit nor Done will be invoked on nil nodes.
func CreateVisitor ¶ added in v0.8.0
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package asttest implements utilities for testing the abstract syntax tree.
|
Package asttest implements utilities for testing the abstract syntax tree. |
internal
|
|
fbast
Package fbast contains code generated by the FlatBuffers compiler for serializing AST.
|
Package fbast contains code generated by the FlatBuffers compiler for serializing AST. |