grafana/public/app/plugins/datasource/logging/syntax.ts
David Kaltschmidt a61c8d23d4 Explore: Fix label and history suggestions
- fork promql's tokenizer (need to specify that labels context can only follow beginning of line or whitespace)
- remove unneeded syntax features
- only present history items when field is empty
2018-11-30 15:13:53 +01:00

29 lines
638 B
TypeScript

/* tslint:disable max-line-length */
const tokenizer = {
comment: {
pattern: /(^|[^\n])#.*/,
lookbehind: true,
},
'context-labels': {
pattern: /(^|\s)\{[^}]*(?=})/,
lookbehind: true,
inside: {
'label-key': {
pattern: /[a-z_]\w*(?=\s*(=|!=|=~|!~))/,
alias: 'attr-name',
},
'label-value': {
pattern: /"(?:\\.|[^\\"])*"/,
greedy: true,
alias: 'attr-value',
},
},
},
// number: /\b-?\d+((\.\d*)?([eE][+-]?\d+)?)?\b/,
operator: new RegExp(`/&&?|\\|?\\||!=?|<(?:=>?|<|>)?|>[>=]?`, 'i'),
punctuation: /[{}`,.]/,
};
export default tokenizer;