Пример #1
0
        protected void PreProcess(Point Entry)
        {
            //Uncomment to show Program overview at start of execution
            //Overview(Entry);
            OutWriter.Debug("[ PREPROC ]  Started Preprocessor...");
            IEnumerator <Point> it = new Iteration2D(Entry.X, Entry.Y, Program.GetLength(0), Program.GetLength(1))
                                     .Snake(270, true);

            while (it.MoveNext())
            {
                //Jump to labels only
                switch ((CodeChar.Order)GetAt(it.Current))
                {
                //Skip none
                case CodeChar.Order.Entry:
                case CodeChar.Order.WriteLn:
                case CodeChar.Order.Parse:
                case CodeChar.Order.Exit:
                    break;

                //Skip two
                case CodeChar.Order.If:
                case CodeChar.Order.Math:
                case CodeChar.Order.Not:
                    it.MoveNext(); it.MoveNext();
                    break;

                //Label: mark
                case CodeChar.Order.Label:
                    Point pt = it.Current;
                    it.MoveNext();
                    Labels[GetAt(it.Current)] = new Point(it.Current.X, it.Current.Y);
                    OutWriter.Debug($"[ PREPROC ]      @{pt.ToString()}: Encountered Mark Label: ({GetAt(it.Current).ToString()}) := {Labels[GetAt(it.Current)].ToString()}");
                    break;

                //Skip one
                default:
                    it.MoveNext();
                    break;
                }
            }
            OutWriter.Debug("[ PREPROC ]    Labels:");
            Labels.Select(x => $"{x.Key}: ({x.Value.X}, {x.Value.Y})").ToList().ForEach(x => OutWriter.Debug($"[ PREPROC ]      {x}"));
            OutWriter.Debug("[ PREPROC ]  Preprocessor Ready.");
        }
Пример #2
0
        protected void Overview(Point Entry)
        {
            OutWriter.Debug("   ====  PROGRAM OVERVIEW  ====   ");
            IEnumerator <Point> it = new Iteration2D(Entry.X, Entry.Y, Program.GetLength(0), Program.GetLength(1)).Snake(270, true);

            while (it.MoveNext())
            {
                OutWriter.Debug("    " + GetAt(it.Current).ToString());
            }
            OutWriter.Debug("   ====  END OF OVERVIEW  ====   ");
        }