public static void Main(string[] args) { bool refreshEnv = false; bool showSexp = false; bool showExpr = false; List <string> files = new List <string>(); foreach (string arg in args) { if (arg.Substring(0, 1) == "-") { switch (arg) { case "-r": case "--refreshEnv": refreshEnv = true; break; case "-v": case "--verbose": showSexp = true; showExpr = true; break; default: Console.Error.WriteLine("Unrecognized commandline option: " + arg); break; } } else { files.Add(arg); } } Environment env = GetStartEnv(refreshEnv); Val result = new NumV(-1); foreach (string file in files) { SExpression sexp = new SExpOpenXML(file); if (showSexp) { Console.WriteLine("Lexical Analyzer Output:"); Console.WriteLine(sexp.ToString()); } ExprC prog = Parser.parse(sexp); if (showExpr) { Console.WriteLine("Parser Output:"); Console.WriteLine(prog.ToString()); } result = prog.interp(env); } Console.WriteLine(result.ToString()); }
public override string ToString() { return(body.ToString() + " - " + env.ToString()); }