Directly using tadpole_frontend
In some situations, it is preferred to directly call the internal functions of the tadpole_frontend parser. Particuarly, this is the case when using a specification in a standalone file with imports enabled, as the SoundChanger::parse API does not support specifying the file name.
The parser can be called as follows:
let directives = TadpoleParser::default().parse(spec, filename);
let engine = match directives {
Ok(dirs) => Ok(SoundChanger::new(dirs)),
Err(e) => {
// print or forward error
}
}The error type returned here is Vec<ValidationError>. Each ValidationError consists of a main error with a code span as well as optional hints, each of which may or may not have an associated span. Types provided by the Chumsky parser library are used for the spans. Below is an example of a simplified way to print the error content. The tadpole CLI uses Ariadne to format errors.
Enabling Imports
Instead of TadpoleParser::default(), two other functions can be used to instantiate the parser:
TadpoleParser::with_imports()enables imports.TadpoleParser::builtins_only()enables imports, restricted to the standard library included in the executable.