SetDescription() static private method

static private SetDescription ( String set ) : String
set String
return String
Example #1
0
        internal void Dump()
        {
            int i;

            Debug.WriteLine("Direction:  " + (_rightToLeft ? "right-to-left" : "left-to-right"));
            Debug.WriteLine("Firstchars: " + (_fcPrefix == null ? "n/a" : RegexCharClass.SetDescription(_fcPrefix.Prefix)));
            Debug.WriteLine("Prefix:     " + (_bmPrefix == null ? "n/a" : Regex.Escape(_bmPrefix.ToString())));
            Debug.WriteLine("Anchors:    " + RegexFCD.AnchorDescription(_anchors));
            Debug.WriteLine("Scanchars:  " + (_scPrefix == null ? "n/a" : RegexCharClass.SetDescription(_scPrefix.Prefix)));
            Debug.WriteLine("");

            /*
             * if (_bmPrefix != null) {
             *  Debug.WriteLine("BoyerMoore:");
             *  Debug.WriteLine(_bmPrefix.Dump("    "));
             * }
             */
            for (i = 0; i < _codes.Length;)
            {
                Debug.WriteLine(OpcodeDescription(i));
                i += OpcodeSize(_codes[i]);
            }

            Debug.WriteLine("");
        }
Example #2
0
        public void Dump()
        {
            int i;

            Debug.WriteLine("Direction:  " + (RightToLeft ? "right-to-left" : "left-to-right"));
            Debug.WriteLine("Firstchars: " + (FCPrefix == null ? "n/a" : RegexCharClass.SetDescription(FCPrefix.GetValueOrDefault().Prefix)));
            Debug.WriteLine("Prefix:     " + (BMPrefix == null ? "n/a" : Regex.Escape(BMPrefix.ToString())));
            Debug.WriteLine("Anchors:    " + RegexFCD.AnchorDescription(Anchors));
            Debug.WriteLine("");
            if (BMPrefix != null)
            {
                Debug.WriteLine("BoyerMoore:");
                Debug.WriteLine(BMPrefix.Dump("    "));
            }
            for (i = 0; i < Codes.Length;)
            {
                Debug.WriteLine(OpcodeDescription(i));
                i += OpcodeSize(Codes[i]);
            }

            Debug.WriteLine("");
        }
Example #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());
        }
Example #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());
        }
Example #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());
        }