VPL Parser
Lexing and parsing for the VPL streaming analytics language.
This crate transforms VPL source code into an Abstract Syntax Tree (AST) that can be executed by the runtime engine.
Features
- Complete VPL grammar support
- Detailed error messages with line/column information
- Syntax hints for common mistakes
- PEG-based parsing via Pest
Modules
- [
pest_parser]: Main parser implementation using Pest PEG grammar - [
lexer]: Token definitions (used for syntax highlighting) - [
error]: Parse error types with location information - [
helpers]: Parsing utility functions - [
indent]: Indentation handling
Quick Start
use parse;
let source = r#"
stream Readings = SensorReading
.where(temperature > 100)
.emit(alert("HighTemp", "Temperature exceeded threshold"))
"#;
match parse
Error Handling
Parse errors include detailed location information:
use ;
let result = parse; // Typo: "form" instead of "from"
if let Err = result
Grammar
The VPL grammar is defined in varpulis.pest and supports:
- Stream declarations with filtering, selection, windowing, and aggregation
- Event type definitions
- SASE+ pattern declarations (sequences, Kleene closures, negation)
- User-defined functions
- Configuration blocks
- Control flow (if/elif/else, for, while)
- Expressions with operators and function calls
See Also
varpulis_core: AST types produced by the parservarpulis_runtime: Executing parsed programs