Пример #1
0
        public static bool ChooseSequence(IDebuggerEnvironment env, ref int seqToExecute, List <Sequence> sequences, SequenceNAry seq)
        {
            do
            {
                ConsoleKeyInfo key = env.ReadKeyWithCancel();
                switch (key.KeyChar)
                {
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                    int num = key.KeyChar - '0';
                    if (num >= sequences.Count)
                    {
                        Console.WriteLine("You must specify a number between 0 and " + (sequences.Count - 1) + "!");
                        break;
                    }
                    seqToExecute = num;
                    return(false);

                case 'e':
                    Console.Write("Enter number of sequence to show: ");
                    String numStr = Console.ReadLine();
                    if (int.TryParse(numStr, out num))
                    {
                        if (num < 0 || num >= sequences.Count)
                        {
                            Console.WriteLine("You must specify a number between 0 and " + (sequences.Count - 1) + "!");
                            break;
                        }
                        seqToExecute = num;
                        return(false);
                    }
                    Console.WriteLine("You must enter a valid integer number!");
                    break;

                case 's':
                case 'n':
                    return(true);

                case 'u':
                case 'o':
                    seq.Skip = true; // skip remaining rules (reset after exection of seq)
                    return(true);

                default:
                    Console.WriteLine("Illegal choice (Key = " + key.Key
                                      + ")! Only (0)...(9), (e)nter number, (s)/(n) to commit and continue, (u)/(o) to commit and skip remaining choices allowed! ");
                    break;
                }
            }while(true);
        }
Пример #2
0
 public int ChooseSequence(int seqToExecute, List <Sequence> sequences, SequenceNAry seq)
 {
     return(seqToExecute);
 }
Пример #3
0
        private static void PrintSequenceNAry(SequenceNAry seqN, Sequence parent, PrintSequenceContext context)
        {
            if (context.cpPosCounter >= 0)
            {
                PrintChoice(seqN, context);
                ++context.cpPosCounter;
                Console.Write((seqN.Choice ? "$%" : "$") + seqN.OperatorSymbol + "(");
                bool first = true;
                foreach (Sequence seqChild in seqN.Children)
                {
                    if (!first)
                    {
                        Console.Write(", ");
                    }
                    PrintSequence(seqChild, seqN, context);
                    first = false;
                }
                Console.Write(")");
                return;
            }

            bool highlight = false;

            foreach (Sequence seqChild in seqN.Children)
            {
                if (seqChild == context.highlightSeq)
                {
                    highlight = true;
                }
            }
            if (highlight && context.choice)
            {
                WorkaroundManager.Workaround.PrintHighlighted("$%" + seqN.OperatorSymbol + "(", HighlightingMode.Choicepoint);
                bool first = true;
                foreach (Sequence seqChild in seqN.Children)
                {
                    if (!first)
                    {
                        Console.Write(", ");
                    }
                    if (seqChild == context.highlightSeq)
                    {
                        WorkaroundManager.Workaround.PrintHighlighted(">>", HighlightingMode.Choicepoint);
                    }
                    if (context.sequences != null)
                    {
                        for (int i = 0; i < context.sequences.Count; ++i)
                        {
                            if (seqChild == context.sequences[i])
                            {
                                WorkaroundManager.Workaround.PrintHighlighted("(" + i + ")", HighlightingMode.Choicepoint);
                            }
                        }
                    }

                    Sequence highlightSeqBackup = context.highlightSeq;
                    context.highlightSeq = null; // we already highlighted here
                    PrintSequence(seqChild, seqN, context);
                    context.highlightSeq = highlightSeqBackup;

                    if (seqChild == context.highlightSeq)
                    {
                        WorkaroundManager.Workaround.PrintHighlighted("<<", HighlightingMode.Choicepoint);
                    }
                    first = false;
                }
                WorkaroundManager.Workaround.PrintHighlighted(")", HighlightingMode.Choicepoint);
                return;
            }

            Console.Write((seqN.Choice ? "$%" : "$") + seqN.OperatorSymbol + "(");
            PrintChildren(seqN, context);
            Console.Write(")");
        }