Expand description
Fast query parser for file search
This parser takes a search query and extracts structured constraints while preserving text for fuzzy matching. Designed for maximum performance:
- Single-pass parsing with minimal branching
- Stack-allocated string buffers
§Examples
use fff_query_parser::{QueryParser, Constraint, FuzzyQuery};
let parser = QueryParser::default();
// Single-token queries return FFFQuery with Text fuzzy query and no constraints
let result = parser.parse("hello");
assert!(result.constraints.is_empty());
assert_eq!(result.fuzzy_query, FuzzyQuery::Text("hello"));
// Multi-token queries are parsed
let result = parser.parse("name *.rs");
match &result.fuzzy_query {
FuzzyQuery::Text(text) => assert_eq!(*text, "name"),
_ => panic!("Expected text"),
}
assert!(matches!(result.constraints[0], Constraint::Extension("rs")));
// Parse glob pattern with text
let result = parser.parse("**/*.rs foo");
assert!(matches!(result.constraints[0], Constraint::Glob("**/*.rs")));
// Parse negation
let result = parser.parse("!*.rs foo");
match &result.constraints[0] {
Constraint::Not(inner) => {
assert!(matches!(inner.as_ref(), Constraint::Extension("rs")));
}
_ => panic!("Expected Not constraint"),
}Re-exports§
pub use location::Location;
Modules§
- glob_
detect - Glob wildcard detection — delegates to zlob when available, pure-Rust fallback otherwise.
- location
- Location parsing for file:line:col patterns
Structs§
- AiGrep
Config - Configuration for AI-mode grep — extends
GrepConfigbehavior with automatic file-path constraint detection. - FFFQuery
- File
Search Config - Default configuration for file picker - all features enabled
- Grep
Config - Configuration for full-text search (grep) - file constraints enabled for filtering which files to search, git status disabled since it’s not useful when searching file contents.
- Query
Parser - Main query parser - zero-cost wrapper around configuration
Enums§
- Constraint
- Constraint types that can be extracted from a query
- Fuzzy
Query - GitStatus
Filter
Traits§
- Parser
Config - Parser configuration trait - allows different picker types to customize parsing