From 266248fbd706a3c532a1cda9b22d0346aacf7ae8 Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Thu, 13 May 2021 20:21:16 +0200 Subject: [PATCH] Provide alternative "MetricName" top-level entrypoint Signed-off-by: Julius Volz --- package-lock.json | 2 +- src/promql.grammar | 1 + test/expression.txt | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 3392fad..b2ce1f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "lezer-promql", - "version": "0.17.0", + "version": "0.18.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/promql.grammar b/src/promql.grammar index 6f806c7..f743c01 100644 --- a/src/promql.grammar +++ b/src/promql.grammar @@ -13,6 +13,7 @@ // limitations under the License. @top PromQL { Expr } +@top MetricName { MetricIdentifier } @precedence { pow @right, diff --git a/test/expression.txt b/test/expression.txt index 5041bb8..3e98831 100644 --- a/test/expression.txt +++ b/test/expression.txt @@ -833,3 +833,10 @@ foo offset 5d ==> PromQL(Expr(OffsetExpr(Expr(VectorSelector(MetricIdentifier(Identifier))), Offset, Duration))) + +# Parsing only metric names with alternative @top { "top": "MetricName" } + +sum:my_metric_name:rate5m + +==> +MetricName(MetricIdentifier(Identifier))