ds@1952: using System; ds@1952: using System.Collections.Generic; ds@1952: using System.Text; ds@1952: ds@1952: namespace incparser ds@1952: { ds@1952: class Program ds@1952: { ds@1952: static void Main(string[] args) ds@1952: { ds@1952: Environment.Exit(SubMain(args)); ds@1952: } ds@1952: ds@1952: static int SubMain(string[] args) ds@1952: { ds@1952: if (args.Length < 1) ds@1952: { ds@1952: Console.WriteLine("Usage: incparser "); ds@1952: return 1; ds@1952: } ds@1952: ds@1952: IncParser inc = null; ds@1952: try ds@1952: { ds@1952: inc = new IncParser(args[0]); ds@1952: } ds@1952: catch (ParseException e) ds@1952: { ds@1952: Console.WriteLine("Initial browsing failed: " + e.Message); ds@1952: return 1; ds@1952: } ds@1952: catch (System.Exception e) ds@1952: { ds@1952: Console.WriteLine("Failed to read file: " + e.Message); ds@1952: return 1; ds@1952: } ds@1952: ds@1952: ParseWriter pw = new ParseWriter(); ds@1952: ds@1952: try ds@1952: { ds@1952: inc.Parse(pw); ds@1952: } ds@1952: catch (System.Exception e) ds@1952: { ds@1952: Console.WriteLine("Error parsing file (line " + inc.GetLineNumber() + "): " + e.Message); ds@1952: return 1; ds@1952: } ds@1952: ds@1952: if (pw.Level != 0) ds@1952: { ds@1952: Console.WriteLine("Fatal parse error detected; unable to complete output."); ds@1952: return 1; ds@1952: } ds@1952: ds@1952: Console.Write(pw.Contents); ds@1952: Console.Write("\n"); ds@1952: ds@1952: return 0; ds@1952: } ds@1952: } ds@1952: }