Add grammar (maybe?)

Signed-off-by: Levi Harrison <git@leviharrison.dev>
This commit is contained in:
Levi Harrison 2021-08-29 14:18:23 -04:00
parent a283b52e8c
commit e27ac3e7e4
3 changed files with 6 additions and 2 deletions

View file

@ -28,6 +28,7 @@ export const binOpTerms = [
{ label: '<' },
{ label: '<=' },
{ label: '!=' },
{ label: 'atan2' },
{ label: 'and' },
{ label: 'or' },
{ label: 'unless' },

View file

@ -16,7 +16,8 @@
@precedence {
pow @right,
mul @left,
mul @left
atan2 @left,
add @left,
eql @left,
and @left,
@ -69,6 +70,7 @@ BinaryExpr {
Expr !mul Mul BinModifiers Expr |
Expr !mul Div BinModifiers Expr |
Expr !mul Mod BinModifiers Expr |
Expr !mul Atan2 BinModifiers Expr |
Expr !add Add BinModifiers Expr |
Expr !add Sub BinModifiers Expr |
Expr !eql Eql BinModifiers Expr |
@ -333,6 +335,7 @@ NumberLiteral {
// Contextual keywords
@external extend {Identifier} extendIdentifier from "./tokens" {
Atan2,
Avg,
Bottomk,
Count,

View file

@ -40,7 +40,7 @@ export function promQLLanguage(top: LanguageType): LezerLanguage {
'Avg Bottomk Count Count_values Group Max Min Quantile Stddev Stdvar Sum Topk': tags.operatorKeyword,
'By Without Bool On Ignoring GroupLeft GroupRight Offset Start End': tags.modifier,
'And Unless Or': tags.logicOperator,
'Sub Add Mul Mod Div Eql Neq Lte Lss Gte Gtr EqlRegex EqlSingle NeqRegex Pow At': tags.operator,
'Sub Add Mul Mod Div Atan2 Eql Neq Lte Lss Gte Gtr EqlRegex EqlSingle NeqRegex Pow At': tags.operator,
UnaryOp: tags.arithmeticOperator,
'( )': tags.paren,
'[ ]': tags.squareBracket,