m2-syn 0.7.0

Parser, typed CST, traversal and procedural macros for Macaulay2
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Prints source, flattened tokens, and the complete typed CST for an M2 file.

use std::error::Error;
use std::fs;

use m2_syn::ParsedFile;

/// The SAMPLE sample value.
const SAMPLE: &str = "f = (x, y) -> if x then {y,} else {,x}\nf 1 2";

fn main() -> Result<(), Box<dyn Error>> {
    let source = match std::env::args_os().nth(1) {
        Some(path) => fs::read_to_string(path)?,
        None => SAMPLE.to_owned(),
    };
    ParsedFile::from_source(source)?.print_pretty()?;
    Ok(())
}