ast

package
v0.0.0-...-f696b34 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldString

func FieldString(pathparts []string) string

Types

type AndNode

type AndNode struct {
	Left  Node
	Right Node
}

TODO: AndExpr, etc

func (*AndNode) IsNode

func (a *AndNode) IsNode()

func (*AndNode) String

func (a *AndNode) String() string

type BoolVal

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

func NewBoolVal

func NewBoolVal(b []byte, pos Pos) (*BoolVal, error)

func (*BoolVal) Pos

func (b *BoolVal) Pos() Pos

func (*BoolVal) String

func (b *BoolVal) String() string

func (*BoolVal) Type

func (b *BoolVal) Type() ValType

func (*BoolVal) Value

func (b *BoolVal) Value() bool

type ExprNode

type ExprNode struct {
	Op       Op
	Field    []string
	RVals    []Val
	Position Pos
}

func (*ExprNode) FriendlyString

func (e *ExprNode) FriendlyString() string

func (*ExprNode) IsNode

func (e *ExprNode) IsNode()

func (*ExprNode) Pos

func (e *ExprNode) Pos() Pos

func (*ExprNode) String

func (e *ExprNode) String() string

type FloatVal

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

func NewFloatVal

func NewFloatVal(b []byte, pos Pos) (*FloatVal, error)

func (*FloatVal) Pos

func (f *FloatVal) Pos() Pos

func (*FloatVal) String

func (f *FloatVal) String() string

func (*FloatVal) Type

func (f *FloatVal) Type() ValType

func (*FloatVal) Value

func (f *FloatVal) Value() float64

type IntVal

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

func NewIntVal

func NewIntVal(b []byte, pos Pos) (*IntVal, error)

func (*IntVal) Pos

func (i *IntVal) Pos() Pos

func (*IntVal) String

func (i *IntVal) String() string

func (*IntVal) Type

func (i *IntVal) Type() ValType

func (*IntVal) Value

func (i *IntVal) Value() int64

type NetVal

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

func NewNetVal

func NewNetVal(b []byte, pos Pos) (*NetVal, error)

func (*NetVal) Pos

func (n *NetVal) Pos() Pos

func (*NetVal) String

func (n *NetVal) String() string

func (*NetVal) Type

func (n *NetVal) Type() ValType

func (*NetVal) Value

func (n *NetVal) Value() netip.Prefix

type Node

type Node interface {
	IsNode()
	String() string
}

type NotNode

type NotNode struct {
	Expr Node
}

func (*NotNode) IsNode

func (n *NotNode) IsNode()

func (*NotNode) String

func (n *NotNode) String() string

type Op

type Op string
const (
	EQ  Op = `==`
	LT  Op = `<`
	LTE Op = `<=`
	GT  Op = `>`
	GTE Op = `>=`
	BET Op = `><`
	SIM Op = `~`
	EXS Op = `exists`
	NUL Op = `null`
)

type OrNode

type OrNode struct {
	Left  Node
	Right Node
}

func (*OrNode) IsNode

func (o *OrNode) IsNode()

func (*OrNode) String

func (o *OrNode) String() string

type Pos

type Pos struct {
	// Line is a 1-based integer representing the line on which the token was.
	// found.
	Line int `json:"line"`
	// Col is a 1-based integer representing the rune offset of the token on the line.
	Col int `json:"column"`
	// Offset is a 0-based offset of the token in the entire input text.
	Offset int `json:"offset"`
	// Len is the length of the token from Offset, in runes
	Len int `json:"length"`
}

Pos represents the position of a node or token in the text.

func NoPosition

func NoPosition() Pos

NoPosition returns a position with a negative offset for messages and errors that are not attached to a query feature.

func (Pos) IsZero

func (p Pos) IsZero() bool

func (Pos) Start

func (p Pos) Start() Pos

type RegexpVal

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

func NewRegexpVal

func NewRegexpVal(b []byte, pos Pos) (*RegexpVal, error)

func (*RegexpVal) Pos

func (r *RegexpVal) Pos() Pos

func (*RegexpVal) String

func (r *RegexpVal) String() string

func (*RegexpVal) Type

func (r *RegexpVal) Type() ValType

func (*RegexpVal) Value

func (r *RegexpVal) Value() *regexp.Regexp

type StringVal

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

func NewStringVal

func NewStringVal(b []byte, pos Pos) (*StringVal, error)

func (*StringVal) Pos

func (s *StringVal) Pos() Pos

func (*StringVal) String

func (s *StringVal) String() string

func (*StringVal) Type

func (s *StringVal) Type() ValType

func (*StringVal) Value

func (s *StringVal) Value() string

type SubdocNode

type SubdocNode struct {
	Field []string
	Expr  Node
}

func (*SubdocNode) IsNode

func (s *SubdocNode) IsNode()

func (*SubdocNode) String

func (s *SubdocNode) String() string

type TimeVal

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

func NewTimeVal

func NewTimeVal(b []byte, pos Pos) (*TimeVal, error)

func (*TimeVal) DayOnly

func (t *TimeVal) DayOnly() bool

func (*TimeVal) Pos

func (t *TimeVal) Pos() Pos

func (*TimeVal) String

func (t *TimeVal) String() string

func (*TimeVal) Type

func (t *TimeVal) Type() ValType

func (*TimeVal) Value

func (t *TimeVal) Value() time.Time

type Val

type Val interface {
	String() string
	Type() ValType
	Pos() Pos
}

type ValType

type ValType string
const (
	TypeInt    ValType = "integer"
	TypeFloat  ValType = "float"
	TypeString ValType = "string"
	TypeBool   ValType = "boolean"
	TypeRegex  ValType = "regex"
	TypeNet    ValType = "netaddr"
	TypeTime   ValType = "timestamp"
)

Jump to

Keyboard shortcuts

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