static int Main(string[] args) { int result = 0; try { #if false StreamReader sr = new StreamReader(args[0]); Scanner scanner = new Scanner(args[0], sr, 4); for (; ;) { Token token = scanner.ReadToken(); Console.WriteLine(token.Position.ToString() + ":" + token.ToString()); if (token.Kind == TokenKind.EndOfFile) { break; } } sr.Close(); Console.ReadLine(); #else // expand wildcards string[] found = Toolbox.Find(args, false); // process each input file in turn foreach (string arg in found) { SymbolTable symbols = new SymbolTable(); StreamReader reader = new StreamReader(arg); Scanner scanner = new Scanner(arg, reader, 4); Parser parser = new Parser(symbols, scanner); AST.Program program = parser.ParseProgram(); Checker checker = new Checker(symbols, program); Indenter indenter = new Indenter(arg + ".log", System.Text.Encoding.ASCII); try { program.Dump(indenter); } finally { indenter.Close(); } new CodeGen(symbols, program); Console.WriteLine("Press ENTER"); Console.ReadLine(); } #endif } catch (BerylError that) { if (that.Position == null) { Console.WriteLine("Error: {0}", that.Message); } else { Console.WriteLine("{0} Error: {1}", that.Position.ToString(), that.Message); } result = 1; } #if false catch (System.Exception that) { Console.WriteLine("Error: {0}", that.Message); result = 1; } #endif return(result); }
static int Main(string[] args) { int result = 0; try { #if false StreamReader sr = new StreamReader(args[0]); Scanner scanner = new Scanner(args[0], sr, 4); for (; ; ) { Token token = scanner.ReadToken(); Console.WriteLine(token.Position.ToString() + ":" + token.ToString()); if (token.Kind == TokenKind.EndOfFile) break; } sr.Close(); Console.ReadLine(); #else // expand wildcards string[] found = Toolbox.Find(args, false); // process each input file in turn foreach (string arg in found) { SymbolTable symbols = new SymbolTable(); StreamReader reader = new StreamReader(arg); Scanner scanner = new Scanner(arg, reader, 4); Parser parser = new Parser(symbols, scanner); AST.Program program = parser.ParseProgram(); Checker checker = new Checker(symbols, program); Indenter indenter = new Indenter(arg + ".log", System.Text.Encoding.ASCII); try { program.Dump(indenter); } finally { indenter.Close(); } new CodeGen(symbols, program); Console.WriteLine("Press ENTER"); Console.ReadLine(); } #endif } catch (BerylError that) { if (that.Position == null) Console.WriteLine("Error: {0}", that.Message); else Console.WriteLine("{0} Error: {1}", that.Position.ToString(), that.Message); result = 1; } #if false catch (System.Exception that) { Console.WriteLine("Error: {0}", that.Message); result = 1; } #endif return result; }