tools/incparser/Program.cs
author Scott Ehlert <ds@alliedmods.net>
Sun Mar 30 07:00:22 2008 +0000 (2008-03-30)
changeset 1952 b7aa2b626807
child 2019 9f473114a511
permissions -rw-r--r--
Spring Cleaning, Part Ichi (1)
Various minor things done to project files
Updated sample extension project file and updated makefile to the new unified version (more changes likely on the way)
Updated regex project file and makefile
ds@1952
     1
using System;
ds@1952
     2
using System.Collections.Generic;
ds@1952
     3
using System.Text;
ds@1952
     4
ds@1952
     5
namespace incparser
ds@1952
     6
{
ds@1952
     7
    class Program
ds@1952
     8
    {
ds@1952
     9
        static void Main(string[] args)
ds@1952
    10
        {
ds@1952
    11
            Environment.Exit(SubMain(args));
ds@1952
    12
        }
ds@1952
    13
ds@1952
    14
        static int SubMain(string[] args)
ds@1952
    15
        {
ds@1952
    16
            if (args.Length < 1)
ds@1952
    17
            {
ds@1952
    18
                Console.WriteLine("Usage: incparser <infile>");
ds@1952
    19
                return 1;
ds@1952
    20
            }
ds@1952
    21
ds@1952
    22
            IncParser inc = null;
ds@1952
    23
            try
ds@1952
    24
            {
ds@1952
    25
                inc = new IncParser(args[0]);
ds@1952
    26
            }
ds@1952
    27
            catch (ParseException e)
ds@1952
    28
            {
ds@1952
    29
                Console.WriteLine("Initial browsing failed: " + e.Message);
ds@1952
    30
                return 1;
ds@1952
    31
            }
ds@1952
    32
            catch (System.Exception e)
ds@1952
    33
            {
ds@1952
    34
                Console.WriteLine("Failed to read file: " + e.Message);
ds@1952
    35
                return 1;
ds@1952
    36
            }
ds@1952
    37
ds@1952
    38
            ParseWriter pw = new ParseWriter();
ds@1952
    39
ds@1952
    40
            try
ds@1952
    41
            {
ds@1952
    42
                inc.Parse(pw);
ds@1952
    43
            }
ds@1952
    44
            catch (System.Exception e)
ds@1952
    45
            {
ds@1952
    46
                Console.WriteLine("Error parsing file (line " + inc.GetLineNumber() + "): " + e.Message);
ds@1952
    47
                return 1;
ds@1952
    48
            }
ds@1952
    49
ds@1952
    50
            if (pw.Level != 0)
ds@1952
    51
            {
ds@1952
    52
                Console.WriteLine("Fatal parse error detected; unable to complete output.");
ds@1952
    53
                return 1;
ds@1952
    54
            }
ds@1952
    55
ds@1952
    56
            Console.Write(pw.Contents);
ds@1952
    57
            Console.Write("\n");
ds@1952
    58
ds@1952
    59
            return 0;
ds@1952
    60
        }
ds@1952
    61
    }
ds@1952
    62
}