package parse
import "golang.org/x/perf/benchproc/internal/parse"
Package parse implements parsers for golang.org/x/perf/benchproc/syntax.
Currently this package is internal to benchproc, but if we ever migrate perf.golang.org to this expression syntax, it will be valuable to construct database queries from the same grammar.
Index ¶
- type Field
- type Filter
- type FilterMatch
- func (q *FilterMatch) Match(value []byte) bool
- func (q *FilterMatch) MatchString(value string) bool
- func (q *FilterMatch) String() string
- type FilterOp
- type Op
- type SyntaxError
Types ¶
type Field ¶
type Field struct { Key string // Order is the sort order for this field. This can be // "first", meaning to sort by order of first appearance; // "fixed", meaning to use the explicit value order in Fixed; // or a named sort order. Order string // Fixed gives the explicit value order for "fixed" ordering. // If a record's value is not in this list, the record should // be filtered out. Otherwise, values should be sorted // according to their order in this list. Fixed []string // KeyOff and OrderOff give the byte offsets of the key and // order, for error reporting. KeyOff, OrderOff int }
A Field is one element in a projection expression. It represents extracting a single dimension of a benchmark result and applying an order to it.
func ParseProjection ¶
ParseProjection parses a projection expression into a tuple of Fields.
func (Field) String ¶
String returns Projection as a valid projection expression.
type Filter ¶
type Filter interface { String() string // contains filtered or unexported methods }
A Filter is a node in the boolean filter. It can either be a FilterOp or a FilterMatch.
func ParseFilter ¶
ParseFilter parses a filter expression into a Filter tree.
type FilterMatch ¶
type FilterMatch struct { Key string // Regexp is the regular expression to match against the // value. This may be nil, in which case this is a literal // match against Lit. Regexp *regexp.Regexp // Lit is the literal value to match against the value if Regexp // is nil. Lit string // Off is the byte offset of the key in the original query, // for error reporting. Off int }
A FilterMatch is a leaf in a Filter tree that tests a specific key for a match.
func (*FilterMatch) Match ¶
func (q *FilterMatch) Match(value []byte) bool
Match returns whether q matches the given value of q.Key.
func (*FilterMatch) MatchString ¶
func (q *FilterMatch) MatchString(value string) bool
MatchString returns whether q matches the given value of q.Key.
func (*FilterMatch) String ¶
func (q *FilterMatch) String() string
type FilterOp ¶
A FilterOp is a boolean operator in the Filter tree. OpNot must have exactly one child node. OpAnd and OpOr may have zero or more child nodes.
func (*FilterOp) String ¶
type Op ¶
type Op int
Op specifies a type of boolean operator.
type SyntaxError ¶
type SyntaxError struct { Query string // The original query string Off int // Byte offset of the error in Query Msg string // Error message }
A SyntaxError is an error produced by parsing a malformed expression.
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string
Source Files ¶
doc.go filter.go projection.go tok.go tree.go
- Version
- v0.0.0-20250214215153-c95ad7d5b636 (latest)
- Published
- Feb 14, 2025
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 2 weeks ago –
Tools for package owners.