| Crates.io | dsq-parser |
| lib.rs | dsq-parser |
| version | 0.1.0 |
| created_at | 2025-12-15 17:45:25.754824+00 |
| updated_at | 2025-12-15 17:45:25.754824+00 |
| description | Parser for DSQ filter language that produces an AST |
| homepage | |
| repository | https://github.com/durableprogramming/dsq |
| max_upload_size | |
| id | 1986450 |
| size | 204,075 |
Parser for the DSQ filter language that produces an Abstract Syntax Tree (AST).
dsq-parser is a core component of the DSQ (DataSet Query) ecosystem that handles parsing of jq-like query syntax into an AST representation. The parser is built using the nom parser combinator library and produces a structured AST that can be evaluated by other DSQ components.
nom for composability and performanceAdd this to your Cargo.toml:
[dependencies]
dsq-parser = "0.1"
use dsq_parser::parse_filter;
fn main() {
let query = ".name | select(.age > 18)";
match parse_filter(query) {
Ok(ast) => println!("Parsed AST: {:?}", ast),
Err(e) => eprintln!("Parse error: {}", e),
}
}
use dsq_parser::{parse_filter, Expr};
fn main() {
let query = ".[] | .id";
let ast = parse_filter(query).expect("Failed to parse");
// Process the AST
match ast {
Expr::Pipe(left, right) => {
println!("Pipeline detected");
println!("Left: {:?}", left);
println!("Right: {:?}", right);
}
_ => println!("Other expression type"),
}
}
The parser supports the following jq-like constructs:
.field, .field.nested.[], .[0], .[1:3]expr | exprselect(), map(), sort_by()+, -, *, /, ==, !=, <, >, <=, >={key: value}[expr]For detailed API documentation, see docs.rs/dsq-parser.
The parser is organized into several modules:
Contributions are welcome! Please see the CONTRIBUTING.md file in the repository root for guidelines.
Licensed under either of:
at your option.