Documentation ¶
Overview ¶
Package lang parses failure association rule predicates. The predicate syntax defined here is intended to be a subset of BigQuery Standard SQL's Expression syntax, with the same semantics. This provides a few benefits:
- Well-known and understood syntax and semantics.
- Ability to leverage existing high-quality documentation to communicate language concepts to end-users.
- Simplified debugging of LUCI Analysis (by allowing direct copy- paste of expressions into BigQuery to verify clustering is correct).
- Possibility of using BigQuery as an execution engine in future.
Rules permitted by this package look similar to:
reason LIKE "% exited with code 5 %" AND NOT ( test = "arc.Boot" OR test = "arc.StartStop" )
The grammar for the language in Extended Backus-Naur form follows. The top-level production rule is BoolExpr.
BoolExpr = BoolTerm , ( "OR" , BoolTerm )* ; BoolTerm = BoolFactor , ( "AND" , BoolFactor )* ; BoolFactor = [ "NOT" ] BoolPrimary ; BoolPrimary = BoolItem | BoolPredicate ; BoolItem = BoolConst | "(" , BoolExpr , ")" | BoolFunc ; BoolConst = "TRUE" | "FALSE" ; BoolFunc = Identifier , "(" , StringExpr , ( "," , StringExpr )* , ")" ; BoolPredicate = StringExpr , BoolTest ; BoolTest = CompPredicate | NegatablePredicate ; CompPredicate = Operator , StringExpr ; Operator = "!=" | "<>" | "=" NegatablePredicate = [ "NOT" ] , ( InPredicate | LikePredicate ) ; InPredicate = "IN" , "(" , StringExpr , ( "," , StringExpr )* , ")" ; LikePredicate = "LIKE" , String ; StringExpr = String | Identifier ;
Where: - Identifier represents the production rule for identifiers. - String is the production rule for a double-quoted string literal. The precise definitions of which are omitted here but found in the implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateLikePattern ¶
ValidateLikePattern validates the given string is a valid LIKE pattern. In particular, this checks that all escape sequences are valid, and that there is no unfinished trailing escape sequence (trailing '\').
Types ¶
type Expr ¶
type Expr struct {
// contains filtered or unexported fields
}
Expr represents a predicate for a failure association rule.
func Parse ¶
Parse parses a failure association rule from the specified text. idents is the set of identifiers that are recognised by the application.