Skip to main content

inspect/
inspect.rs

1//! Prints source, flattened tokens, and the complete typed CST for an M2 file.
2
3use std::error::Error;
4use std::fs;
5
6use m2_syn::ParsedFile;
7
8const SAMPLE: &str = "f = (x, y) -> if x then {y,} else {,x}\nf 1 2";
9
10fn main() -> Result<(), Box<dyn Error>> {
11    let source = match std::env::args_os().nth(1) {
12        Some(path) => fs::read_to_string(path)?,
13        None => SAMPLE.to_owned(),
14    };
15    ParsedFile::from_source(source)?.print_pretty()?;
16    Ok(())
17}