Exemplo n.º 1
0
        public static void Main(string[] args)
		{
            bool RegisterFlag = false;
			foreach (string arg in args)
			{
                if (RegisterFlag)
                {
                    Output.RegisterObject(new object(), arg);
                    RegisterFlag = false;
                    continue;
                }

				switch (arg)
				{
					case "-v":
						verbose = true;
						break;
					
					case "--token":
						WhatShouldIDo = "token";
						break;
					
					case "--ast":
						WhatShouldIDo = "ast";
						break;
						
					case "--interprete":
						WhatShouldIDo = "interprete";
						break;

                    case "--register":
                        RegisterFlag = true;
                        break;

					default:
                        if (File.Exists(arg))
                            FilePath = arg;
                        else
                            Console.WriteLine("The given file was not found.");
						break;
				}
			}

            Console.WriteLine("DialogueShell - DialogueScript command line tester and parser");

            Stream Source;

            if (FilePath == null)
            {
                while (true)
                {
                    Console.Write(">>> "); string Expression = Console.ReadLine();
                    Console.WriteLine("- - - - - - - - - - - - - - -");

                    if (Expression.ToLower() == "exit")
                        return;

                    try
                    {
                        using (Source = Expression.ToStream())
                            DoEverything(Source, Output);
                    }
                    catch (Exception e)
                    {
                        Output.Exception(e);
                        Console.WriteLine("Restarting DialogueShell... \n\n");
                    }
                }
            }
            else
            {
                try
                {
                    using (Source = new FileStream(FilePath, FileMode.Open))
                        DoEverything(Source, Output);
                }
                catch (Exception e)
                {
                    Output.Exception(e);
                    Console.WriteLine("\nPress any key to close DialogueShell...");
                    Console.ReadKey();
                }
            }
        }