ast

package
v0.7.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: MIT Imports: 5 Imported by: 49

Documentation

Overview

Package ast declares the types used to represent the syntax tree for Flux source code.

Index

Constants

This section is empty.

Variables

View Source
var LogicalOperatorTokens = map[LogicalOperatorKind]string{
	AndOperator: "and",
	OrOperator:  "or",
}

LogicalOperatorTokens converts LogicalOperatorKind to string

OperatorTokens converts OperatorKind to string

Functions

This section is empty.

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) MarshalJSON

func (e *ArrayExpression) MarshalJSON() ([]byte, error)

func (*ArrayExpression) Type

func (*ArrayExpression) Type() string

Type is the abstract type

func (*ArrayExpression) UnmarshalJSON

func (e *ArrayExpression) UnmarshalJSON(data []byte) error

type ArrowFunctionExpression

type ArrowFunctionExpression struct {
	BaseNode
	Params []*Property `json:"params"`
	Body   Node        `json:"body"`
}

func (*ArrowFunctionExpression) Copy

func (e *ArrowFunctionExpression) Copy() Node

func (*ArrowFunctionExpression) MarshalJSON

func (e *ArrowFunctionExpression) MarshalJSON() ([]byte, error)

func (*ArrowFunctionExpression) Type

Type is the abstract type

func (*ArrowFunctionExpression) UnmarshalJSON

func (e *ArrowFunctionExpression) UnmarshalJSON(data []byte) error

type BaseNode

type BaseNode struct {
	Loc *SourceLocation `json:"location,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 arithmatic operators

func (*BinaryExpression) Copy

func (e *BinaryExpression) Copy() Node

func (*BinaryExpression) MarshalJSON

func (e *BinaryExpression) MarshalJSON() ([]byte, error)

func (*BinaryExpression) Type

func (*BinaryExpression) Type() string

Type is the abstract type

func (*BinaryExpression) UnmarshalJSON

func (e *BinaryExpression) UnmarshalJSON(data []byte) error

type BlockStatement

type BlockStatement struct {
	BaseNode
	Body []Statement `json:"body"`
}

BlockStatement is a set of statements

func (*BlockStatement) Copy

func (s *BlockStatement) Copy() Node

func (*BlockStatement) MarshalJSON

func (s *BlockStatement) MarshalJSON() ([]byte, error)

func (*BlockStatement) Type

func (*BlockStatement) Type() string

Type is the abstract type

func (*BlockStatement) UnmarshalJSON

func (s *BlockStatement) UnmarshalJSON(data []byte) error

type BooleanLiteral

type BooleanLiteral struct {
	BaseNode
	Value bool `json:"value"`
}

BooleanLiteral represent boolean values

func (*BooleanLiteral) Copy

func (l *BooleanLiteral) Copy() Node

func (*BooleanLiteral) MarshalJSON

func (l *BooleanLiteral) MarshalJSON() ([]byte, error)

func (*BooleanLiteral) Type

func (*BooleanLiteral) Type() string

Type is the abstract type

type CallExpression

type CallExpression struct {
	BaseNode
	Callee    Expression   `json:"callee"`
	Arguments []Expression `json:"arguments,omitempty"`
}

CallExpression represents a function all whose callee may be an Identifier or MemberExpression

func (*CallExpression) Copy

func (e *CallExpression) Copy() Node

func (*CallExpression) MarshalJSON

func (e *CallExpression) MarshalJSON() ([]byte, error)

func (*CallExpression) Type

func (*CallExpression) Type() string

Type is the abstract type

func (*CallExpression) UnmarshalJSON

func (e *CallExpression) UnmarshalJSON(data []byte) error

type ConditionalExpression

type ConditionalExpression struct {
	BaseNode
	Test       Expression `json:"test"`
	Alternate  Expression `json:"alternate"`
	Consequent Expression `json:"consequent"`
}

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) 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

type DateTimeLiteral struct {
	BaseNode
	Value time.Time `json:"value"`
}

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 (*DateTimeLiteral) Copy

func (l *DateTimeLiteral) Copy() Node

func (*DateTimeLiteral) MarshalJSON

func (l *DateTimeLiteral) MarshalJSON() ([]byte, error)

func (*DateTimeLiteral) Type

func (*DateTimeLiteral) Type() string

Type is the abstract type

type Duration

type Duration struct {
	Magnitude int64  `json:"magnitude"`
	Unit      string `json:"unit"`
}

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

type DurationLiteral struct {
	BaseNode
	Values []Duration `json:"values"`
}

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) MarshalJSON

func (l *DurationLiteral) MarshalJSON() ([]byte, error)

func (*DurationLiteral) Type

func (*DurationLiteral) Type() string

Type is the abstract type

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) 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 FloatLiteral

type FloatLiteral struct {
	BaseNode
	Value float64 `json:"value"`
}

FloatLiteral represent floating point numbers according to the double representations defined by the IEEE-754-1985

func (*FloatLiteral) Copy

func (l *FloatLiteral) Copy() Node

func (*FloatLiteral) MarshalJSON

func (l *FloatLiteral) MarshalJSON() ([]byte, error)

func (*FloatLiteral) Type

func (*FloatLiteral) Type() string

Type is the abstract type

type Identifier

type Identifier struct {
	BaseNode
	Name string `json:"name"`
}

Identifier represents a name that identifies a unique Node

func (*Identifier) Copy

func (i *Identifier) Copy() Node

func (*Identifier) MarshalJSON

func (i *Identifier) MarshalJSON() ([]byte, error)

func (*Identifier) Type

func (*Identifier) Type() string

Type is the abstract type

type IntegerLiteral

type IntegerLiteral struct {
	BaseNode
	Value int64 `json:"value"`
}

IntegerLiteral represent integer numbers.

func (*IntegerLiteral) Copy

func (l *IntegerLiteral) Copy() Node

func (*IntegerLiteral) MarshalJSON

func (l *IntegerLiteral) MarshalJSON() ([]byte, error)

func (*IntegerLiteral) Type

func (*IntegerLiteral) Type() string

Type is the abstract type

func (*IntegerLiteral) UnmarshalJSON

func (l *IntegerLiteral) 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) MarshalJSON

func (e *LogicalExpression) MarshalJSON() ([]byte, error)

func (*LogicalExpression) Type

func (*LogicalExpression) Type() string

Type is the abstract type

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 MemberExpression

type MemberExpression struct {
	BaseNode
	Object   Expression `json:"object"`
	Property Expression `json:"property"`
}

MemberExpression represents calling a property of a CallExpression

func (*MemberExpression) Copy

func (e *MemberExpression) Copy() Node

func (*MemberExpression) MarshalJSON

func (e *MemberExpression) MarshalJSON() ([]byte, error)

func (*MemberExpression) Type

func (*MemberExpression) Type() string

Type is the abstract type

func (*MemberExpression) UnmarshalJSON

func (e *MemberExpression) UnmarshalJSON(data []byte) error

type Node

type Node interface {
	Type() string // Type property is a string that contains the variant type of the node
	Location() SourceLocation
	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

func UnmarshalNode(data []byte) (Node, error)

type ObjectExpression

type ObjectExpression struct {
	BaseNode
	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) MarshalJSON

func (e *ObjectExpression) MarshalJSON() ([]byte, error)

func (*ObjectExpression) Type

func (*ObjectExpression) Type() string

Type is the abstract type

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
	AdditionOperator
	SubtractionOperator
	LessThanEqualOperator
	LessThanOperator
	GreaterThanEqualOperator
	GreaterThanOperator
	StartsWithOperator
	InOperator
	NotOperator
	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
	Declaration *VariableDeclarator `json:"declaration"`
}

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) MarshalJSON

func (s *OptionStatement) MarshalJSON() ([]byte, error)

func (*OptionStatement) Type

func (*OptionStatement) Type() string

Type is the abstract type

type PipeExpression

type PipeExpression struct {
	BaseNode
	Argument Expression      `json:"argument"`
	Call     *CallExpression `json:"call"`
}

func (*PipeExpression) Copy

func (e *PipeExpression) Copy() Node

func (*PipeExpression) MarshalJSON

func (e *PipeExpression) MarshalJSON() ([]byte, error)

func (*PipeExpression) Type

func (*PipeExpression) Type() string

Type is the abstract type

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 (i *PipeLiteral) Copy() Node

func (*PipeLiteral) MarshalJSON

func (l *PipeLiteral) MarshalJSON() ([]byte, error)

func (*PipeLiteral) Type

func (*PipeLiteral) Type() string

Type is the abstract type

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

func (Position) Less

func (p Position) Less(o Position) bool

func (Position) String

func (p Position) String() string

type Program

type Program struct {
	BaseNode
	Body []Statement `json:"body"`
}

Program represents a complete program source tree

func (*Program) Copy

func (p *Program) Copy() Node

func (*Program) MarshalJSON

func (p *Program) MarshalJSON() ([]byte, error)

func (*Program) Type

func (*Program) Type() string

Type is the abstract type

func (*Program) UnmarshalJSON

func (p *Program) UnmarshalJSON(data []byte) error

type Property

type Property struct {
	BaseNode
	Key   *Identifier `json:"key"`
	Value Expression  `json:"value"`
}

Property is the value associated with a key

func (*Property) Copy

func (p *Property) Copy() Node

func (*Property) MarshalJSON

func (p *Property) MarshalJSON() ([]byte, error)

func (*Property) Type

func (*Property) Type() string

Type is the abstract type

func (*Property) UnmarshalJSON

func (p *Property) UnmarshalJSON(data []byte) error

type RegexpLiteral

type RegexpLiteral struct {
	BaseNode
	Value *regexp.Regexp `json:"value"`
}

RegexpLiteral expressions begin and end with `/` and are regular expressions with syntax accepted by RE2

func (*RegexpLiteral) Copy

func (l *RegexpLiteral) Copy() Node

func (*RegexpLiteral) MarshalJSON

func (l *RegexpLiteral) MarshalJSON() ([]byte, error)

func (*RegexpLiteral) Type

func (*RegexpLiteral) Type() string

Type is the abstract type

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) MarshalJSON

func (s *ReturnStatement) MarshalJSON() ([]byte, error)

func (*ReturnStatement) Type

func (*ReturnStatement) Type() string

Type is the abstract type

func (*ReturnStatement) UnmarshalJSON

func (s *ReturnStatement) UnmarshalJSON(data []byte) error

type SourceLocation

type SourceLocation struct {
	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) Less

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 StringLiteral

type StringLiteral struct {
	BaseNode
	Value string `json:"value"`
}

StringLiteral expressions begin and end with double quote marks.

func (*StringLiteral) Copy

func (l *StringLiteral) Copy() Node

func (*StringLiteral) MarshalJSON

func (l *StringLiteral) MarshalJSON() ([]byte, error)

func (*StringLiteral) Type

func (*StringLiteral) Type() string

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) MarshalJSON

func (e *UnaryExpression) MarshalJSON() ([]byte, error)

func (*UnaryExpression) Type

func (*UnaryExpression) Type() string

Type is the abstract type

func (*UnaryExpression) UnmarshalJSON

func (e *UnaryExpression) UnmarshalJSON(data []byte) error

type UnsignedIntegerLiteral

type UnsignedIntegerLiteral struct {
	BaseNode
	Value uint64 `json:"value"`
}

UnsignedIntegerLiteral represent integer numbers.

func (*UnsignedIntegerLiteral) Copy

func (l *UnsignedIntegerLiteral) Copy() Node

func (*UnsignedIntegerLiteral) MarshalJSON

func (l *UnsignedIntegerLiteral) MarshalJSON() ([]byte, error)

func (*UnsignedIntegerLiteral) Type

Type is the abstract type

func (*UnsignedIntegerLiteral) UnmarshalJSON

func (l *UnsignedIntegerLiteral) UnmarshalJSON(data []byte) error

type VariableDeclaration

type VariableDeclaration struct {
	BaseNode
	Declarations []*VariableDeclarator `json:"declarations"`
}

VariableDeclaration declares one or more variables using assignment

func (*VariableDeclaration) Copy

func (d *VariableDeclaration) Copy() Node

func (*VariableDeclaration) MarshalJSON

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

func (*VariableDeclaration) Type

func (*VariableDeclaration) Type() string

Type is the abstract type

type VariableDeclarator

type VariableDeclarator struct {
	BaseNode
	ID   *Identifier `json:"id"`
	Init Expression  `json:"init"`
}

VariableDeclarator represents the declaration of a variable

func (*VariableDeclarator) Copy

func (d *VariableDeclarator) Copy() Node

func (*VariableDeclarator) MarshalJSON

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

func (*VariableDeclarator) Type

func (*VariableDeclarator) Type() string

Type is the abstract type

func (*VariableDeclarator) UnmarshalJSON

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

Directories

Path Synopsis
Package asttest implements utilities for testing the abstract syntax tree.
Package asttest implements utilities for testing the abstract syntax tree.
cmpgen
cmpgen generates comparison options for the asttest package.
cmpgen generates comparison options for the asttest package.

Jump to

Keyboard shortcuts

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