Beispiel #1
0
        private bool EvalChar(Mode mode, ref int ptr, ref int pc, bool multi)
        {
            bool flag = false;
            char c    = '\0';
            bool flag3;

            do
            {
                ushort  num     = program[pc];
                OpCode  opCode  = (OpCode)(num & 0xFF);
                OpFlags opFlags = (OpFlags)(num & 0xFF00);
                pc++;
                bool flag2 = (opFlags & OpFlags.IgnoreCase) != OpFlags.None;
                if (!flag)
                {
                    if ((opFlags & OpFlags.RightToLeft) != 0)
                    {
                        if (ptr <= 0)
                        {
                            return(false);
                        }
                        c = text[--ptr];
                    }
                    else
                    {
                        if (ptr >= text_end)
                        {
                            return(false);
                        }
                        c = text[ptr++];
                    }
                    if (flag2)
                    {
                        c = char.ToLower(c);
                    }
                    flag = true;
                }
                flag3 = ((opFlags & OpFlags.Negate) != OpFlags.None);
                switch (opCode)
                {
                case OpCode.True:
                    return(true);

                case OpCode.False:
                    return(false);

                case OpCode.Character:
                    if (c == program[pc++])
                    {
                        return(!flag3);
                    }
                    break;

                case OpCode.Category:
                    if (CategoryUtils.IsCategory((Category)program[pc++], c))
                    {
                        return(!flag3);
                    }
                    break;

                case OpCode.NotCategory:
                    if (!CategoryUtils.IsCategory((Category)program[pc++], c))
                    {
                        return(!flag3);
                    }
                    break;

                case OpCode.Range:
                {
                    int num6 = program[pc++];
                    int num7 = program[pc++];
                    if (num6 <= c && c <= num7)
                    {
                        return(!flag3);
                    }
                    break;
                }

                case OpCode.Set:
                {
                    int num2 = program[pc++];
                    int num3 = program[pc++];
                    int num4 = pc;
                    pc += num3;
                    int num5 = c - num2;
                    if (num5 < 0 || num5 >= num3 << 4 || (program[num4 + (num5 >> 4)] & (1 << (num5 & 0xF))) == 0)
                    {
                        break;
                    }
                    return(!flag3);
                }
                }
            }while (multi);
            return(flag3);
        }
Beispiel #2
0
 private bool IsWordChar(char c)
 {
     return(CategoryUtils.IsCategory(Category.Word, c));
 }