@prometheus-io/lezer-promql 0.308.0 → 0.311.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +158 -9
- package/dist/index.cjs +210 -184
- package/dist/index.d.ts +11 -1
- package/dist/index.es.js +201 -185
- package/package.json +2 -2
- package/src/highlight.js +1 -1
- package/src/parser.js +155 -145
- package/src/parser.terms.js +144 -134
- package/src/promql.grammar +29 -1
- package/src/tokens.js +74 -68
package/src/parser.terms.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
2
2
|
export const
|
|
3
|
-
inf =
|
|
4
|
-
nan =
|
|
3
|
+
inf = 177,
|
|
4
|
+
nan = 178,
|
|
5
5
|
Bool = 1,
|
|
6
6
|
Ignoring = 2,
|
|
7
7
|
On = 3,
|
|
@@ -32,135 +32,145 @@ export const
|
|
|
32
32
|
End = 28,
|
|
33
33
|
Smoothed = 29,
|
|
34
34
|
Anchored = 30,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
35
|
+
Fill = 31,
|
|
36
|
+
FillLeft = 32,
|
|
37
|
+
FillRight = 33,
|
|
38
|
+
LineComment = 34,
|
|
39
|
+
PromQL = 35,
|
|
40
|
+
AggregateExpr = 36,
|
|
41
|
+
AggregateOp = 37,
|
|
42
|
+
AggregateModifier = 38,
|
|
43
|
+
GroupingLabels = 39,
|
|
44
|
+
LabelName = 40,
|
|
45
|
+
QuotedLabelName = 41,
|
|
46
|
+
StringLiteral = 42,
|
|
47
|
+
FunctionCallBody = 43,
|
|
48
|
+
BinaryExpr = 44,
|
|
49
|
+
Pow = 45,
|
|
50
|
+
BoolModifier = 46,
|
|
51
|
+
MatchingModifierClause = 47,
|
|
52
|
+
FillModifier = 48,
|
|
53
|
+
FillClause = 49,
|
|
54
|
+
NumberDurationLiteral = 50,
|
|
55
|
+
FillLeftClause = 51,
|
|
56
|
+
FillRightClause = 52,
|
|
57
|
+
Mul = 53,
|
|
58
|
+
Div = 54,
|
|
59
|
+
Mod = 55,
|
|
60
|
+
Add = 56,
|
|
61
|
+
Sub = 57,
|
|
62
|
+
Eql = 58,
|
|
63
|
+
Gte = 59,
|
|
64
|
+
Gtr = 60,
|
|
65
|
+
TrimUpper = 61,
|
|
66
|
+
TrimLower = 62,
|
|
67
|
+
Lte = 63,
|
|
68
|
+
Lss = 64,
|
|
69
|
+
Neq = 65,
|
|
70
|
+
FunctionCall = 66,
|
|
71
|
+
FunctionIdentifier = 67,
|
|
72
|
+
AbsentOverTime = 68,
|
|
73
|
+
Identifier = 69,
|
|
74
|
+
Absent = 70,
|
|
75
|
+
Abs = 71,
|
|
76
|
+
Acos = 72,
|
|
77
|
+
Acosh = 73,
|
|
78
|
+
Asin = 74,
|
|
79
|
+
Asinh = 75,
|
|
80
|
+
Atan = 76,
|
|
81
|
+
Atanh = 77,
|
|
82
|
+
AvgOverTime = 78,
|
|
83
|
+
Ceil = 79,
|
|
84
|
+
Changes = 80,
|
|
85
|
+
Clamp = 81,
|
|
86
|
+
ClampMax = 82,
|
|
87
|
+
ClampMin = 83,
|
|
88
|
+
Cos = 84,
|
|
89
|
+
Cosh = 85,
|
|
90
|
+
CountOverTime = 86,
|
|
91
|
+
DaysInMonth = 87,
|
|
92
|
+
DayOfMonth = 88,
|
|
93
|
+
DayOfWeek = 89,
|
|
94
|
+
DayOfYear = 90,
|
|
95
|
+
Deg = 91,
|
|
96
|
+
Delta = 92,
|
|
97
|
+
Deriv = 93,
|
|
98
|
+
Exp = 94,
|
|
99
|
+
FirstOverTime = 95,
|
|
100
|
+
Floor = 96,
|
|
101
|
+
HistogramCount = 97,
|
|
102
|
+
HistogramFraction = 98,
|
|
103
|
+
HistogramQuantile = 99,
|
|
104
|
+
HistogramQuantiles = 100,
|
|
105
|
+
HistogramStdDev = 101,
|
|
106
|
+
HistogramStdVar = 102,
|
|
107
|
+
HistogramSum = 103,
|
|
108
|
+
HistogramAvg = 104,
|
|
109
|
+
DoubleExponentialSmoothing = 105,
|
|
110
|
+
Hour = 106,
|
|
111
|
+
Idelta = 107,
|
|
112
|
+
Increase = 108,
|
|
113
|
+
Info = 109,
|
|
114
|
+
Irate = 110,
|
|
115
|
+
LabelReplace = 111,
|
|
116
|
+
LabelJoin = 112,
|
|
117
|
+
LastOverTime = 113,
|
|
118
|
+
Ln = 114,
|
|
119
|
+
Log10 = 115,
|
|
120
|
+
Log2 = 116,
|
|
121
|
+
MadOverTime = 117,
|
|
122
|
+
MaxOverTime = 118,
|
|
123
|
+
MinOverTime = 119,
|
|
124
|
+
TsOfFirstOverTime = 120,
|
|
125
|
+
TsOfMaxOverTime = 121,
|
|
126
|
+
TsOfMinOverTime = 122,
|
|
127
|
+
TsOfLastOverTime = 123,
|
|
128
|
+
Minute = 124,
|
|
129
|
+
Month = 125,
|
|
130
|
+
Pi = 126,
|
|
131
|
+
PredictLinear = 127,
|
|
132
|
+
PresentOverTime = 128,
|
|
133
|
+
QuantileOverTime = 129,
|
|
134
|
+
Rad = 130,
|
|
135
|
+
Rate = 131,
|
|
136
|
+
Resets = 132,
|
|
137
|
+
Round = 133,
|
|
138
|
+
Scalar = 134,
|
|
139
|
+
Sgn = 135,
|
|
140
|
+
Sin = 136,
|
|
141
|
+
Sinh = 137,
|
|
142
|
+
Sort = 138,
|
|
143
|
+
SortDesc = 139,
|
|
144
|
+
SortByLabel = 140,
|
|
145
|
+
SortByLabelDesc = 141,
|
|
146
|
+
Sqrt = 142,
|
|
147
|
+
StddevOverTime = 143,
|
|
148
|
+
StdvarOverTime = 144,
|
|
149
|
+
SumOverTime = 145,
|
|
150
|
+
Tan = 146,
|
|
151
|
+
Tanh = 147,
|
|
152
|
+
Timestamp = 148,
|
|
153
|
+
Time = 149,
|
|
154
|
+
Vector = 150,
|
|
155
|
+
Year = 151,
|
|
156
|
+
MatrixSelector = 152,
|
|
157
|
+
NumberDurationLiteralInDurationContext = 153,
|
|
158
|
+
OffsetExpr = 154,
|
|
159
|
+
AnchoredExpr = 155,
|
|
160
|
+
SmoothedExpr = 156,
|
|
161
|
+
ParenExpr = 157,
|
|
162
|
+
SubqueryExpr = 158,
|
|
163
|
+
UnaryExpr = 159,
|
|
164
|
+
UnaryOp = 160,
|
|
165
|
+
VectorSelector = 161,
|
|
166
|
+
LabelMatchers = 162,
|
|
167
|
+
UnquotedLabelMatcher = 163,
|
|
168
|
+
MatchOp = 164,
|
|
169
|
+
EqlSingle = 165,
|
|
170
|
+
EqlRegex = 166,
|
|
171
|
+
NeqRegex = 167,
|
|
172
|
+
QuotedLabelMatcher = 168,
|
|
173
|
+
StepInvariantExpr = 169,
|
|
174
|
+
At = 170,
|
|
175
|
+
AtModifierPreprocessors = 171,
|
|
176
|
+
MetricName = 172
|
package/src/promql.grammar
CHANGED
|
@@ -88,6 +88,8 @@ BinaryExpr {
|
|
|
88
88
|
expr !eql Eql binModifiers expr |
|
|
89
89
|
expr !eql Gte binModifiers expr |
|
|
90
90
|
expr !eql Gtr binModifiers expr |
|
|
91
|
+
expr !eql TrimUpper binModifiers expr |
|
|
92
|
+
expr !eql TrimLower binModifiers expr |
|
|
91
93
|
expr !eql Lte binModifiers expr |
|
|
92
94
|
expr !eql Lss binModifiers expr |
|
|
93
95
|
expr !eql Neq binModifiers expr |
|
|
@@ -101,11 +103,30 @@ MatchingModifierClause {
|
|
|
101
103
|
((GroupLeft | GroupRight) (!group GroupingLabels)?)?
|
|
102
104
|
}
|
|
103
105
|
|
|
106
|
+
FillClause {
|
|
107
|
+
Fill "(" NumberDurationLiteral ")"
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
FillLeftClause {
|
|
111
|
+
FillLeft "(" NumberDurationLiteral ")"
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
FillRightClause {
|
|
115
|
+
FillRight "(" NumberDurationLiteral ")"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
FillModifier {
|
|
119
|
+
(FillClause | FillLeftClause | FillRightClause) |
|
|
120
|
+
(FillLeftClause FillRightClause) |
|
|
121
|
+
(FillRightClause FillLeftClause)
|
|
122
|
+
}
|
|
123
|
+
|
|
104
124
|
BoolModifier { Bool }
|
|
105
125
|
|
|
106
126
|
binModifiers {
|
|
107
127
|
BoolModifier?
|
|
108
128
|
MatchingModifierClause?
|
|
129
|
+
FillModifier?
|
|
109
130
|
}
|
|
110
131
|
|
|
111
132
|
GroupingLabels {
|
|
@@ -148,6 +169,7 @@ FunctionIdentifier {
|
|
|
148
169
|
HistogramCount |
|
|
149
170
|
HistogramFraction |
|
|
150
171
|
HistogramQuantile |
|
|
172
|
+
HistogramQuantiles |
|
|
151
173
|
HistogramStdDev |
|
|
152
174
|
HistogramStdVar |
|
|
153
175
|
HistogramSum |
|
|
@@ -318,6 +340,8 @@ NumberDurationLiteralInDurationContext {
|
|
|
318
340
|
Lss { "<" }
|
|
319
341
|
Gte { ">=" }
|
|
320
342
|
Gtr { ">" }
|
|
343
|
+
TrimUpper { "</" }
|
|
344
|
+
TrimLower { ">/" }
|
|
321
345
|
EqlRegex { "=~" }
|
|
322
346
|
EqlSingle { "=" }
|
|
323
347
|
NeqRegex { "!~" }
|
|
@@ -366,7 +390,10 @@ NumberDurationLiteralInDurationContext {
|
|
|
366
390
|
Start,
|
|
367
391
|
End,
|
|
368
392
|
Smoothed,
|
|
369
|
-
Anchored
|
|
393
|
+
Anchored,
|
|
394
|
+
Fill,
|
|
395
|
+
FillLeft,
|
|
396
|
+
FillRight
|
|
370
397
|
}
|
|
371
398
|
|
|
372
399
|
@external propSource promQLHighLight from "./highlight"
|
|
@@ -404,6 +431,7 @@ NumberDurationLiteralInDurationContext {
|
|
|
404
431
|
HistogramCount { condFn<"histogram_count"> }
|
|
405
432
|
HistogramFraction { condFn<"histogram_fraction"> }
|
|
406
433
|
HistogramQuantile { condFn<"histogram_quantile"> }
|
|
434
|
+
HistogramQuantiles { condFn<"histogram_quantiles"> }
|
|
407
435
|
HistogramStdDev { condFn<"histogram_stddev"> }
|
|
408
436
|
HistogramStdVar { condFn<"histogram_stdvar"> }
|
|
409
437
|
HistogramSum { condFn<"histogram_sum"> }
|
package/src/tokens.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright The Prometheus Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -12,82 +12,88 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
15
|
+
And,
|
|
16
|
+
Avg,
|
|
17
|
+
Atan2,
|
|
18
|
+
Bool,
|
|
19
|
+
Bottomk,
|
|
20
|
+
By,
|
|
21
|
+
Count,
|
|
22
|
+
CountValues,
|
|
23
|
+
End,
|
|
24
|
+
Group,
|
|
25
|
+
GroupLeft,
|
|
26
|
+
GroupRight,
|
|
27
|
+
Ignoring,
|
|
28
|
+
inf,
|
|
29
|
+
Max,
|
|
30
|
+
Min,
|
|
31
|
+
nan,
|
|
32
|
+
Offset,
|
|
33
|
+
On,
|
|
34
|
+
Or,
|
|
35
|
+
Quantile,
|
|
36
|
+
LimitK,
|
|
37
|
+
LimitRatio,
|
|
38
|
+
Start,
|
|
39
|
+
Stddev,
|
|
40
|
+
Stdvar,
|
|
41
|
+
Sum,
|
|
42
|
+
Topk,
|
|
43
|
+
Unless,
|
|
44
|
+
Without,
|
|
45
|
+
Smoothed,
|
|
46
|
+
Anchored,
|
|
47
|
+
Fill,
|
|
48
|
+
FillLeft,
|
|
49
|
+
FillRight,
|
|
50
|
+
} from "./parser.terms.js";
|
|
48
51
|
|
|
49
52
|
const keywordTokens = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
inf: inf,
|
|
54
|
+
nan: nan,
|
|
55
|
+
bool: Bool,
|
|
56
|
+
ignoring: Ignoring,
|
|
57
|
+
on: On,
|
|
58
|
+
group_left: GroupLeft,
|
|
59
|
+
group_right: GroupRight,
|
|
60
|
+
offset: Offset,
|
|
58
61
|
};
|
|
59
62
|
|
|
60
63
|
export const specializeIdentifier = (value, stack) => {
|
|
61
|
-
|
|
64
|
+
return keywordTokens[value.toLowerCase()] || -1;
|
|
62
65
|
};
|
|
63
66
|
|
|
64
67
|
const contextualKeywordTokens = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
68
|
+
avg: Avg,
|
|
69
|
+
atan2: Atan2,
|
|
70
|
+
bottomk: Bottomk,
|
|
71
|
+
count: Count,
|
|
72
|
+
count_values: CountValues,
|
|
73
|
+
group: Group,
|
|
74
|
+
max: Max,
|
|
75
|
+
min: Min,
|
|
76
|
+
quantile: Quantile,
|
|
77
|
+
limitk: LimitK,
|
|
78
|
+
limit_ratio: LimitRatio,
|
|
79
|
+
stddev: Stddev,
|
|
80
|
+
stdvar: Stdvar,
|
|
81
|
+
sum: Sum,
|
|
82
|
+
topk: Topk,
|
|
83
|
+
by: By,
|
|
84
|
+
without: Without,
|
|
85
|
+
and: And,
|
|
86
|
+
or: Or,
|
|
87
|
+
unless: Unless,
|
|
88
|
+
start: Start,
|
|
89
|
+
end: End,
|
|
90
|
+
smoothed: Smoothed,
|
|
91
|
+
anchored: Anchored,
|
|
92
|
+
fill: Fill,
|
|
93
|
+
fill_left: FillLeft,
|
|
94
|
+
fill_right: FillRight,
|
|
89
95
|
};
|
|
90
96
|
|
|
91
97
|
export const extendIdentifier = (value, stack) => {
|
|
92
|
-
|
|
98
|
+
return contextualKeywordTokens[value.toLowerCase()] || -1;
|
|
93
99
|
};
|