Expand description
A Rust library for parsing ferron.conf configuration files.
ferron.conf is a domain-specific language for custom web server configurations.
This crate provides a reference implementation including a lexer, parser, and AST.
§Features
- Lexer — Tokenizes configuration files with support for comments, strings, numbers, booleans, and interpolation
- Parser — Builds an AST from tokens with full error reporting
- AST — Type-safe representation of configuration structures with helper methods
§Quick Start
use ferronconf::Config;
use std::str::FromStr;
let input = r#"
example.com {
root /var/www/example
tls true
}
*.example.com:443 {
proxy http://backend
}
"#;
let config = Config::from_str(input).unwrap();
// Find all host blocks
for host_block in config.find_host_blocks() {
for host in &host_block.hosts {
println!("Host: {}", host.as_str());
}
}§See Also
Config— The root AST nodeSpan— Source location for error reportingParseError— Error type for parse failures
Structs§
- Block
- A block of nested statements enclosed in braces.
- Config
- The root AST node representing a complete
ferron.confconfiguration file. - Directive
- A configuration directive with a name, optional arguments, and an optional nested block.
- Host
Block - A host-specific configuration block.
- Host
Pattern - A host pattern in a host block.
- Match
Block - A conditional match block that evaluates request attributes.
- Matcher
Expression - An expression in a match block that compares two operands.
- Parse
Error - A parse error with message and source location.
- Snippet
Block - A reusable configuration snippet definition.
- Span
- A source location (line and column) for error reporting.
Enums§
- Host
Labels - The type of host label in a host pattern.
- Operand
- An operand in a matcher expression.
- Operator
- A comparison operator in a matcher expression.
- Statement
- A statement in the configuration file.
- String
Part - A part of an interpolated string.
- Value
- A value in a directive argument or expression operand.