mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 13:44:05 -08:00
parser.{Expr,Statement} publicly implementable (#7639)
* parser.{Expr,Statement} publicly implementable Signed-off-by: Owen Diehl <ow.diehl@gmail.com>
This commit is contained in:
parent
e17d18a043
commit
00b7bdb1b6
|
@ -26,7 +26,7 @@ import (
|
||||||
// Node is a generic interface for all nodes in an AST.
|
// Node is a generic interface for all nodes in an AST.
|
||||||
//
|
//
|
||||||
// Whenever numerous nodes are listed such as in a switch-case statement
|
// Whenever numerous nodes are listed such as in a switch-case statement
|
||||||
// or a chain of function definitions (e.g. String(), expr(), etc.) convention is
|
// or a chain of function definitions (e.g. String(), PromQLExpr(), etc.) convention is
|
||||||
// to list them as follows:
|
// to list them as follows:
|
||||||
//
|
//
|
||||||
// - Statements
|
// - Statements
|
||||||
|
@ -49,9 +49,9 @@ type Node interface {
|
||||||
type Statement interface {
|
type Statement interface {
|
||||||
Node
|
Node
|
||||||
|
|
||||||
// stmt ensures that no other type accidentally implements the interface
|
// PromQLStmt ensures that no other type accidentally implements the interface
|
||||||
// nolint:unused
|
// nolint:unused
|
||||||
stmt()
|
PromQLStmt()
|
||||||
}
|
}
|
||||||
|
|
||||||
// EvalStmt holds an expression and information on the range it should
|
// EvalStmt holds an expression and information on the range it should
|
||||||
|
@ -66,7 +66,7 @@ type EvalStmt struct {
|
||||||
Interval time.Duration
|
Interval time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*EvalStmt) stmt() {}
|
func (*EvalStmt) PromQLStmt() {}
|
||||||
|
|
||||||
// Expr is a generic interface for all expression types.
|
// Expr is a generic interface for all expression types.
|
||||||
type Expr interface {
|
type Expr interface {
|
||||||
|
@ -75,8 +75,8 @@ type Expr interface {
|
||||||
// Type returns the type the expression evaluates to. It does not perform
|
// Type returns the type the expression evaluates to. It does not perform
|
||||||
// in-depth checks as this is done at parsing-time.
|
// in-depth checks as this is done at parsing-time.
|
||||||
Type() ValueType
|
Type() ValueType
|
||||||
// expr ensures that no other types accidentally implement the interface.
|
// PromQLExpr ensures that no other types accidentally implement the interface.
|
||||||
expr()
|
PromQLExpr()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expressions is a list of expression nodes that implements Node.
|
// Expressions is a list of expression nodes that implements Node.
|
||||||
|
@ -180,7 +180,7 @@ type VectorSelector struct {
|
||||||
type TestStmt func(context.Context) error
|
type TestStmt func(context.Context) error
|
||||||
|
|
||||||
func (TestStmt) String() string { return "test statement" }
|
func (TestStmt) String() string { return "test statement" }
|
||||||
func (TestStmt) stmt() {}
|
func (TestStmt) PromQLStmt() {}
|
||||||
|
|
||||||
func (TestStmt) PositionRange() PositionRange {
|
func (TestStmt) PositionRange() PositionRange {
|
||||||
return PositionRange{
|
return PositionRange{
|
||||||
|
@ -204,16 +204,16 @@ func (e *BinaryExpr) Type() ValueType {
|
||||||
return ValueTypeVector
|
return ValueTypeVector
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*AggregateExpr) expr() {}
|
func (*AggregateExpr) PromQLExpr() {}
|
||||||
func (*BinaryExpr) expr() {}
|
func (*BinaryExpr) PromQLExpr() {}
|
||||||
func (*Call) expr() {}
|
func (*Call) PromQLExpr() {}
|
||||||
func (*MatrixSelector) expr() {}
|
func (*MatrixSelector) PromQLExpr() {}
|
||||||
func (*SubqueryExpr) expr() {}
|
func (*SubqueryExpr) PromQLExpr() {}
|
||||||
func (*NumberLiteral) expr() {}
|
func (*NumberLiteral) PromQLExpr() {}
|
||||||
func (*ParenExpr) expr() {}
|
func (*ParenExpr) PromQLExpr() {}
|
||||||
func (*StringLiteral) expr() {}
|
func (*StringLiteral) PromQLExpr() {}
|
||||||
func (*UnaryExpr) expr() {}
|
func (*UnaryExpr) PromQLExpr() {}
|
||||||
func (*VectorSelector) expr() {}
|
func (*VectorSelector) PromQLExpr() {}
|
||||||
|
|
||||||
// VectorMatchCardinality describes the cardinality relationship
|
// VectorMatchCardinality describes the cardinality relationship
|
||||||
// of two Vectors in a binary operation.
|
// of two Vectors in a binary operation.
|
||||||
|
|
Loading…
Reference in a new issue