Skip to main content

inspect_syntax

Function inspect_syntax 

Source
pub fn inspect_syntax(source: &str) -> SyntaxFeatures
Expand description

Inspect fixed public shell syntax features without retaining source values.

Examples found in repository?
examples/shell_parser_fuzz.rs (line 13)
5fn main() -> Result<(), String> {
6    let mut bytes = Vec::new();
7    io::stdin()
8        .take(MAX_FUZZ_INPUT_BYTES)
9        .read_to_end(&mut bytes)
10        .map_err(|error| format!("could not read fuzz input: {error}"))?;
11    let source = String::from_utf8_lossy(&bytes).into_owned();
12    let original = source.clone();
13    let _ = yarp_cli::shell::inspect_syntax(&source);
14    let _ = yarp_cli::rewrite::select_result_plan(&source);
15    let _ = yarp_cli::rewrite::rewrite(&source);
16    if source != original {
17        return Err("shell classification changed its input".to_owned());
18    }
19    Ok(())
20}