From 8547a2bd8603787fa12fc46163ed768b5431b2aa Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Tue, 24 Aug 2021 19:22:14 -0400 Subject: [PATCH] Add `atan2` binary operator Signed-off-by: Levi Harrison --- promql/engine.go | 2 + promql/parser/generated_parser.y | 4 +- promql/parser/generated_parser.y.go | 1023 ++++++++++++++------------- promql/parser/lex.go | 1 + 4 files changed, 521 insertions(+), 509 deletions(-) diff --git a/promql/engine.go b/promql/engine.go index 3b1d35757..e5dbcd2d7 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -2116,6 +2116,8 @@ func vectorElemBinop(op parser.ItemType, lhs, rhs float64) (float64, bool) { return lhs, lhs >= rhs case parser.LTE: return lhs, lhs <= rhs + case parser.ATAN2: + return math.Atan2(lhs, rhs), true } panic(errors.Errorf("operator %q not allowed for operations between Vectors", op)) } diff --git a/promql/parser/generated_parser.y b/promql/parser/generated_parser.y index 75f147ee4..4380da4ee 100644 --- a/promql/parser/generated_parser.y +++ b/promql/parser/generated_parser.y @@ -84,6 +84,7 @@ NEQ_REGEX POW SUB AT +ATAN2 %token operatorsEnd // Aggregators. @@ -156,7 +157,7 @@ START_METRIC_SELECTOR %left LAND LUNLESS %left EQLC GTE GTR LSS LTE NEQ %left ADD SUB -%left MUL DIV MOD +%left MUL DIV MOD ATAN2 %right POW // Offset modifiers do not have associativity. @@ -237,6 +238,7 @@ aggregate_modifier: // Operator precedence only works if each of those is listed separately. binary_expr : expr ADD bin_modifier expr { $$ = yylex.(*parser).newBinaryExpression($1, $2, $3, $4) } + | expr ATAN2 bin_modifier expr { $$ = yylex.(*parser).newBinaryExpression($1, $2, $3, $4) } | expr DIV bin_modifier expr { $$ = yylex.(*parser).newBinaryExpression($1, $2, $3, $4) } | expr EQLC bin_modifier expr { $$ = yylex.(*parser).newBinaryExpression($1, $2, $3, $4) } | expr GTE bin_modifier expr { $$ = yylex.(*parser).newBinaryExpression($1, $2, $3, $4) } diff --git a/promql/parser/generated_parser.y.go b/promql/parser/generated_parser.y.go index 5a2aafe3d..a9eb6d99e 100644 --- a/promql/parser/generated_parser.y.go +++ b/promql/parser/generated_parser.y.go @@ -1,11 +1,11 @@ -// Code generated by goyacc -o generated_parser.y.go generated_parser.y. DO NOT EDIT. +// Code generated by goyacc -o promql/parser/generated_parser.y.go promql/parser/generated_parser.y. DO NOT EDIT. -//line generated_parser.y:15 +//line promql/parser/generated_parser.y:15 package parser import __yyfmt__ "fmt" -//line generated_parser.y:15 +//line promql/parser/generated_parser.y:15 import ( "math" @@ -17,7 +17,7 @@ import ( "github.com/prometheus/prometheus/pkg/value" ) -//line generated_parser.y:28 +//line promql/parser/generated_parser.y:28 type yySymType struct { yys int node Node @@ -73,41 +73,42 @@ const NEQ_REGEX = 57382 const POW = 57383 const SUB = 57384 const AT = 57385 -const operatorsEnd = 57386 -const aggregatorsStart = 57387 -const AVG = 57388 -const BOTTOMK = 57389 -const COUNT = 57390 -const COUNT_VALUES = 57391 -const GROUP = 57392 -const MAX = 57393 -const MIN = 57394 -const QUANTILE = 57395 -const STDDEV = 57396 -const STDVAR = 57397 -const SUM = 57398 -const TOPK = 57399 -const aggregatorsEnd = 57400 -const keywordsStart = 57401 -const BOOL = 57402 -const BY = 57403 -const GROUP_LEFT = 57404 -const GROUP_RIGHT = 57405 -const IGNORING = 57406 -const OFFSET = 57407 -const ON = 57408 -const WITHOUT = 57409 -const keywordsEnd = 57410 -const preprocessorStart = 57411 -const START = 57412 -const END = 57413 -const preprocessorEnd = 57414 -const startSymbolsStart = 57415 -const START_METRIC = 57416 -const START_SERIES_DESCRIPTION = 57417 -const START_EXPRESSION = 57418 -const START_METRIC_SELECTOR = 57419 -const startSymbolsEnd = 57420 +const ATAN2 = 57386 +const operatorsEnd = 57387 +const aggregatorsStart = 57388 +const AVG = 57389 +const BOTTOMK = 57390 +const COUNT = 57391 +const COUNT_VALUES = 57392 +const GROUP = 57393 +const MAX = 57394 +const MIN = 57395 +const QUANTILE = 57396 +const STDDEV = 57397 +const STDVAR = 57398 +const SUM = 57399 +const TOPK = 57400 +const aggregatorsEnd = 57401 +const keywordsStart = 57402 +const BOOL = 57403 +const BY = 57404 +const GROUP_LEFT = 57405 +const GROUP_RIGHT = 57406 +const IGNORING = 57407 +const OFFSET = 57408 +const ON = 57409 +const WITHOUT = 57410 +const keywordsEnd = 57411 +const preprocessorStart = 57412 +const START = 57413 +const END = 57414 +const preprocessorEnd = 57415 +const startSymbolsStart = 57416 +const START_METRIC = 57417 +const START_SERIES_DESCRIPTION = 57418 +const START_EXPRESSION = 57419 +const START_METRIC_SELECTOR = 57420 +const startSymbolsEnd = 57421 var yyToknames = [...]string{ "$end", @@ -153,6 +154,7 @@ var yyToknames = [...]string{ "POW", "SUB", "AT", + "ATAN2", "operatorsEnd", "aggregatorsStart", "AVG", @@ -196,7 +198,7 @@ const yyEofCode = 1 const yyErrCode = 2 const yyInitialStackSize = 16 -//line generated_parser.y:747 +//line promql/parser/generated_parser.y:749 //line yacctab:1 var yyExca = [...]int{ @@ -204,258 +206,257 @@ var yyExca = [...]int{ 1, -1, -2, 0, -1, 35, - 1, 130, - 10, 130, - 22, 130, + 1, 131, + 10, 131, + 22, 131, -2, 0, -1, 58, - 2, 142, - 15, 142, - 61, 142, - 67, 142, - -2, 96, - -1, 59, 2, 143, 15, 143, - 61, 143, - 67, 143, + 62, 143, + 68, 143, -2, 97, - -1, 60, + -1, 59, 2, 144, 15, 144, - 61, 144, - 67, 144, - -2, 99, - -1, 61, + 62, 144, + 68, 144, + -2, 98, + -1, 60, 2, 145, 15, 145, - 61, 145, - 67, 145, + 62, 145, + 68, 145, -2, 100, - -1, 62, + -1, 61, 2, 146, 15, 146, - 61, 146, - 67, 146, + 62, 146, + 68, 146, -2, 101, - -1, 63, + -1, 62, 2, 147, 15, 147, - 61, 147, - 67, 147, - -2, 106, - -1, 64, + 62, 147, + 68, 147, + -2, 102, + -1, 63, 2, 148, 15, 148, - 61, 148, - 67, 148, - -2, 108, - -1, 65, + 62, 148, + 68, 148, + -2, 107, + -1, 64, 2, 149, 15, 149, - 61, 149, - 67, 149, - -2, 110, - -1, 66, + 62, 149, + 68, 149, + -2, 109, + -1, 65, 2, 150, 15, 150, - 61, 150, - 67, 150, + 62, 150, + 68, 150, -2, 111, - -1, 67, + -1, 66, 2, 151, 15, 151, - 61, 151, - 67, 151, + 62, 151, + 68, 151, -2, 112, - -1, 68, + -1, 67, 2, 152, 15, 152, - 61, 152, - 67, 152, + 62, 152, + 68, 152, -2, 113, - -1, 69, + -1, 68, 2, 153, 15, 153, - 61, 153, - 67, 153, + 62, 153, + 68, 153, -2, 114, - -1, 188, - 12, 197, - 13, 197, - 16, 197, - 17, 197, - 23, 197, - 26, 197, - 32, 197, - 33, 197, - 36, 197, - 42, 197, - 46, 197, - 47, 197, - 48, 197, - 49, 197, - 50, 197, - 51, 197, - 52, 197, - 53, 197, - 54, 197, - 55, 197, - 56, 197, - 57, 197, - 61, 197, - 65, 197, - 67, 197, - 70, 197, - 71, 197, + -1, 69, + 2, 154, + 15, 154, + 62, 154, + 68, 154, + -2, 115, + -1, 190, + 12, 198, + 13, 198, + 16, 198, + 17, 198, + 23, 198, + 26, 198, + 32, 198, + 33, 198, + 36, 198, + 42, 198, + 47, 198, + 48, 198, + 49, 198, + 50, 198, + 51, 198, + 52, 198, + 53, 198, + 54, 198, + 55, 198, + 56, 198, + 57, 198, + 58, 198, + 62, 198, + 66, 198, + 68, 198, + 71, 198, + 72, 198, -2, 0, - -1, 189, - 12, 197, - 13, 197, - 16, 197, - 17, 197, - 23, 197, - 26, 197, - 32, 197, - 33, 197, - 36, 197, - 42, 197, - 46, 197, - 47, 197, - 48, 197, - 49, 197, - 50, 197, - 51, 197, - 52, 197, - 53, 197, - 54, 197, - 55, 197, - 56, 197, - 57, 197, - 61, 197, - 65, 197, - 67, 197, - 70, 197, - 71, 197, + -1, 191, + 12, 198, + 13, 198, + 16, 198, + 17, 198, + 23, 198, + 26, 198, + 32, 198, + 33, 198, + 36, 198, + 42, 198, + 47, 198, + 48, 198, + 49, 198, + 50, 198, + 51, 198, + 52, 198, + 53, 198, + 54, 198, + 55, 198, + 56, 198, + 57, 198, + 58, 198, + 62, 198, + 66, 198, + 68, 198, + 71, 198, + 72, 198, -2, 0, - -1, 209, - 19, 195, - -2, 0, - -1, 258, + -1, 212, 19, 196, -2, 0, + -1, 261, + 19, 197, + -2, 0, } const yyPrivate = 57344 -const yyLast = 654 +const yyLast = 649 var yyAct = [...]int{ - 264, 37, 213, 140, 254, 253, 148, 112, 77, 101, - 100, 146, 186, 103, 187, 188, 189, 6, 102, 104, - 125, 267, 248, 147, 57, 99, 151, 247, 120, 51, - 72, 105, 53, 22, 52, 152, 72, 163, 265, 256, - 54, 268, 249, 70, 152, 243, 151, 205, 246, 18, - 19, 153, 95, 20, 98, 107, 105, 108, 242, 71, - 153, 106, 121, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 178, 97, 103, 13, 149, - 150, 109, 24, 104, 30, 33, 142, 31, 32, 2, - 3, 4, 5, 143, 210, 262, 177, 7, 209, 143, - 261, 168, 269, 154, 114, 79, 167, 164, 158, 161, - 156, 208, 157, 260, 113, 78, 48, 166, 81, 34, - 244, 175, 73, 185, 1, 176, 141, 184, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, - 202, 203, 257, 47, 183, 204, 126, 127, 128, 129, - 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, - 160, 46, 170, 117, 171, 259, 8, 119, 116, 118, - 35, 155, 143, 159, 114, 245, 206, 207, 143, 115, - 36, 99, 51, 72, 113, 53, 22, 52, 250, 173, - 111, 251, 252, 54, 83, 255, 70, 10, 45, 172, - 174, 44, 18, 19, 92, 93, 20, 74, 95, 124, - 98, 56, 71, 258, 9, 9, 58, 59, 60, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 215, 43, - 42, 13, 97, 79, 41, 24, 122, 30, 225, 162, - 31, 32, 231, 78, 40, 263, 270, 123, 180, 76, - 266, 39, 38, 49, 144, 182, 181, 80, 227, 228, - 151, 179, 229, 211, 271, 75, 145, 55, 272, 152, - 214, 169, 216, 218, 220, 221, 222, 230, 232, 235, - 236, 237, 238, 239, 50, 153, 217, 219, 223, 224, - 226, 233, 234, 110, 0, 0, 240, 241, 51, 72, - 0, 53, 22, 52, 0, 0, 0, 0, 0, 54, - 0, 0, 70, 0, 0, 0, 0, 0, 18, 19, - 0, 0, 20, 0, 0, 0, 0, 0, 71, 0, - 0, 0, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 69, 215, 0, 0, 13, 0, 0, - 0, 24, 0, 30, 225, 0, 31, 32, 231, 0, - 0, 0, 212, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 227, 228, 0, 0, 229, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 216, 218, - 220, 221, 222, 230, 232, 235, 236, 237, 238, 239, - 0, 0, 217, 219, 223, 224, 226, 233, 234, 0, - 17, 72, 240, 241, 22, 0, 0, 0, 0, 0, + 267, 37, 216, 142, 257, 256, 150, 113, 77, 102, + 101, 104, 148, 188, 126, 189, 270, 105, 6, 103, + 190, 191, 252, 149, 154, 251, 57, 153, 250, 121, + 51, 72, 106, 53, 22, 52, 154, 180, 165, 259, + 155, 54, 271, 145, 70, 268, 246, 153, 208, 249, + 18, 19, 155, 106, 20, 108, 144, 109, 179, 245, + 71, 107, 72, 145, 122, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 33, 7, 104, + 13, 151, 152, 110, 24, 105, 30, 162, 272, 31, + 32, 2, 3, 4, 5, 213, 143, 265, 170, 212, + 161, 48, 264, 169, 156, 34, 115, 73, 166, 160, + 163, 158, 211, 159, 168, 263, 114, 100, 262, 120, + 157, 119, 247, 81, 187, 145, 178, 145, 186, 192, + 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, + 203, 204, 205, 206, 96, 185, 99, 207, 127, 128, + 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, + 139, 140, 141, 10, 172, 79, 173, 1, 56, 98, + 115, 9, 9, 74, 260, 78, 47, 248, 209, 210, + 114, 177, 36, 100, 51, 72, 112, 53, 22, 52, + 253, 175, 46, 254, 255, 54, 84, 258, 70, 79, + 45, 174, 176, 44, 18, 19, 93, 94, 20, 78, + 96, 125, 99, 83, 71, 76, 261, 43, 42, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, + 69, 218, 8, 41, 13, 98, 35, 123, 24, 164, + 30, 228, 40, 31, 32, 234, 124, 39, 266, 273, + 118, 182, 38, 269, 49, 117, 146, 183, 184, 80, + 181, 230, 231, 153, 214, 232, 116, 274, 75, 147, + 55, 275, 154, 217, 171, 50, 219, 221, 223, 224, + 225, 233, 235, 238, 239, 240, 241, 242, 155, 111, + 220, 222, 226, 227, 229, 236, 237, 0, 0, 0, + 243, 244, 51, 72, 0, 53, 22, 52, 0, 0, + 0, 0, 0, 54, 0, 0, 70, 0, 0, 0, + 0, 0, 18, 19, 0, 0, 20, 0, 0, 0, + 0, 0, 71, 0, 0, 0, 0, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67, 68, 69, 218, + 0, 0, 13, 0, 0, 0, 24, 0, 30, 228, + 0, 31, 32, 234, 0, 0, 0, 215, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 230, + 231, 0, 0, 232, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 219, 221, 223, 224, 225, 233, + 235, 238, 239, 240, 241, 242, 0, 0, 220, 222, + 226, 227, 229, 236, 237, 0, 17, 72, 243, 244, + 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 18, 19, 0, 0, + 20, 0, 0, 17, 33, 0, 0, 22, 0, 0, + 0, 11, 12, 14, 15, 16, 21, 23, 25, 26, + 27, 28, 29, 18, 19, 0, 13, 20, 0, 0, + 24, 0, 30, 0, 0, 31, 32, 0, 11, 12, + 14, 15, 16, 21, 23, 25, 26, 27, 28, 29, + 0, 0, 100, 13, 0, 0, 0, 24, 167, 30, + 0, 0, 31, 32, 82, 84, 85, 0, 86, 87, + 88, 89, 90, 91, 92, 93, 94, 95, 100, 96, + 97, 99, 83, 0, 0, 0, 0, 0, 0, 0, + 82, 84, 85, 0, 86, 87, 88, 89, 90, 91, + 92, 93, 94, 95, 98, 96, 97, 99, 83, 0, + 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 82, 84, 85, 0, 86, 87, 88, + 98, 90, 91, 92, 93, 94, 95, 100, 96, 97, + 99, 83, 0, 0, 0, 0, 0, 0, 0, 82, + 84, 85, 0, 86, 87, 0, 100, 90, 91, 0, + 93, 94, 95, 98, 96, 97, 99, 83, 82, 84, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, + 94, 0, 0, 96, 97, 99, 83, 0, 0, 98, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 18, 19, 0, 0, 20, 0, 17, 33, 0, 0, - 22, 0, 0, 0, 11, 12, 14, 15, 16, 21, - 23, 25, 26, 27, 28, 29, 18, 19, 0, 13, - 20, 0, 0, 24, 0, 30, 0, 0, 31, 32, - 11, 12, 14, 15, 16, 21, 23, 25, 26, 27, - 28, 29, 0, 0, 99, 13, 0, 0, 0, 24, - 165, 30, 0, 0, 31, 32, 82, 83, 84, 0, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 0, 95, 96, 98, 0, 0, 0, 0, 0, 0, - 99, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 82, 83, 84, 97, 85, 86, 87, 88, - 89, 90, 91, 92, 93, 94, 0, 95, 96, 98, - 0, 0, 99, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 82, 83, 84, 0, 85, 86, - 87, 97, 89, 90, 91, 92, 93, 94, 0, 95, - 96, 98, 0, 0, 99, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 82, 83, 84, 0, - 85, 86, 99, 97, 89, 90, 0, 92, 93, 94, - 0, 95, 96, 98, 82, 83, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 92, 93, 0, 0, 95, - 96, 98, 0, 0, 0, 97, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 97, + 0, 0, 0, 0, 0, 0, 0, 0, 98, } var yyPact = [...]int{ - 15, 87, 424, 424, 170, 398, -1000, -1000, -1000, 72, + 16, 68, 431, 431, 172, 404, -1000, -1000, -1000, 64, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, 231, -1000, 116, -1000, 506, -1000, -1000, + -1000, -1000, -1000, 197, -1000, 121, -1000, 504, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - 16, 41, -1000, 286, -1000, 286, 23, -1000, -1000, -1000, + 17, 38, -1000, 290, -1000, 290, 49, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, 172, -1000, -1000, 161, -1000, -1000, 165, -1000, - 6, -1000, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, 84, 9, 169, - 41, -48, -1000, 158, 158, 17, -1000, 470, 11, -1000, - 99, -1000, -1000, 160, -1000, -1000, 103, -1000, 73, -1000, - 243, 286, -1000, -52, -47, -1000, 286, 286, 286, 286, - 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, - -1000, 90, -1000, -1000, -1000, 32, -1000, -1000, -1000, -1000, - -1000, -1000, 29, 29, 92, -1000, -1000, -1000, -1000, 342, - -1000, -1000, 38, -1000, 506, -1000, -1000, 102, -1000, 25, - -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -2, 18, -1000, -1000, -1000, 167, 158, 158, 158, 158, - 11, 588, 588, 588, 570, 538, 588, 588, 570, 11, - 11, 588, 11, 167, -1000, 19, -1000, -1000, -1000, 163, - -1000, 93, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, 168, -1000, -1000, 248, -1000, -1000, 117, -1000, + 7, -1000, -47, -47, -47, -47, -47, -47, -47, -47, + -47, -47, -47, -47, -47, -47, -47, -47, 54, 10, + 118, 38, -51, -1000, 85, 85, 18, -1000, 478, 103, + -1000, 96, -1000, -1000, 162, -1000, -1000, 163, -1000, 35, + -1000, 246, 290, -1000, -52, -43, -1000, 290, 290, 290, + 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, + 290, 290, -1000, 34, -1000, -1000, -1000, 33, -1000, -1000, + -1000, -1000, -1000, -1000, 30, 30, 93, -1000, -1000, -1000, + -1000, 347, -1000, -1000, 39, -1000, 504, -1000, -1000, 104, + -1000, 26, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, + -1000, -1000, 1, -2, -1000, -1000, -1000, 169, 85, 85, + 85, 85, 103, 103, 582, 582, 582, 563, 537, 582, + 582, 563, 103, 103, 582, 103, 169, -1000, 19, -1000, + -1000, -1000, 116, -1000, 95, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, 286, -1000, -1000, -1000, -1000, 21, 21, - -3, -1000, -1000, -1000, -1000, -1000, -1000, 22, 100, -1000, - -1000, 226, -1000, 506, -1000, -1000, -1000, 21, -1000, -1000, - -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, -1000, 290, -1000, -1000, -1000, + -1000, 28, 28, -8, -1000, -1000, -1000, -1000, -1000, -1000, + 23, 86, -1000, -1000, 229, -1000, 504, -1000, -1000, -1000, + 28, -1000, -1000, -1000, -1000, -1000, } var yyPgo = [...]int{ - 0, 293, 7, 284, 2, 271, 270, 211, 267, 266, - 197, 265, 166, 8, 263, 4, 5, 261, 257, 0, - 23, 256, 6, 254, 253, 252, 10, 62, 251, 247, - 1, 244, 239, 9, 236, 24, 234, 230, 229, 209, - 201, 198, 161, 143, 116, 3, 142, 124, 119, + 0, 289, 7, 275, 2, 274, 273, 168, 270, 269, + 163, 268, 232, 8, 264, 4, 5, 260, 259, 0, + 23, 257, 6, 256, 254, 252, 10, 64, 247, 246, + 1, 242, 239, 9, 237, 26, 233, 218, 217, 211, + 203, 200, 192, 176, 101, 3, 174, 167, 105, } var yyR1 = [...]int{ @@ -463,22 +464,22 @@ var yyR1 = [...]int{ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 25, 25, 25, 25, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 27, 29, 29, 39, 39, 34, 34, 34, 34, - 15, 15, 15, 15, 14, 14, 14, 4, 4, 31, - 33, 33, 32, 32, 32, 40, 38, 38, 38, 24, - 24, 24, 9, 9, 36, 42, 42, 42, 42, 42, - 43, 44, 44, 44, 35, 35, 35, 1, 1, 1, - 2, 2, 2, 2, 12, 12, 7, 7, 7, 7, + 28, 28, 27, 29, 29, 39, 39, 34, 34, 34, + 34, 15, 15, 15, 15, 14, 14, 14, 4, 4, + 31, 33, 33, 32, 32, 32, 40, 38, 38, 38, + 24, 24, 24, 9, 9, 36, 42, 42, 42, 42, + 42, 43, 44, 44, 44, 35, 35, 35, 1, 1, + 1, 2, 2, 2, 2, 12, 12, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 10, 10, - 10, 10, 11, 11, 11, 13, 13, 13, 13, 48, - 18, 18, 18, 18, 17, 17, 17, 17, 17, 21, - 21, 21, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 10, + 10, 10, 10, 11, 11, 11, 13, 13, 13, 13, + 48, 18, 18, 18, 18, 17, 17, 17, 17, 17, + 21, 21, 21, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 8, 8, 5, 5, 5, 5, 37, 20, 22, 22, - 23, 23, 19, 45, 41, 46, 46, 16, 16, + 6, 8, 8, 5, 5, 5, 5, 37, 20, 22, + 22, 23, 23, 19, 45, 41, 46, 46, 16, 16, } var yyR2 = [...]int{ @@ -486,84 +487,84 @@ var yyR2 = [...]int{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 1, 0, 1, 3, 3, 1, 1, 3, 3, - 3, 4, 2, 1, 3, 1, 2, 1, 1, 2, - 3, 2, 3, 1, 2, 3, 3, 4, 3, 3, - 5, 3, 1, 1, 4, 6, 6, 5, 4, 3, - 2, 2, 1, 1, 3, 4, 2, 3, 1, 2, - 3, 3, 2, 1, 2, 1, 1, 1, 1, 1, + 4, 4, 1, 0, 1, 3, 3, 1, 1, 3, + 3, 3, 4, 2, 1, 3, 1, 2, 1, 1, + 2, 3, 2, 3, 1, 2, 3, 3, 4, 3, + 3, 5, 3, 1, 1, 4, 6, 6, 5, 4, + 3, 2, 2, 1, 1, 3, 4, 2, 3, 1, + 2, 3, 3, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, - 2, 0, 3, 1, 2, 3, 3, 2, 1, 2, - 0, 3, 2, 1, 1, 3, 1, 3, 4, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, + 4, 2, 0, 3, 1, 2, 3, 3, 2, 1, + 2, 0, 3, 2, 1, 1, 3, 1, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, - 1, 1, 1, 1, 1, 0, 1, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 2, 1, 1, 1, 1, 1, 0, 1, 0, 1, } var yyChk = [...]int{ - -1000, -47, 74, 75, 76, 77, 2, 10, -12, -7, - -10, 46, 47, 61, 48, 49, 50, 12, 32, 33, - 36, 51, 16, 52, 65, 53, 54, 55, 56, 57, - 67, 70, 71, 13, -48, -12, 10, -30, -25, -28, + -1000, -47, 75, 76, 77, 78, 2, 10, -12, -7, + -10, 47, 48, 62, 49, 50, 51, 12, 32, 33, + 36, 52, 16, 53, 66, 54, 55, 56, 57, 58, + 68, 71, 72, 13, -48, -12, 10, -30, -25, -28, -31, -36, -37, -38, -40, -41, -42, -43, -44, -24, - -3, 12, 17, 15, 23, -8, -7, -35, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + -3, 12, 17, 15, 23, -8, -7, -35, 47, 48, + 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 26, 42, 13, -44, -10, -11, 18, -13, 12, 2, - -18, 2, 26, 27, 28, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 41, 42, 65, 43, 14, - -26, -33, 2, 61, 67, 15, -33, -30, -30, -35, - -1, 18, -2, 12, 2, 18, 7, 2, 4, 2, - 22, -27, -34, -29, -39, 60, -27, -27, -27, -27, + -18, 2, 26, 44, 27, 28, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 41, 42, 66, 43, + 14, -26, -33, 2, 62, 68, 15, -33, -30, -30, + -35, -1, 18, -2, 12, 2, 18, 7, 2, 4, + 2, 22, -27, -34, -29, -39, 61, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, - -45, 42, 2, 9, -23, -9, 2, -20, -22, 70, - 71, 17, 26, 42, -45, 2, -33, -26, -15, 15, - 2, -15, -32, 20, -30, 20, 18, 7, 2, -5, - 2, 4, 39, 29, 40, 18, -13, 23, 2, -17, - 5, -21, 12, -20, -22, -30, 64, 66, 62, 63, - -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -45, 15, -20, -20, 19, 6, - 2, -14, 20, -4, -6, 2, 46, 60, 47, 61, - 48, 49, 50, 62, 63, 12, 64, 32, 33, 36, - 51, 16, 52, 65, 66, 53, 54, 55, 56, 57, - 70, 71, 20, 7, 18, -2, 23, 2, 24, 24, - -22, -15, -15, -16, -15, -16, 20, -46, -45, 2, - 20, 7, 2, -30, -19, 17, -19, 24, 19, 2, - 20, -4, -19, + -27, -27, -45, 42, 2, 9, -23, -9, 2, -20, + -22, 71, 72, 17, 26, 42, -45, 2, -33, -26, + -15, 15, 2, -15, -32, 20, -30, 20, 18, 7, + 2, -5, 2, 4, 39, 29, 40, 18, -13, 23, + 2, -17, 5, -21, 12, -20, -22, -30, 65, 67, + 63, 64, -30, -30, -30, -30, -30, -30, -30, -30, + -30, -30, -30, -30, -30, -30, -30, -45, 15, -20, + -20, 19, 6, 2, -14, 20, -4, -6, 2, 47, + 61, 48, 62, 49, 50, 51, 63, 64, 12, 65, + 32, 33, 36, 52, 16, 53, 66, 67, 54, 55, + 56, 57, 58, 71, 72, 20, 7, 18, -2, 23, + 2, 24, 24, -22, -15, -15, -16, -15, -16, 20, + -46, -45, 2, 20, 7, 2, -30, -19, 17, -19, + 24, 19, 2, 20, -4, -19, } var yyDef = [...]int{ - 0, -2, 121, 121, 0, 0, 7, 6, 1, 121, - 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, - 115, 116, 117, 0, 2, -2, 3, 4, 8, 9, + 0, -2, 122, 122, 0, 0, 7, 6, 1, 122, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, + 116, 117, 118, 0, 2, -2, 3, 4, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 0, 102, 186, 0, 194, 0, 82, 83, -2, -2, + 0, 103, 187, 0, 195, 0, 83, 84, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, - 180, 181, 0, 5, 94, 0, 120, 123, 0, 128, - 129, 133, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 0, 0, 0, - 0, 22, 23, 0, 0, 0, 59, 0, 80, 81, - 0, 86, 88, 0, 93, 118, 0, 124, 0, 127, - 132, 0, 41, 46, 47, 43, 0, 0, 0, 0, + 181, 182, 0, 5, 95, 0, 121, 124, 0, 129, + 130, 134, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 0, 0, + 0, 0, 22, 23, 0, 0, 0, 60, 0, 81, + 82, 0, 87, 89, 0, 94, 119, 0, 125, 0, + 128, 133, 0, 42, 47, 48, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 66, 0, 68, 193, 69, 0, 71, 190, 191, 72, - 73, 187, 0, 0, 0, 79, 20, 21, 24, 0, - 53, 25, 0, 61, 63, 65, 84, 0, 89, 0, - 92, 182, 183, 184, 185, 119, 122, 125, 126, 131, - 134, 136, 139, 140, 141, 26, 0, 0, -2, -2, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 67, 0, 188, 189, 74, -2, - 78, 0, 52, 55, 57, 58, 154, 155, 156, 157, - 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, - 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, - 178, 179, 60, 64, 85, 87, 90, 91, 0, 0, - 0, 44, 45, 48, 198, 49, 70, 0, -2, 77, - 50, 0, 56, 62, 135, 192, 137, 0, 75, 76, - 51, 54, 138, + 0, 0, 67, 0, 69, 194, 70, 0, 72, 191, + 192, 73, 74, 188, 0, 0, 0, 80, 20, 21, + 24, 0, 54, 25, 0, 62, 64, 66, 85, 0, + 90, 0, 93, 183, 184, 185, 186, 120, 123, 126, + 127, 132, 135, 137, 140, 141, 142, 26, 0, 0, + -2, -2, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 68, 0, 189, + 190, 75, -2, 79, 0, 53, 56, 58, 59, 155, + 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, + 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, + 176, 177, 178, 179, 180, 61, 65, 86, 88, 91, + 92, 0, 0, 0, 45, 46, 49, 199, 50, 71, + 0, -2, 78, 51, 0, 57, 63, 136, 193, 138, + 0, 76, 77, 52, 55, 139, } var yyTok1 = [...]int{ @@ -578,7 +579,7 @@ var yyTok2 = [...]int{ 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, + 72, 73, 74, 75, 76, 77, 78, 79, } var yyTok3 = [...]int{ @@ -924,62 +925,62 @@ yydefault: case 1: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:173 +//line promql/parser/generated_parser.y:174 { yylex.(*parser).generatedParserResult = yyDollar[2].labels } case 3: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:176 +//line promql/parser/generated_parser.y:177 { yylex.(*parser).addParseErrf(PositionRange{}, "no expression found in input") } case 4: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:178 +//line promql/parser/generated_parser.y:179 { yylex.(*parser).generatedParserResult = yyDollar[2].node } case 5: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:180 +//line promql/parser/generated_parser.y:181 { yylex.(*parser).generatedParserResult = yyDollar[2].node } case 7: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:183 +//line promql/parser/generated_parser.y:184 { yylex.(*parser).unexpected("", "") } case 20: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:206 +//line promql/parser/generated_parser.y:207 { yyVAL.node = yylex.(*parser).newAggregateExpr(yyDollar[1].item, yyDollar[2].node, yyDollar[3].node) } case 21: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:208 +//line promql/parser/generated_parser.y:209 { yyVAL.node = yylex.(*parser).newAggregateExpr(yyDollar[1].item, yyDollar[3].node, yyDollar[2].node) } case 22: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:210 +//line promql/parser/generated_parser.y:211 { yyVAL.node = yylex.(*parser).newAggregateExpr(yyDollar[1].item, &AggregateExpr{}, yyDollar[2].node) } case 23: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:212 +//line promql/parser/generated_parser.y:213 { yylex.(*parser).unexpected("aggregation", "") yyVAL.node = yylex.(*parser).newAggregateExpr(yyDollar[1].item, &AggregateExpr{}, Expressions{}) } case 24: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:220 +//line promql/parser/generated_parser.y:221 { yyVAL.node = &AggregateExpr{ Grouping: yyDollar[2].strings, @@ -987,7 +988,7 @@ yydefault: } case 25: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:226 +//line promql/parser/generated_parser.y:227 { yyVAL.node = &AggregateExpr{ Grouping: yyDollar[2].strings, @@ -996,205 +997,211 @@ yydefault: } case 26: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:239 +//line promql/parser/generated_parser.y:240 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 27: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:240 +//line promql/parser/generated_parser.y:241 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 28: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:241 +//line promql/parser/generated_parser.y:242 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 29: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:242 +//line promql/parser/generated_parser.y:243 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 30: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:243 +//line promql/parser/generated_parser.y:244 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 31: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:244 +//line promql/parser/generated_parser.y:245 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 32: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:245 +//line promql/parser/generated_parser.y:246 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 33: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:246 +//line promql/parser/generated_parser.y:247 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 34: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:247 +//line promql/parser/generated_parser.y:248 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 35: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:248 +//line promql/parser/generated_parser.y:249 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 36: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:249 +//line promql/parser/generated_parser.y:250 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 37: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:250 +//line promql/parser/generated_parser.y:251 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 38: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:251 +//line promql/parser/generated_parser.y:252 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 39: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:252 +//line promql/parser/generated_parser.y:253 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } case 40: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:253 +//line promql/parser/generated_parser.y:254 { yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) } - case 42: + case 41: + yyDollar = yyS[yypt-4 : yypt+1] +//line promql/parser/generated_parser.y:255 + { + yyVAL.node = yylex.(*parser).newBinaryExpression(yyDollar[1].node, yyDollar[2].item, yyDollar[3].node, yyDollar[4].node) + } + case 43: yyDollar = yyS[yypt-0 : yypt+1] -//line generated_parser.y:261 +//line promql/parser/generated_parser.y:263 { yyVAL.node = &BinaryExpr{ VectorMatching: &VectorMatching{Card: CardOneToOne}, } } - case 43: + case 44: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:266 +//line promql/parser/generated_parser.y:268 { yyVAL.node = &BinaryExpr{ VectorMatching: &VectorMatching{Card: CardOneToOne}, ReturnBool: true, } } - case 44: + case 45: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:274 +//line promql/parser/generated_parser.y:276 { yyVAL.node = yyDollar[1].node yyVAL.node.(*BinaryExpr).VectorMatching.MatchingLabels = yyDollar[3].strings } - case 45: + case 46: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:279 +//line promql/parser/generated_parser.y:281 { yyVAL.node = yyDollar[1].node yyVAL.node.(*BinaryExpr).VectorMatching.MatchingLabels = yyDollar[3].strings yyVAL.node.(*BinaryExpr).VectorMatching.On = true } - case 48: + case 49: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:289 +//line promql/parser/generated_parser.y:291 { yyVAL.node = yyDollar[1].node yyVAL.node.(*BinaryExpr).VectorMatching.Card = CardManyToOne yyVAL.node.(*BinaryExpr).VectorMatching.Include = yyDollar[3].strings } - case 49: + case 50: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:295 +//line promql/parser/generated_parser.y:297 { yyVAL.node = yyDollar[1].node yyVAL.node.(*BinaryExpr).VectorMatching.Card = CardOneToMany yyVAL.node.(*BinaryExpr).VectorMatching.Include = yyDollar[3].strings } - case 50: - yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:304 - { - yyVAL.strings = yyDollar[2].strings - } case 51: - yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:306 + yyDollar = yyS[yypt-3 : yypt+1] +//line promql/parser/generated_parser.y:306 { yyVAL.strings = yyDollar[2].strings } case 52: + yyDollar = yyS[yypt-4 : yypt+1] +//line promql/parser/generated_parser.y:308 + { + yyVAL.strings = yyDollar[2].strings + } + case 53: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:308 +//line promql/parser/generated_parser.y:310 { yyVAL.strings = []string{} } - case 53: + case 54: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:310 +//line promql/parser/generated_parser.y:312 { yylex.(*parser).unexpected("grouping opts", "\"(\"") yyVAL.strings = nil } - case 54: + case 55: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:316 +//line promql/parser/generated_parser.y:318 { yyVAL.strings = append(yyDollar[1].strings, yyDollar[3].item.Val) } - case 55: + case 56: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:318 +//line promql/parser/generated_parser.y:320 { yyVAL.strings = []string{yyDollar[1].item.Val} } - case 56: + case 57: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:320 +//line promql/parser/generated_parser.y:322 { yylex.(*parser).unexpected("grouping opts", "\",\" or \")\"") yyVAL.strings = yyDollar[1].strings } - case 57: + case 58: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:324 +//line promql/parser/generated_parser.y:326 { if !isLabel(yyDollar[1].item.Val) { yylex.(*parser).unexpected("grouping opts", "label") } yyVAL.item = yyDollar[1].item } - case 58: + case 59: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:331 +//line promql/parser/generated_parser.y:333 { yylex.(*parser).unexpected("grouping opts", "label") yyVAL.item = Item{} } - case 59: + case 60: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:339 +//line promql/parser/generated_parser.y:341 { fn, exist := getFunction(yyDollar[1].item.Val) if !exist { @@ -1209,88 +1216,88 @@ yydefault: }, } } - case 60: + case 61: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:356 +//line promql/parser/generated_parser.y:358 { yyVAL.node = yyDollar[2].node } - case 61: + case 62: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:358 +//line promql/parser/generated_parser.y:360 { yyVAL.node = Expressions{} } - case 62: + case 63: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:362 +//line promql/parser/generated_parser.y:364 { yyVAL.node = append(yyDollar[1].node.(Expressions), yyDollar[3].node.(Expr)) } - case 63: + case 64: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:364 +//line promql/parser/generated_parser.y:366 { yyVAL.node = Expressions{yyDollar[1].node.(Expr)} } - case 64: + case 65: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:366 +//line promql/parser/generated_parser.y:368 { yylex.(*parser).addParseErrf(yyDollar[2].item.PositionRange(), "trailing commas not allowed in function call args") yyVAL.node = yyDollar[1].node } - case 65: + case 66: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:377 +//line promql/parser/generated_parser.y:379 { yyVAL.node = &ParenExpr{Expr: yyDollar[2].node.(Expr), PosRange: mergeRanges(&yyDollar[1].item, &yyDollar[3].item)} } - case 66: + case 67: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:385 +//line promql/parser/generated_parser.y:387 { yylex.(*parser).addOffset(yyDollar[1].node, yyDollar[3].duration) yyVAL.node = yyDollar[1].node } - case 67: + case 68: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:390 +//line promql/parser/generated_parser.y:392 { yylex.(*parser).addOffset(yyDollar[1].node, -yyDollar[4].duration) yyVAL.node = yyDollar[1].node } - case 68: + case 69: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:395 +//line promql/parser/generated_parser.y:397 { yylex.(*parser).unexpected("offset", "duration") yyVAL.node = yyDollar[1].node } - case 69: + case 70: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:402 +//line promql/parser/generated_parser.y:404 { yylex.(*parser).setTimestamp(yyDollar[1].node, yyDollar[3].float) yyVAL.node = yyDollar[1].node } - case 70: + case 71: yyDollar = yyS[yypt-5 : yypt+1] -//line generated_parser.y:407 +//line promql/parser/generated_parser.y:409 { yylex.(*parser).setAtModifierPreprocessor(yyDollar[1].node, yyDollar[3].item) yyVAL.node = yyDollar[1].node } - case 71: + case 72: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:412 +//line promql/parser/generated_parser.y:414 { yylex.(*parser).unexpected("@", "timestamp") yyVAL.node = yyDollar[1].node } - case 74: + case 75: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:422 +//line promql/parser/generated_parser.y:424 { var errMsg string vs, ok := yyDollar[1].node.(*VectorSelector) @@ -1313,9 +1320,9 @@ yydefault: EndPos: yylex.(*parser).lastClosing, } } - case 75: + case 76: yyDollar = yyS[yypt-6 : yypt+1] -//line generated_parser.y:447 +//line promql/parser/generated_parser.y:449 { yyVAL.node = &SubqueryExpr{ Expr: yyDollar[1].node.(Expr), @@ -1325,37 +1332,37 @@ yydefault: EndPos: yyDollar[6].item.Pos + 1, } } - case 76: + case 77: yyDollar = yyS[yypt-6 : yypt+1] -//line generated_parser.y:457 +//line promql/parser/generated_parser.y:459 { yylex.(*parser).unexpected("subquery selector", "\"]\"") yyVAL.node = yyDollar[1].node } - case 77: + case 78: yyDollar = yyS[yypt-5 : yypt+1] -//line generated_parser.y:459 +//line promql/parser/generated_parser.y:461 { yylex.(*parser).unexpected("subquery selector", "duration or \"]\"") yyVAL.node = yyDollar[1].node } - case 78: + case 79: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:461 +//line promql/parser/generated_parser.y:463 { yylex.(*parser).unexpected("subquery or range", "\":\" or \"]\"") yyVAL.node = yyDollar[1].node } - case 79: + case 80: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:463 +//line promql/parser/generated_parser.y:465 { yylex.(*parser).unexpected("subquery selector", "duration") yyVAL.node = yyDollar[1].node } - case 80: + case 81: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:473 +//line promql/parser/generated_parser.y:475 { if nl, ok := yyDollar[2].node.(*NumberLiteral); ok { if yyDollar[1].item.Typ == SUB { @@ -1367,9 +1374,9 @@ yydefault: yyVAL.node = &UnaryExpr{Op: yyDollar[1].item.Typ, Expr: yyDollar[2].node.(Expr), StartPos: yyDollar[1].item.Pos} } } - case 81: + case 82: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:491 +//line promql/parser/generated_parser.y:493 { vs := yyDollar[2].node.(*VectorSelector) vs.PosRange = mergeRanges(&yyDollar[1].item, vs) @@ -1377,9 +1384,9 @@ yydefault: yylex.(*parser).assembleVectorSelector(vs) yyVAL.node = vs } - case 82: + case 83: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:499 +//line promql/parser/generated_parser.y:501 { vs := &VectorSelector{ Name: yyDollar[1].item.Val, @@ -1389,44 +1396,44 @@ yydefault: yylex.(*parser).assembleVectorSelector(vs) yyVAL.node = vs } - case 83: + case 84: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:509 +//line promql/parser/generated_parser.y:511 { vs := yyDollar[1].node.(*VectorSelector) yylex.(*parser).assembleVectorSelector(vs) yyVAL.node = vs } - case 84: + case 85: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:517 +//line promql/parser/generated_parser.y:519 { yyVAL.node = &VectorSelector{ LabelMatchers: yyDollar[2].matchers, PosRange: mergeRanges(&yyDollar[1].item, &yyDollar[3].item), } } - case 85: + case 86: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:524 +//line promql/parser/generated_parser.y:526 { yyVAL.node = &VectorSelector{ LabelMatchers: yyDollar[2].matchers, PosRange: mergeRanges(&yyDollar[1].item, &yyDollar[4].item), } } - case 86: + case 87: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:531 +//line promql/parser/generated_parser.y:533 { yyVAL.node = &VectorSelector{ LabelMatchers: []*labels.Matcher{}, PosRange: mergeRanges(&yyDollar[1].item, &yyDollar[2].item), } } - case 87: + case 88: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:540 +//line promql/parser/generated_parser.y:542 { if yyDollar[1].matchers != nil { yyVAL.matchers = append(yyDollar[1].matchers, yyDollar[3].matcher) @@ -1434,196 +1441,196 @@ yydefault: yyVAL.matchers = yyDollar[1].matchers } } - case 88: + case 89: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:548 +//line promql/parser/generated_parser.y:550 { yyVAL.matchers = []*labels.Matcher{yyDollar[1].matcher} } - case 89: + case 90: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:550 +//line promql/parser/generated_parser.y:552 { yylex.(*parser).unexpected("label matching", "\",\" or \"}\"") yyVAL.matchers = yyDollar[1].matchers } - case 90: + case 91: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:554 +//line promql/parser/generated_parser.y:556 { yyVAL.matcher = yylex.(*parser).newLabelMatcher(yyDollar[1].item, yyDollar[2].item, yyDollar[3].item) } - case 91: + case 92: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:556 +//line promql/parser/generated_parser.y:558 { yylex.(*parser).unexpected("label matching", "string") yyVAL.matcher = nil } - case 92: + case 93: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:558 +//line promql/parser/generated_parser.y:560 { yylex.(*parser).unexpected("label matching", "label matching operator") yyVAL.matcher = nil } - case 93: + case 94: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:560 +//line promql/parser/generated_parser.y:562 { yylex.(*parser).unexpected("label matching", "identifier or \"}\"") yyVAL.matcher = nil } - case 94: + case 95: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:568 +//line promql/parser/generated_parser.y:570 { yyVAL.labels = append(yyDollar[2].labels, labels.Label{Name: labels.MetricName, Value: yyDollar[1].item.Val}) sort.Sort(yyVAL.labels) } - case 95: + case 96: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:570 +//line promql/parser/generated_parser.y:572 { yyVAL.labels = yyDollar[1].labels } - case 118: - yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:577 - { - yyVAL.labels = labels.New(yyDollar[2].labels...) - } case 119: - yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:579 + yyDollar = yyS[yypt-3 : yypt+1] +//line promql/parser/generated_parser.y:579 { yyVAL.labels = labels.New(yyDollar[2].labels...) } case 120: - yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:581 + yyDollar = yyS[yypt-4 : yypt+1] +//line promql/parser/generated_parser.y:581 { - yyVAL.labels = labels.New() + yyVAL.labels = labels.New(yyDollar[2].labels...) } case 121: - yyDollar = yyS[yypt-0 : yypt+1] -//line generated_parser.y:583 + yyDollar = yyS[yypt-2 : yypt+1] +//line promql/parser/generated_parser.y:583 { yyVAL.labels = labels.New() } case 122: + yyDollar = yyS[yypt-0 : yypt+1] +//line promql/parser/generated_parser.y:585 + { + yyVAL.labels = labels.New() + } + case 123: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:587 +//line promql/parser/generated_parser.y:589 { yyVAL.labels = append(yyDollar[1].labels, yyDollar[3].label) } - case 123: + case 124: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:589 +//line promql/parser/generated_parser.y:591 { yyVAL.labels = []labels.Label{yyDollar[1].label} } - case 124: + case 125: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:591 +//line promql/parser/generated_parser.y:593 { yylex.(*parser).unexpected("label set", "\",\" or \"}\"") yyVAL.labels = yyDollar[1].labels } - case 125: + case 126: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:596 +//line promql/parser/generated_parser.y:598 { yyVAL.label = labels.Label{Name: yyDollar[1].item.Val, Value: yylex.(*parser).unquoteString(yyDollar[3].item.Val)} } - case 126: + case 127: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:598 +//line promql/parser/generated_parser.y:600 { yylex.(*parser).unexpected("label set", "string") yyVAL.label = labels.Label{} } - case 127: + case 128: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:600 +//line promql/parser/generated_parser.y:602 { yylex.(*parser).unexpected("label set", "\"=\"") yyVAL.label = labels.Label{} } - case 128: + case 129: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:602 +//line promql/parser/generated_parser.y:604 { yylex.(*parser).unexpected("label set", "identifier or \"}\"") yyVAL.label = labels.Label{} } - case 129: + case 130: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:610 +//line promql/parser/generated_parser.y:612 { yylex.(*parser).generatedParserResult = &seriesDescription{ labels: yyDollar[1].labels, values: yyDollar[2].series, } } - case 130: + case 131: yyDollar = yyS[yypt-0 : yypt+1] -//line generated_parser.y:619 +//line promql/parser/generated_parser.y:621 { yyVAL.series = []SequenceValue{} } - case 131: + case 132: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:621 +//line promql/parser/generated_parser.y:623 { yyVAL.series = append(yyDollar[1].series, yyDollar[3].series...) } - case 132: + case 133: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:623 +//line promql/parser/generated_parser.y:625 { yyVAL.series = yyDollar[1].series } - case 133: + case 134: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:625 +//line promql/parser/generated_parser.y:627 { yylex.(*parser).unexpected("series values", "") yyVAL.series = nil } - case 134: + case 135: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:629 +//line promql/parser/generated_parser.y:631 { yyVAL.series = []SequenceValue{{Omitted: true}} } - case 135: + case 136: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:631 +//line promql/parser/generated_parser.y:633 { yyVAL.series = []SequenceValue{} for i := uint64(0); i < yyDollar[3].uint; i++ { yyVAL.series = append(yyVAL.series, SequenceValue{Omitted: true}) } } - case 136: + case 137: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:638 +//line promql/parser/generated_parser.y:640 { yyVAL.series = []SequenceValue{{Value: yyDollar[1].float}} } - case 137: + case 138: yyDollar = yyS[yypt-3 : yypt+1] -//line generated_parser.y:640 +//line promql/parser/generated_parser.y:642 { yyVAL.series = []SequenceValue{} for i := uint64(0); i <= yyDollar[3].uint; i++ { yyVAL.series = append(yyVAL.series, SequenceValue{Value: yyDollar[1].float}) } } - case 138: + case 139: yyDollar = yyS[yypt-4 : yypt+1] -//line generated_parser.y:647 +//line promql/parser/generated_parser.y:649 { yyVAL.series = []SequenceValue{} for i := uint64(0); i <= yyDollar[4].uint; i++ { @@ -1631,45 +1638,45 @@ yydefault: yyDollar[1].float += yyDollar[2].float } } - case 139: + case 140: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:657 +//line promql/parser/generated_parser.y:659 { if yyDollar[1].item.Val != "stale" { yylex.(*parser).unexpected("series values", "number or \"stale\"") } yyVAL.float = math.Float64frombits(value.StaleNaN) } - case 186: + case 187: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:688 +//line promql/parser/generated_parser.y:690 { yyVAL.node = &NumberLiteral{ Val: yylex.(*parser).number(yyDollar[1].item.Val), PosRange: yyDollar[1].item.PositionRange(), } } - case 187: + case 188: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:696 +//line promql/parser/generated_parser.y:698 { yyVAL.float = yylex.(*parser).number(yyDollar[1].item.Val) } - case 188: + case 189: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:698 +//line promql/parser/generated_parser.y:700 { yyVAL.float = yyDollar[2].float } - case 189: + case 190: yyDollar = yyS[yypt-2 : yypt+1] -//line generated_parser.y:699 +//line promql/parser/generated_parser.y:701 { yyVAL.float = -yyDollar[2].float } - case 192: + case 193: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:705 +//line promql/parser/generated_parser.y:707 { var err error yyVAL.uint, err = strconv.ParseUint(yyDollar[1].item.Val, 10, 64) @@ -1677,9 +1684,9 @@ yydefault: yylex.(*parser).addParseErrf(yyDollar[1].item.PositionRange(), "invalid repetition in series values: %s", err) } } - case 193: + case 194: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:715 +//line promql/parser/generated_parser.y:717 { var err error yyVAL.duration, err = parseDuration(yyDollar[1].item.Val) @@ -1687,24 +1694,24 @@ yydefault: yylex.(*parser).addParseErr(yyDollar[1].item.PositionRange(), err) } } - case 194: + case 195: yyDollar = yyS[yypt-1 : yypt+1] -//line generated_parser.y:726 +//line promql/parser/generated_parser.y:728 { yyVAL.node = &StringLiteral{ Val: yylex.(*parser).unquoteString(yyDollar[1].item.Val), PosRange: yyDollar[1].item.PositionRange(), } } - case 195: + case 196: yyDollar = yyS[yypt-0 : yypt+1] -//line generated_parser.y:739 +//line promql/parser/generated_parser.y:741 { yyVAL.duration = 0 } - case 197: + case 198: yyDollar = yyS[yypt-0 : yypt+1] -//line generated_parser.y:743 +//line promql/parser/generated_parser.y:745 { yyVAL.strings = nil } diff --git a/promql/parser/lex.go b/promql/parser/lex.go index 313bd8f88..e1dee3356 100644 --- a/promql/parser/lex.go +++ b/promql/parser/lex.go @@ -97,6 +97,7 @@ var key = map[string]ItemType{ "and": LAND, "or": LOR, "unless": LUNLESS, + "atan2": ATAN2, // Aggregators. "sum": SUM,