当前位置: 首页>>代码示例>>C#>>正文


C# RegularExpressions.RegexNode类代码示例

本文整理汇总了C#中System.Text.RegularExpressions.RegexNode的典型用法代码示例。如果您正苦于以下问题:C# RegexNode类的具体用法?C# RegexNode怎么用?C# RegexNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RegexNode类属于System.Text.RegularExpressions命名空间,在下文中一共展示了RegexNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RegexTree

 internal RegexTree(RegexNode root, Hashtable caps, Object[] capnumlist, int captop, Hashtable capnames, String[] capslist, RegexOptions opts) {
     _root = root;
     _caps = caps;
     _capnumlist = capnumlist;
     _capnames = capnames;
     _capslist = capslist;
     _captop = captop;
     _options = opts;
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:9,代码来源:regextree.cs

示例2: RegexReplacement

 internal RegexReplacement(string rep, RegexNode concat, System.Collections.Generic.Dictionary<object,object> _caps)
 {
     this._rep = rep;
     if (concat.Type() != 0x19)
     {
         throw new ArgumentException(RegExRes.GetString(0x25));
     }
     StringBuilder builder = new StringBuilder();
     ArrayList list = new ArrayList();
     ArrayList list2 = new ArrayList();
     for (int i = 0; i < concat.ChildCount(); i++)
     {
         RegexNode node = concat.Child(i);
         switch (node.Type())
         {
             case 9:
             {
                 builder.Append(node._ch);
                 continue;
             }
             case 12:
             {
                 builder.Append(node._str);
                 continue;
             }
             case 13:
             {
                 if (builder.Length > 0)
                 {
                     list2.Add(list.Count);
                     list.Add(builder.ToString());
                     builder.Length = 0;
                 }
                 int num = node._m;
                 if ((_caps != null) && (num >= 0))
                 {
                     num = (int) _caps[num];
                 }
                 list2.Add(-5 - num);
                 continue;
             }
         }
         throw new ArgumentException(RegExRes.GetString(0x25));
     }
     if (builder.Length > 0)
     {
         list2.Add(list.Count);
         list.Add(builder.ToString());
     }
     this._strings = new string[list.Count];
     list.CopyTo(0, this._strings, 0, list.Count);
     this._rules = new int[list2.Count];
     for (int j = 0; j < list2.Count; j++)
     {
         this._rules[j] = (int) list2[j];
     }
 }
开发者ID:memsom,项目名称:dotNetAnywhere-wb,代码行数:57,代码来源:RegexReplacement.cs

示例3: RegexReplacement

        /*
         * Since RegexReplacement shares the same parser as Regex,
         * the constructor takes a RegexNode which is a concatenation
         * of constant strings and backreferences.
         */
        internal RegexReplacement(String rep, RegexNode concat, Dictionary<Int32, Int32> _caps)
        {
            StringBuilder sb;
            List<String> strings;
            List<Int32> rules;
            int slot;

            _rep = rep;

            if (concat.Type() != RegexNode.Concatenate)
                throw new ArgumentException(SR.ReplacementError);

            sb = new StringBuilder();
            strings = new List<String>();
            rules = new List<Int32>();

            for (int i = 0; i < concat.ChildCount(); i++)
            {
                RegexNode child = concat.Child(i);

                switch (child.Type())
                {
                    case RegexNode.Multi:
                        sb.Append(child._str);
                        break;
                    case RegexNode.One:
                        sb.Append(child._ch);
                        break;
                    case RegexNode.Ref:
                        if (sb.Length > 0)
                        {
                            rules.Add(strings.Count);
                            strings.Add(sb.ToString());
                            sb.Length = 0;
                        }
                        slot = child._m;

                        if (_caps != null && slot >= 0)
                            slot = (int)_caps[slot];

                        rules.Add(-Specials - 1 - slot);
                        break;
                    default:
                        throw new ArgumentException(SR.ReplacementError);
                }
            }

            if (sb.Length > 0)
            {
                rules.Add(strings.Count);
                strings.Add(sb.ToString());
            }

            _strings = strings;
            _rules = rules;
        }
开发者ID:svcgany1,项目名称:corefx,代码行数:61,代码来源:RegexReplacement.cs

示例4: RegexTree

 internal RegexTree(RegexNode root, Dictionary<Int32, Int32> caps, Int32[] capnumlist, int captop, Dictionary<String, Int32> capnames, String[] capslist, RegexOptions opts)
 {
     _root = root;
     _caps = caps;
     _capnumlist = capnumlist;
     _capnames = capnames;
     _capslist = capslist;
     _captop = captop;
     _options = opts;
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:10,代码来源:RegexTree.cs

示例5: RegexTree

 internal RegexTree(RegexNode root, Hashtable caps, int[] capnumlist, int captop, Hashtable capnames, string[] capslist, RegexOptions opts)
 {
     this._root = root;
     this._caps = caps;
     this._capnumlist = capnumlist;
     this._capnames = capnames;
     this._capslist = capslist;
     this._captop = captop;
     this._options = opts;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:RegexTree.cs

示例6: RegexReplacement

        private readonly List<string> _strings; // table of string constants

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Since RegexReplacement shares the same parser as Regex,
        /// the constructor takes a RegexNode which is a concatenation
        /// of constant strings and backreferences.
        /// </summary>
        internal RegexReplacement(string rep, RegexNode concat, Hashtable _caps)
        {
            if (concat.Type() != RegexNode.Concatenate)
                throw new ArgumentException(SR.ReplacementError);

            StringBuilder sb = StringBuilderCache.Acquire();
            List<string> strings = new List<string>();
            List<int> rules = new List<int>();

            for (int i = 0; i < concat.ChildCount(); i++)
            {
                RegexNode child = concat.Child(i);

                switch (child.Type())
                {
                    case RegexNode.Multi:
                        sb.Append(child._str);
                        break;

                    case RegexNode.One:
                        sb.Append(child._ch);
                        break;

                    case RegexNode.Ref:
                        if (sb.Length > 0)
                        {
                            rules.Add(strings.Count);
                            strings.Add(sb.ToString());
                            sb.Length = 0;
                        }
                        int slot = child._m;

                        if (_caps != null && slot >= 0)
                            slot = (int)_caps[slot];

                        rules.Add(-Specials - 1 - slot);
                        break;

                    default:
                        throw new ArgumentException(SR.ReplacementError);
                }
            }

            if (sb.Length > 0)
            {
                rules.Add(strings.Count);
                strings.Add(sb.ToString());
            }

            StringBuilderCache.Release(sb);

            _rep = rep;
            _strings = strings;
            _rules = rules;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:66,代码来源:RegexReplacement.cs

示例7: RegexTree

 internal RegexTree(RegexNode root, System.Collections.Generic.Dictionary<object,object> caps, 
     object[] capnumlist, int captop, System.Collections.Generic.Dictionary<object,object> capnames, string[] capslist, RegexOptions opts)
 {
     this._root = root;
     this._caps = caps;
     this._capnumlist = capnumlist;
     this._capnames = capnames;
     this._capslist = capslist;
     this._captop = captop;
     this._options = opts;
 }
开发者ID:memsom,项目名称:dotNetAnywhere-wb,代码行数:11,代码来源:RegexTree.cs

示例8: AddAlternate

 internal void AddAlternate()
 {
     if ((this._group.Type() == 0x22) || (this._group.Type() == 0x21))
     {
         this._group.AddChild(this._concatenation.ReverseLeft());
     }
     else
     {
         this._alternation.AddChild(this._concatenation.ReverseLeft());
     }
     this._concatenation = new RegexNode(0x19, this._options);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:RegexParser.cs

示例9: RegexReplacement

 internal RegexReplacement(string rep, RegexNode concat, Hashtable _caps)
 {
     this._rep = rep;
     if (concat.Type() != 0x19)
     {
         throw new ArgumentException(SR.GetString("ReplacementError"));
     }
     StringBuilder builder = new StringBuilder();
     List<string> list = new List<string>();
     List<int> list2 = new List<int>();
     for (int i = 0; i < concat.ChildCount(); i++)
     {
         RegexNode node = concat.Child(i);
         switch (node.Type())
         {
             case 9:
             {
                 builder.Append(node._ch);
                 continue;
             }
             case 12:
             {
                 builder.Append(node._str);
                 continue;
             }
             case 13:
             {
                 if (builder.Length > 0)
                 {
                     list2.Add(list.Count);
                     list.Add(builder.ToString());
                     builder.Length = 0;
                 }
                 int num = node._m;
                 if ((_caps != null) && (num >= 0))
                 {
                     num = (int) _caps[num];
                 }
                 list2.Add(-5 - num);
                 continue;
             }
         }
         throw new ArgumentException(SR.GetString("ReplacementError"));
     }
     if (builder.Length > 0)
     {
         list2.Add(list.Count);
         list.Add(builder.ToString());
     }
     this._strings = list;
     this._rules = list2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:52,代码来源:RegexReplacement.cs

示例10: StartGroup

 internal void StartGroup(RegexNode openGroup)
 {
     this._group = openGroup;
     this._alternation = new RegexNode(0x18, this._options);
     this._concatenation = new RegexNode(0x19, this._options);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:6,代码来源:RegexParser.cs

示例11: AddUnitNotone

        /*
         * Sets the current unit to a single inverse-char node
         */
        internal void AddUnitNotone(char ch)
        {
            if (UseOptionI())
                ch = _culture.TextInfo.ToLower(ch);

            _unit = new RegexNode(RegexNode.Notone, _options, ch);
        }
开发者ID:Corillian,项目名称:corefx,代码行数:10,代码来源:RegexParser.cs

示例12: AddUnitType

 internal void AddUnitType(int type)
 {
     this._unit = new RegexNode(type, this._options);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:RegexParser.cs

示例13: ScanReplacement

 internal RegexNode ScanReplacement()
 {
     this._concatenation = new RegexNode(0x19, this._options);
     while (true)
     {
         int num = this.CharsRight();
         if (num == 0)
         {
             return this._concatenation;
         }
         int pos = this.Textpos();
         while ((num > 0) && (this.RightChar() != '$'))
         {
             this.MoveRight();
             num--;
         }
         this.AddConcatenate(pos, this.Textpos() - pos, true);
         if (num > 0)
         {
             if (this.MoveRightGetChar() == '$')
             {
                 this.AddUnitNode(this.ScanDollar());
             }
             this.AddConcatenate();
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:RegexParser.cs

示例14: EmitFragment

        /// <summary>
        /// The main RegexCode generator. It does a depth-first walk
        /// through the tree and calls EmitFragment to emits code before
        /// and after each child of an interior node, and at each leaf.
        /// </summary>
        private void EmitFragment(int nodetype, RegexNode node, int curIndex)
        {
            int bits = 0;

            if (nodetype <= RegexNode.Ref)
            {
                if (node.UseOptionR())
                    bits |= RegexCode.Rtl;
                if ((node._options & RegexOptions.IgnoreCase) != 0)
                    bits |= RegexCode.Ci;
            }

            switch (nodetype)
            {
                case RegexNode.Concatenate | BeforeChild:
                case RegexNode.Concatenate | AfterChild:
                case RegexNode.Empty:
                    break;

                case RegexNode.Alternate | BeforeChild:
                    if (curIndex < node._children.Count - 1)
                    {
                        PushInt(CurPos());
                        Emit(RegexCode.Lazybranch, 0);
                    }
                    break;

                case RegexNode.Alternate | AfterChild:
                    {
                        if (curIndex < node._children.Count - 1)
                        {
                            int LBPos = PopInt();
                            PushInt(CurPos());
                            Emit(RegexCode.Goto, 0);
                            PatchJump(LBPos, CurPos());
                        }
                        else
                        {
                            int I;
                            for (I = 0; I < curIndex; I++)
                            {
                                PatchJump(PopInt(), CurPos());
                            }
                        }
                        break;
                    }

                case RegexNode.Testref | BeforeChild:
                    switch (curIndex)
                    {
                        case 0:
                            Emit(RegexCode.Setjump);
                            PushInt(CurPos());
                            Emit(RegexCode.Lazybranch, 0);
                            Emit(RegexCode.Testref, MapCapnum(node._m));
                            Emit(RegexCode.Forejump);
                            break;
                    }
                    break;

                case RegexNode.Testref | AfterChild:
                    switch (curIndex)
                    {
                        case 0:
                            {
                                int Branchpos = PopInt();
                                PushInt(CurPos());
                                Emit(RegexCode.Goto, 0);
                                PatchJump(Branchpos, CurPos());
                                Emit(RegexCode.Forejump);
                                if (node._children.Count > 1)
                                    break;
                                // else fallthrough
                                goto case 1;
                            }
                        case 1:
                            PatchJump(PopInt(), CurPos());
                            break;
                    }
                    break;

                case RegexNode.Testgroup | BeforeChild:
                    switch (curIndex)
                    {
                        case 0:
                            Emit(RegexCode.Setjump);
                            Emit(RegexCode.Setmark);
                            PushInt(CurPos());
                            Emit(RegexCode.Lazybranch, 0);
                            break;
                    }
                    break;

                case RegexNode.Testgroup | AfterChild:
                    switch (curIndex)
//.........这里部分代码省略.........
开发者ID:noahfalk,项目名称:corefx,代码行数:101,代码来源:RegexWriter.cs

示例15: AddGroup

        /*
         * Finish the current group (in response to a ')' or end)
         */
        internal void AddGroup()
        {
            if (_group.Type() == RegexNode.Testgroup || _group.Type() == RegexNode.Testref)
            {
                _group.AddChild(_concatenation.ReverseLeft());

                if (_group.Type() == RegexNode.Testref && _group.ChildCount() > 2 || _group.ChildCount() > 3)
                    throw MakeException(SR.TooManyAlternates);
            }
            else
            {
                _alternation.AddChild(_concatenation.ReverseLeft());
                _group.AddChild(_alternation);
            }

            _unit = _group;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:20,代码来源:RegexParser.cs


注:本文中的System.Text.RegularExpressions.RegexNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。