Esempio n. 1
0
 public static int Main(string[] args)
 {
     try
     {
         int res = 0;
         if (args.Length!=0)
         {
             ComponentLoader components = EngineTest.InitComponents();
             WrappedConsole console = new WrappedConsole();
             bool interactive;
             string saveProjectFile;
             Project project = CommandLine.Prepare(args, components, console, out interactive, out saveProjectFile);
             if (project!=null)
             {
                 project.EngineOptions.DumpResults = false;
                 project.EngineOptions.StatusLine = false;
                 project.ParserOptions.Instructions = false;
                 project.ParserOptions.StatusLine = false;
             }
             ParseResult result = CommandLine.Parse(components, console, project);
             if (result==null || !result.Succesfull)
             {
                 return -1;
             }
             CommandLine.Run(components, console, project);
             return 0;
         }
         else
         {
             //MainParser();
             MainEngine();
         }
         if (res == 0)
             Console.WriteLine("No errors");
         return res;
     }
     catch (Exception ex)
     {
         return ExceptionHandler.DumpException(ex);
     }
 }
Esempio n. 2
0
        public static int ConsoleMain(string[] args)
        {
            WrappedConsole console = new WrappedConsole();
            ConsoleCfg consoleConfig = new ConsoleCfg();
            if (!MonoCheck.IsMonoRuntime)
            {
                consoleConfig.Reload();
            }
            LoadPlugins(consoleConfig);

            ComponentLoader components = new ComponentLoader();
            if (!MonoCheck.IsMonoRuntime)
            {
                components.ParserName = consoleConfig.DefaultParser;
                components.EngineName = consoleConfig.DefaultEngine;
            }
            else
            {
                components.ParserName = "nMars.Parser";
                components.EngineName = "nMars.Engine";
            }

            bool interactive;
            string saveProjectFile;
            Project project = CommandLine.Prepare(args, components, console, out interactive, out saveProjectFile);
            if (project == null)
                return -1;
            if (interactive)
            {
                if (consoleConfig.KnownComponents.Contains("nMars.ShellPy"))
                {
                    IShell shellpy = ModuleRegister.CreateShell("nMars.ShellPy");
                    Shells.Add(shellpy);
                }
                components.EngineName = consoleConfig.DefaultDebugEngine;

                foreach (IShell shell in Shells)
                {
                    shell.Attach(console, Shells);
                    shell.Project = project;
                    shell.Components = components;
                    shell.PrintErrors = true;
                    shell.Engine = components.AsyncEngineWrapper;
                    shell.Register(components.AsyncEngineWrapper, "engine");
                }
                console.Inject("step");
                console.Interactive();
                foreach (IShell shell in Shells)
                {
                    shell.Detach();
                }
            }
            else
            {
                if (project.EngineOptions.EngineMode != EngineMode.Match)
                {
                    project.Rules.WarriorsCount = 2;
                }

                ParseResult result = CommandLine.Parse(components, console, project);
                if (result == null || !result.Succesfull)
                    return -2;

                CommandLine.Run(components, console, project);
            }
            if (saveProjectFile != null)
                project.SaveXml(saveProjectFile);
            return 0;
        }