ast

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: BSD-3-Clause, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Inspect

func Inspect(node Node, f func(Node) bool)

func Walk

func Walk(v Visitor, node Node)

Types

type BinaryExpr

type BinaryExpr struct {
	X  Node
	Op Token // and, or
	Y  Node
}

func (BinaryExpr) Type

func (e BinaryExpr) Type() Token

type InRelationExpr

type InRelationExpr struct {
	X  Node           // operand (('mod' | '%') value)?
	Op Token          // ==, !=
	Y  *RangeListExpr //
}

func (InRelationExpr) Type

func (e InRelationExpr) Type() Token

type ModuloExpr

type ModuloExpr struct {
	Op    *OperandExpr
	Value int64
}

func (ModuloExpr) Type

func (ModuloExpr) Type() Token

type Node

type Node interface {
	Type() Token
}

type OperandExpr

type OperandExpr struct {
	Operand string
}

func (OperandExpr) Type

func (OperandExpr) Type() Token

type RangeExpr

type RangeExpr struct {
	From int64
	To   int64
}

func (RangeExpr) Type

func (RangeExpr) Type() Token

type RangeListExpr

type RangeListExpr struct {
	X Node // (range | value)
	Y Node // (',' range_list)*  Optional!
}

func (RangeListExpr) Type

func (RangeListExpr) Type() Token

type Rule

type Rule struct {
	Root    Node
	Samples []string
}

func MustParse

func MustParse(rawRule string) *Rule

func Parse

func Parse(rawRule string) (*Rule, error)

type Token

type Token int
const (
	Operand    Token // n, i, v, w, t, f
	Value            // \d+
	Equal            // =
	NotEqual         // !=
	ValueRange       // value..value
	RangeList        // (range | value) (',' range_list)*
	And              // 'and'
	Or               // 'or'
	Remainder        // %

)

type ValueExpr

type ValueExpr struct {
	Value int64
}

func (ValueExpr) Type

func (ValueExpr) Type() Token

type Visitor

type Visitor interface {
	Visit(node Node) (w Visitor)
}

Jump to

Keyboard shortcuts

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