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
8/// The SAMPLE sample value.
9const SAMPLE: &str = "f = (x, y) -> if x then {y,} else {,x}\nf 1 2";
10
11fn main() -> Result<(), Box<dyn Error>> {
12 let source = match std::env::args_os().nth(1) {
13 Some(path) => fs::read_to_string(path)?,
14 None => SAMPLE.to_owned(),
15 };
16 ParsedFile::from_source(source)?.print_pretty()?;
17 Ok(())
18}