Expand description
Binary expression parsing for PromQL.
This module handles parsing of binary operators and their modifiers.
§Binary Operators
Operators listed from lowest to highest precedence:
| Precedence | Operators | Description |
|---|---|---|
| 1 | or | Set union |
| 2 | and, unless | Set intersection/diff |
| 3 | ==, !=, <, <=, >, >= | Comparison |
| 4 | +, - | Addition/subtraction |
| 5 | *, /, %, atan2 | Multiplication/division |
| 6 | ^ | Power (right-associative) |
§Vector Matching Modifiers
Binary operations between vectors can use matching modifiers:
on(label, ...)- Match only on specified labelsignoring(label, ...)- Match ignoring specified labelsgroup_left(label, ...)- Many-to-one matchinggroup_right(label, ...)- One-to-many matchingbool- Return 0/1 instead of filtering (for comparisons)
§Examples
use rusty_promql_parser::parser::binary::binary_op;
use rusty_promql_parser::ast::BinaryOp;
let (_, op) = binary_op("+").unwrap();
assert_eq!(op, BinaryOp::Add);
let (_, op) = binary_op("and").unwrap();
assert_eq!(op, BinaryOp::And);Functions§
- binary_
op - Parse a binary operator