// Copyright 2019 The Prometheus Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. %{ package parser import ( "math" "strconv" "time" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/model/value" "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/promql/parser/posrange" ) %} %union { node Node item Item matchers []*labels.Matcher matcher *labels.Matcher label labels.Label labels labels.Labels lblList []labels.Label strings []string series []SequenceValue histogram *histogram.FloatHistogram descriptors map[string]interface{} bucket_set []float64 int int64 uint uint64 float float64 } %token EQL BLANK COLON COMMA COMMENT DURATION EOF ERROR IDENTIFIER LEFT_BRACE LEFT_BRACKET LEFT_PAREN OPEN_HIST CLOSE_HIST METRIC_IDENTIFIER NUMBER RIGHT_BRACE RIGHT_BRACKET RIGHT_PAREN SEMICOLON SPACE STRING TIMES // Histogram Descriptors. %token histogramDescStart %token SUM_DESC COUNT_DESC SCHEMA_DESC OFFSET_DESC NEGATIVE_OFFSET_DESC BUCKETS_DESC NEGATIVE_BUCKETS_DESC ZERO_BUCKET_DESC ZERO_BUCKET_WIDTH_DESC CUSTOM_VALUES_DESC %token histogramDescEnd // Operators. %token operatorsStart %token ADD DIV EQLC EQL_REGEX GTE GTR LAND LOR LSS LTE LUNLESS MOD MUL NEQ NEQ_REGEX POW SUB AT ATAN2 %token operatorsEnd // Aggregators. %token aggregatorsStart %token AVG BOTTOMK COUNT COUNT_VALUES GROUP MAX MIN QUANTILE STDDEV STDVAR SUM TOPK LIMITK LIMIT_RATIO %token aggregatorsEnd // Keywords. %token keywordsStart %token BOOL BY GROUP_LEFT GROUP_RIGHT IGNORING OFFSET ON WITHOUT %token keywordsEnd // Preprocessors. %token preprocessorStart %token START END %token preprocessorEnd // Start symbols for the generated parser. %token startSymbolsStart %token START_METRIC START_SERIES_DESCRIPTION START_EXPRESSION START_METRIC_SELECTOR %token startSymbolsEnd // Type definitions for grammar rules. %type label_match_list %type label_matcher %type aggregate_op grouping_label match_op maybe_label metric_identifier unary_op at_modifier_preprocessors string_identifier %type label_set metric %type label_set_list %type