pub fn parse_raw(source: &str) -> Result<Document>Expand description
Parse NOML from a string without resolving dynamic features
Performs only lexical analysis and syntax parsing, returning the raw AST without resolving dynamic features like environment variables, includes, or interpolations. Use this when you need to inspect the document structure or handle resolution manually with custom logic.
§Arguments
source- NOML configuration text to parse
§Returns
Returns a Document containing the raw AST with source information,
or a NomlError if parsing fails.
§Examples
Basic raw parsing:
use noml::parse_raw;
let document = parse_raw(r#"
name = "my-app"
port = 8080
debug = env("DEBUG", false) # Not resolved
"#)?;
// Access the raw AST structure
println!("Document parsed successfully with source: {:?}", document.source_path);
Inspecting unresolved dynamic features:
use noml::parse_raw;
let document = parse_raw(r#"
config = env("CONFIG_PATH", "default.conf")
timeout = @duration("30s")
name = "test"
"#)?;
// The document contains raw function calls and interpolations
// that haven't been resolved yet
§Use Cases
- Static analysis tools that need to examine structure
- Custom resolution with specialized logic
- Configuration validation without side effects
- Development tools and language servers
§Errors
Returns NomlError for:
- Syntax errors in the NOML source
- Invalid token sequences
- Malformed expressions