示例#1
0
        public MondState()
        {
            _machine = new Machine(this);
            _librariesLoaded = false;

            Options = new MondCompilerOptions();

            Libraries = new MondLibraryManager
            {
                new StandardLibraries()
            };
        }
示例#2
0
        public MondState()
        {
            _machine         = new Machine(this);
            _prototypeCache  = new Dictionary <string, MondValue>();
            _librariesLoaded = false;

            Options = new MondCompilerOptions();

            Libraries = new MondLibraryManager
            {
                new StandardLibraries()
            };
        }
示例#3
0
        static void InteractiveMain(string[] args)
        {
            var useColoredInput = args.Any(s => s == "-c");

            if (useColoredInput)
            {
                _readLine = () => Highlighted.ReadLine(ref _highlighter);

                Console.CancelKeyPress += (sender, eventArgs) => Console.ResetColor();
            }
            else
            {
                _readLine = Console.ReadLine;
            }

            _input = new Queue<char>();
            _first = true;

            var libraries = new MondLibraryManager
            {
                new StandardLibraries()
            };

            var state = new MondState();
            var options = new MondCompilerOptions
            {
                MakeRootDeclarationsGlobal = true,
                UseImplicitGlobals = true
            };

            libraries.Load(state);

            while (true)
            {
                try
                {
                    options.FirstLineNumber = _line + 1;

                    foreach (var program in MondProgram.CompileStatements(ConsoleInput(), "stdin", options))
                    {
                        InteractiveRun(state, program);
                    }
                }
                catch (Exception e)
                {
                    PrintException(e);
                }
            }
        }