1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tools/incparser/Program.cs Sun Mar 30 07:00:22 2008 +0000
1.3 @@ -0,0 +1,62 @@
1.4 +using System;
1.5 +using System.Collections.Generic;
1.6 +using System.Text;
1.7 +
1.8 +namespace incparser
1.9 +{
1.10 + class Program
1.11 + {
1.12 + static void Main(string[] args)
1.13 + {
1.14 + Environment.Exit(SubMain(args));
1.15 + }
1.16 +
1.17 + static int SubMain(string[] args)
1.18 + {
1.19 + if (args.Length < 1)
1.20 + {
1.21 + Console.WriteLine("Usage: incparser <infile>");
1.22 + return 1;
1.23 + }
1.24 +
1.25 + IncParser inc = null;
1.26 + try
1.27 + {
1.28 + inc = new IncParser(args[0]);
1.29 + }
1.30 + catch (ParseException e)
1.31 + {
1.32 + Console.WriteLine("Initial browsing failed: " + e.Message);
1.33 + return 1;
1.34 + }
1.35 + catch (System.Exception e)
1.36 + {
1.37 + Console.WriteLine("Failed to read file: " + e.Message);
1.38 + return 1;
1.39 + }
1.40 +
1.41 + ParseWriter pw = new ParseWriter();
1.42 +
1.43 + try
1.44 + {
1.45 + inc.Parse(pw);
1.46 + }
1.47 + catch (System.Exception e)
1.48 + {
1.49 + Console.WriteLine("Error parsing file (line " + inc.GetLineNumber() + "): " + e.Message);
1.50 + return 1;
1.51 + }
1.52 +
1.53 + if (pw.Level != 0)
1.54 + {
1.55 + Console.WriteLine("Fatal parse error detected; unable to complete output.");
1.56 + return 1;
1.57 + }
1.58 +
1.59 + Console.Write(pw.Contents);
1.60 + Console.Write("\n");
1.61 +
1.62 + return 0;
1.63 + }
1.64 + }
1.65 +}