예제 #1
0
파일: Compiler.cs 프로젝트: fossabot/Axion
        private static void EnterInteractiveMode()
        {
            Logger.Info(
                "Axion code editor & interpreter mode.\n"
                + "Type 'exit' or 'quit' to exit mode, 'cls' to clear screen."
                );
            while (true)
            {
                // code editor header
                string rawInput = ConsoleUI.Read("i>> ");
                string input    = rawInput.Trim().ToUpper();

                switch (input)
                {
                case "":
                    // skip empty commands
                    ConsoleUI.ClearLine();
                    continue;

                case "EXIT":
                case "QUIT":
                    // exit from interpreter to main loop
                    Logger.Info("\nInteractive interpreter closed.");
                    return;
                }

                // TODO (UI) parse "help(module)" argument

                // initialize editor
                var editor = new ConsoleCodeEditor(
                    false,
                    true,
                    firstCodeLine: rawInput,
                    highlighter: new AxionSyntaxHighlighter()
                    );
                string[] codeLines = editor.RunSession();
                // interpret as source code and output result
                Process(new SourceUnit(codeLines), SourceProcessingMode.Interpret);
            }
        }