1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-17 20:58:08 +02:00

Fix a typo into the lables regex for PromQL lexer

The correct label matching operator is `!~` instead of `~!`.
This commit is contained in:
Pablo Seminario 2021-04-24 21:44:12 +02:00 committed by Alec Thomas
parent b790655195
commit 9866a75161
3 changed files with 14 additions and 1 deletions

View File

@ -44,7 +44,7 @@ func promqlRules() Rules {
{`\n`, TextWhitespace, nil},
{`\s+`, TextWhitespace, nil},
{`,`, Punctuation, nil},
{`([_a-zA-Z][a-zA-Z0-9_]*?)(\s*?)(=~|!=|=|~!)(\s*?)("|')(.*?)("|')`, ByGroups(NameLabel, TextWhitespace, Operator, TextWhitespace, Punctuation, LiteralString, Punctuation), nil},
{`([_a-zA-Z][a-zA-Z0-9_]*?)(\s*?)(=~|!=|=|!~)(\s*?)("|')(.*?)("|')`, ByGroups(NameLabel, TextWhitespace, Operator, TextWhitespace, Punctuation, LiteralString, Punctuation), nil},
},
"range": {
{`\]`, Punctuation, Pop(1)},

View File

@ -31,3 +31,6 @@ label_replace(
# Values for labels enclosed within single quotes
metric_test_app{app='turtle',proc='web'}
# Use label matching operator `!~`
metric_test_app{status!~'(4|5)..'}

View File

@ -180,5 +180,15 @@
{"type":"Punctuation","value":"'"},
{"type":"LiteralString","value":"web"},
{"type":"Punctuation","value":"'}"},
{"type":"TextWhitespace","value":"\n\n"},
{"type":"CommentSingle","value":"# Use label matching operator `!~`"},
{"type":"TextWhitespace","value":"\n"},
{"type":"NameVariable","value":"metric_test_app"},
{"type":"Punctuation","value":"{"},
{"type":"NameLabel","value":"status"},
{"type":"Operator","value":"!~"},
{"type":"Punctuation","value":"'"},
{"type":"LiteralString","value":"(4|5).."},
{"type":"Punctuation","value":"'}"},
{"type":"TextWhitespace","value":"\n"}
]