use ::pseudocode::eval;
use std::fs::File;
use std::env;
use std::io::prelude::*;

fn main() -> std::io::Result<()> {

    let args: Vec<String> = env::args().collect();
    if let Some(filename) = args.get(1) {
        let mut file = File::open(filename)?;
        let mut prog = String::new();
        file.read_to_string(&mut prog)?;
        println!("{}", prog);
        println!("--------------------------");
        match eval(&prog) {
            Ok(output) => println!("{}", output),
            Err(e) => println!("Error: {}", e),
        }
    }
    Ok(())
}
