|
|
|
|
@ -36,7 +36,6 @@ import ( |
|
|
|
|
series []sequenceValue |
|
|
|
|
uint uint64 |
|
|
|
|
float float64 |
|
|
|
|
string string |
|
|
|
|
duration time.Duration |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -127,7 +126,7 @@ START_METRIC_SELECTOR |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Type definitions for grammar rules. |
|
|
|
|
%type <matchers> label_match_list label_matchers |
|
|
|
|
%type <matchers> label_match_list |
|
|
|
|
%type <matcher> label_matcher |
|
|
|
|
|
|
|
|
|
%type <item> aggregate_op grouping_label match_op maybe_label metric_identifier unary_op |
|
|
|
|
@ -138,8 +137,7 @@ START_METRIC_SELECTOR |
|
|
|
|
%type <series> series_item series_values |
|
|
|
|
%type <uint> uint |
|
|
|
|
%type <float> number series_value signed_number |
|
|
|
|
%type <node> aggregate_expr aggregate_modifier bin_modifier binary_expr bool_modifier expr function_call function_call_args function_call_body group_modifiers matrix_selector number_literal offset_expr on_or_ignoring paren_expr string_literal subquery_expr unary_expr vector_selector |
|
|
|
|
%type <string> string |
|
|
|
|
%type <node> aggregate_expr aggregate_modifier bin_modifier binary_expr bool_modifier expr function_call function_call_args function_call_body group_modifiers label_matchers matrix_selector number_literal offset_expr on_or_ignoring paren_expr string_literal subquery_expr unary_expr vector_selector |
|
|
|
|
%type <duration> duration maybe_duration |
|
|
|
|
|
|
|
|
|
%start start |
|
|
|
|
@ -333,6 +331,10 @@ function_call : IDENTIFIER function_call_body |
|
|
|
|
$$ = &Call{ |
|
|
|
|
Func: fn, |
|
|
|
|
Args: $2.(Expressions), |
|
|
|
|
PosRange: PositionRange{ |
|
|
|
|
Start: $1.Pos, |
|
|
|
|
End: yylex.(*parser).lastClosing, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
; |
|
|
|
|
@ -354,7 +356,7 @@ function_call_args: function_call_args COMMA expr |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
paren_expr : LEFT_PAREN expr RIGHT_PAREN |
|
|
|
|
{ $$ = &ParenExpr{Expr: $2.(Expr)} } |
|
|
|
|
{ $$ = &ParenExpr{Expr: $2.(Expr), PosRange: mergeRanges(&$1, &$3)} } |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
@ -386,6 +388,7 @@ matrix_selector : expr LEFT_BRACKET duration RIGHT_BRACKET |
|
|
|
|
$$ = &MatrixSelector{ |
|
|
|
|
VectorSelector: vs, |
|
|
|
|
Range: $3, |
|
|
|
|
EndPos: yylex.(*parser).lastClosing, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
; |
|
|
|
|
@ -396,6 +399,8 @@ subquery_expr : expr LEFT_BRACKET duration COLON maybe_duration RIGHT_BRACKET |
|
|
|
|
Expr: $1.(Expr), |
|
|
|
|
Range: $3, |
|
|
|
|
Step: $5, |
|
|
|
|
|
|
|
|
|
EndPos: $6.Pos + 1, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
| expr LEFT_BRACKET duration COLON duration error |
|
|
|
|
@ -420,9 +425,10 @@ unary_expr : |
|
|
|
|
if $1.Typ == SUB { |
|
|
|
|
nl.Val *= -1 |
|
|
|
|
} |
|
|
|
|
nl.PosRange.Start = $1.Pos |
|
|
|
|
$$ = nl |
|
|
|
|
} else { |
|
|
|
|
$$ = &UnaryExpr{Op: $1.Typ, Expr: $2.(Expr)} |
|
|
|
|
$$ = &UnaryExpr{Op: $1.Typ, Expr: $2.(Expr), StartPos: $1.Pos} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
; |
|
|
|
|
@ -432,20 +438,52 @@ unary_expr : |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
vector_selector: metric_identifier label_matchers |
|
|
|
|
{ $$ = yylex.(*parser).newVectorSelector($1.Val, $2) } |
|
|
|
|
{ |
|
|
|
|
vs := $2.(*VectorSelector) |
|
|
|
|
vs.PosRange = mergeRanges(&$1, vs) |
|
|
|
|
vs.Name = $1.Val |
|
|
|
|
yylex.(*parser).assembleVectorSelector(vs) |
|
|
|
|
$$ = vs |
|
|
|
|
} |
|
|
|
|
| metric_identifier |
|
|
|
|
{ $$ = yylex.(*parser).newVectorSelector($1.Val, nil) } |
|
|
|
|
{ |
|
|
|
|
vs := &VectorSelector{ |
|
|
|
|
Name: $1.Val, |
|
|
|
|
LabelMatchers: []*labels.Matcher{}, |
|
|
|
|
PosRange: $1.PositionRange(), |
|
|
|
|
} |
|
|
|
|
yylex.(*parser).assembleVectorSelector(vs) |
|
|
|
|
$$ = vs |
|
|
|
|
} |
|
|
|
|
| label_matchers |
|
|
|
|
{ $$ = yylex.(*parser).newVectorSelector("", $1) } |
|
|
|
|
{ |
|
|
|
|
vs := $1.(*VectorSelector) |
|
|
|
|
yylex.(*parser).assembleVectorSelector(vs) |
|
|
|
|
$$ = vs |
|
|
|
|
} |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
label_matchers : LEFT_BRACE label_match_list RIGHT_BRACE |
|
|
|
|
{ $$ = $2 } |
|
|
|
|
{ |
|
|
|
|
$$ = &VectorSelector{ |
|
|
|
|
LabelMatchers: $2, |
|
|
|
|
PosRange: mergeRanges(&$1, &$3), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
| LEFT_BRACE label_match_list COMMA RIGHT_BRACE |
|
|
|
|
{ $$ = $2 } |
|
|
|
|
{ |
|
|
|
|
$$ = &VectorSelector{ |
|
|
|
|
LabelMatchers: $2, |
|
|
|
|
PosRange: mergeRanges(&$1, &$4), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
| LEFT_BRACE RIGHT_BRACE |
|
|
|
|
{ $$ = []*labels.Matcher{} } |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
$$ = &VectorSelector{ |
|
|
|
|
LabelMatchers: []*labels.Matcher{}, |
|
|
|
|
PosRange: mergeRanges(&$1, &$2), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
label_match_list: label_match_list COMMA label_matcher |
|
|
|
|
@ -590,7 +628,14 @@ match_op : EQL | NEQ | EQL_REGEX | NEQ_REGEX ; |
|
|
|
|
* Literals. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
number_literal : number { $$ = &NumberLiteral{$1}} ; |
|
|
|
|
number_literal : NUMBER |
|
|
|
|
{ |
|
|
|
|
$$ = &NumberLiteral{ |
|
|
|
|
Val: yylex.(*parser).number($1.Val), |
|
|
|
|
PosRange: $1.PositionRange(), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
number : NUMBER { $$ = yylex.(*parser).number($1.Val) } ; |
|
|
|
|
|
|
|
|
|
@ -619,9 +664,14 @@ duration : DURATION |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string_literal : string { $$ = &StringLiteral{$1}} ; |
|
|
|
|
|
|
|
|
|
string : STRING { $$ = yylex.(*parser).unquoteString($1.Val) } ; |
|
|
|
|
string_literal : STRING |
|
|
|
|
{ |
|
|
|
|
$$ = &StringLiteral{ |
|
|
|
|
Val: yylex.(*parser).unquoteString($1.Val), |
|
|
|
|
PosRange: $1.PositionRange(), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
* Wrappers for optional arguments. |
|
|
|
|
|