mirror of
https://github.com/alecthomas/chroma.git
synced 2025-03-19 21:10:15 +02:00
Fix PromQL lexer to support values enclosed within single quotes
Values for labels could now be enclosed within single or double quotes.
This commit is contained in:
parent
d11bdacff4
commit
b790655195
lexers
@ -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)},
|
||||
|
3
lexers/testdata/promql.actual
vendored
3
lexers/testdata/promql.actual
vendored
@ -28,3 +28,6 @@ label_replace(
|
||||
"instance",
|
||||
".*"
|
||||
)
|
||||
|
||||
# Values for labels enclosed within single quotes
|
||||
metric_test_app{app='turtle',proc='web'}
|
||||
|
15
lexers/testdata/promql.expected
vendored
15
lexers/testdata/promql.expected
vendored
@ -165,5 +165,20 @@
|
||||
{"type":"Punctuation","value":"\""},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"Operator","value":")"},
|
||||
{"type":"TextWhitespace","value":"\n\n"},
|
||||
{"type":"CommentSingle","value":"# Values for labels enclosed within single quotes"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"NameVariable","value":"metric_test_app"},
|
||||
{"type":"Punctuation","value":"{"},
|
||||
{"type":"NameLabel","value":"app"},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Punctuation","value":"'"},
|
||||
{"type":"LiteralString","value":"turtle"},
|
||||
{"type":"Punctuation","value":"',"},
|
||||
{"type":"NameLabel","value":"proc"},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"Punctuation","value":"'"},
|
||||
{"type":"LiteralString","value":"web"},
|
||||
{"type":"Punctuation","value":"'}"},
|
||||
{"type":"TextWhitespace","value":"\n"}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user