INNER CODE UNIT · Rust

parse_file

dontpanic92/OpenPAL3 · crosscom/ccidl-rs/src/lib.rs:175

fn parse_file(path: &Path) -> Result<CrossComIdl, Error> {
    let content = std::fs::read_to_string(path).map_err(|source| Error::Io {
        path: path.to_path_buf(),
        source,
    })?;
    parse_source(&content).map_err(|message| Error::Parse {
        path: path.to_path_buf(),
        message,
    })
}

pub(crate) fn parse_source(input: &str) -> Result<CrossComIdl, String> {
    let cleaned = strip_comments(input)?;
    Parser::new(&cleaned).parse()
}

/// Replace every `//` line comment and `/* ... */` block comment with an
/// equal-length run of spaces (newlines inside block comments are

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…