Documentation
¶
Overview ¶
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 ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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.
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.
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