CharDescription() 정적인 개인적인 메소드

static private CharDescription ( char ch ) : String
ch char
리턴 String
예제 #1
0
        internal virtual String TextposDescription()
        {
            StringBuilder Sb = new StringBuilder();
            int           remaining;

            Sb.Append(_runtextpos);

            if (Sb.Length < 8)
            {
                Sb.Append(' ', 8 - Sb.Length);
            }

            if (_runtextpos > _runtextbeg)
            {
                Sb.Append(RegexCharClass.CharDescription(_runtext[_runtextpos - 1]));
            }
            else
            {
                Sb.Append('^');
            }

            Sb.Append('>');

            remaining = _runtextend - _runtextpos;

            for (int i = _runtextpos; i < _runtextend; i++)
            {
                Sb.Append(RegexCharClass.CharDescription(_runtext[i]));
            }
            if (Sb.Length >= 64)
            {
                Sb.Length = 61;
                Sb.Append("...");
            }
            else
            {
                Sb.Append('$');
            }

            return(Sb.ToString());
        }
예제 #2
0
        internal virtual string TextposDescription()
        {
            var sb = new StringBuilder();
            int remaining;

            sb.Append(runtextpos);

            if (sb.Length < 8)
            {
                sb.Append(' ', 8 - sb.Length);
            }

            if (runtextpos > runtextbeg)
            {
                sb.Append(RegexCharClass.CharDescription(runtext[runtextpos - 1]));
            }
            else
            {
                sb.Append('^');
            }

            sb.Append('>');

            remaining = runtextend - runtextpos;

            for (int i = runtextpos; i < runtextend; i++)
            {
                sb.Append(RegexCharClass.CharDescription(runtext[i]));
            }
            if (sb.Length >= 64)
            {
                sb.Length = 61;
                sb.Append("...");
            }
            else
            {
                sb.Append('$');
            }

            return(sb.ToString());
        }
예제 #3
0
        internal string OpcodeDescription(int offset)
        {
            StringBuilder sb     = new StringBuilder();
            int           opcode = _codes[offset];

            sb.AppendFormat("{0:D6} ", offset);
            sb.Append(OpcodeBacktracks(opcode & Mask) ? '*' : ' ');
            sb.Append(OperatorDescription(opcode));
            sb.Append('(');

            opcode &= Mask;

            switch (opcode)
            {
            case One:
            case Notone:
            case Onerep:
            case Notonerep:
            case Oneloop:
            case Notoneloop:
            case Onelazy:
            case Notonelazy:
                sb.Append("Ch = ");
                sb.Append(RegexCharClass.CharDescription((char)_codes[offset + 1]));
                break;

            case Set:
            case Setrep:
            case Setloop:
            case Setlazy:
                sb.Append("Set = ");
                sb.Append(RegexCharClass.SetDescription(_strings[_codes[offset + 1]]));
                break;

            case Multi:
                sb.Append("String = ");
                sb.Append(_strings[_codes[offset + 1]]);
                break;

            case Ref:
            case Testref:
                sb.Append("Index = ");
                sb.Append(_codes[offset + 1]);
                break;

            case Capturemark:
                sb.Append("Index = ");
                sb.Append(_codes[offset + 1]);
                if (_codes[offset + 2] != -1)
                {
                    sb.Append(", Unindex = ");
                    sb.Append(_codes[offset + 2]);
                }
                break;

            case Nullcount:
            case Setcount:
                sb.Append("Value = ");
                sb.Append(_codes[offset + 1]);
                break;

            case Goto:
            case Lazybranch:
            case Branchmark:
            case Lazybranchmark:
            case Branchcount:
            case Lazybranchcount:
                sb.Append("Addr = ");
                sb.Append(_codes[offset + 1]);
                break;
            }

            switch (opcode)
            {
            case Onerep:
            case Notonerep:
            case Oneloop:
            case Notoneloop:
            case Onelazy:
            case Notonelazy:
            case Setrep:
            case Setloop:
            case Setlazy:
                sb.Append(", Rep = ");
                if (_codes[offset + 2] == int.MaxValue)
                {
                    sb.Append("inf");
                }
                else
                {
                    sb.Append(_codes[offset + 2]);
                }
                break;

            case Branchcount:
            case Lazybranchcount:
                sb.Append(", Limit = ");
                if (_codes[offset + 2] == int.MaxValue)
                {
                    sb.Append("inf");
                }
                else
                {
                    sb.Append(_codes[offset + 2]);
                }
                break;
            }

            sb.Append(')');

            return(sb.ToString());
        }
예제 #4
0
        internal String Description()
        {
            StringBuilder ArgSb = new StringBuilder();

            ArgSb.Append(TypeStr[_type]);

            if ((_options & RegexOptions.ExplicitCapture) != 0)
            {
                ArgSb.Append("-C");
            }
            if ((_options & RegexOptions.IgnoreCase) != 0)
            {
                ArgSb.Append("-I");
            }
            if ((_options & RegexOptions.RightToLeft) != 0)
            {
                ArgSb.Append("-L");
            }
            if ((_options & RegexOptions.Multiline) != 0)
            {
                ArgSb.Append("-M");
            }
            if ((_options & RegexOptions.Singleline) != 0)
            {
                ArgSb.Append("-S");
            }
            if ((_options & RegexOptions.IgnorePatternWhitespace) != 0)
            {
                ArgSb.Append("-X");
            }
            if ((_options & RegexOptions.ECMAScript) != 0)
            {
                ArgSb.Append("-E");
            }

            switch (_type)
            {
            case Oneloop:
            case Notoneloop:
            case Onelazy:
            case Notonelazy:
            case One:
            case Notone:
                ArgSb.Append("(Ch = " + RegexCharClass.CharDescription(_ch) + ")");
                break;

            case Capture:
                ArgSb.Append("(index = " + _m.ToString(CultureInfo.InvariantCulture) + ", unindex = " + _n.ToString(CultureInfo.InvariantCulture) + ")");
                break;

            case Ref:
            case Testref:
                ArgSb.Append("(index = " + _m.ToString(CultureInfo.InvariantCulture) + ")");
                break;

            case Multi:
                ArgSb.Append("(String = " + _str + ")");
                break;

            case Set:
            case Setloop:
            case Setlazy:
                ArgSb.Append("(Set = " + RegexCharClass.SetDescription(_str) + ")");
                break;
            }

            switch (_type)
            {
            case Oneloop:
            case Notoneloop:
            case Onelazy:
            case Notonelazy:
            case Setloop:
            case Setlazy:
            case Loop:
            case Lazyloop:
                ArgSb.Append("(Min = " + _m.ToString(CultureInfo.InvariantCulture) + ", Max = " + (_n == Int32.MaxValue ? "inf" : Convert.ToString(_n, CultureInfo.InvariantCulture)) + ")");
                break;
            }

            return(ArgSb.ToString());
        }
예제 #5
0
        internal static string OpcodeDescription(int offset, int[] codes, string[] strings)
        {
            var sb     = new StringBuilder();
            int opcode = codes[offset];

            sb.Append($"{offset:D6} ");
            sb.Append(OpcodeBacktracks(opcode & Mask) ? '*' : ' ');
            sb.Append(OperatorDescription(opcode));

            opcode &= Mask;

            switch (opcode)
            {
            case One:
            case Notone:
            case Onerep:
            case Notonerep:
            case Oneloop:
            case Oneloopatomic:
            case Notoneloop:
            case Notoneloopatomic:
            case Onelazy:
            case Notonelazy:
                sb.Append(Indent()).Append('\'').Append(RegexCharClass.CharDescription((char)codes[offset + 1])).Append('\'');
                break;

            case Set:
            case Setrep:
            case Setloop:
            case Setloopatomic:
            case Setlazy:
                sb.Append(Indent()).Append(RegexCharClass.SetDescription(strings[codes[offset + 1]]));
                break;

            case Multi:
                sb.Append(Indent()).Append('"').Append(strings[codes[offset + 1]]).Append('"');
                break;

            case Ref:
            case Testref:
                sb.Append(Indent()).Append("index = ").Append(codes[offset + 1]);
                break;

            case Capturemark:
                sb.Append(Indent()).Append("index = ").Append(codes[offset + 1]);
                if (codes[offset + 2] != -1)
                {
                    sb.Append(", unindex = ").Append(codes[offset + 2]);
                }
                break;

            case Nullcount:
            case Setcount:
                sb.Append(Indent()).Append("value = ").Append(codes[offset + 1]);
                break;

            case Goto:
            case Lazybranch:
            case Branchmark:
            case Lazybranchmark:
            case Branchcount:
            case Lazybranchcount:
                sb.Append(Indent()).Append("addr = ").Append(codes[offset + 1]);
                break;
            }

            switch (opcode)
            {
            case Onerep:
            case Notonerep:
            case Oneloop:
            case Oneloopatomic:
            case Notoneloop:
            case Notoneloopatomic:
            case Onelazy:
            case Notonelazy:
            case Setrep:
            case Setloop:
            case Setloopatomic:
            case Setlazy:
                sb.Append(", rep = ");
                if (codes[offset + 2] == int.MaxValue)
                {
                    sb.Append("inf");
                }
                else
                {
                    sb.Append(codes[offset + 2]);
                }
                break;

            case Branchcount:
            case Lazybranchcount:
                sb.Append(", limit = ");
                if (codes[offset + 2] == int.MaxValue)
                {
                    sb.Append("inf");
                }
                else
                {
                    sb.Append(codes[offset + 2]);
                }
                break;
            }

            string Indent() => new string(' ', Math.Max(1, 25 - sb.Length));

            return(sb.ToString());
        }