Skip to main content

parse_file

Function parse_file 

Source
pub fn parse_file(source: &str) -> Result<SourceFile, ParseError>
Expand description

Parses source with Tree-sitter and lowers its CST into the typed syntax tree.

ยงErrors

Returns ParseError when parsing or typed migration fails.

Examples found in repository?
examples/type_inference.rs (line 294)
293fn main() -> Result<(), ParseError> {
294    let file = parse_file(DEMONSTRATED_CELLS)?;
295    let mut inference = TypeInference::default();
296    inference.visit_source_file(&file);
297
298    for cell in &file.cells {
299        println!(
300            "{:<34} => {}",
301            cell.to_m2().trim_end(),
302            inference.inferred(cell)
303        );
304    }
305    Ok(())
306}