• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# RegularExpressions.RegexNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: AddUnitSet

 /*
  * Sets the current unit to a single set node
  */
 internal void AddUnitSet(string cc)
 {
     _unit = new RegexNode(RegexNode.Set, _options, cc);
 }
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:RegexParser.cs


示例17: CalculateFC

        /*
         * FC computation and shortcut cases for each node type
         */
        private void CalculateFC(int NodeType, RegexNode node, int CurIndex)
        {
            bool ci = false;
            bool rtl = false;

            if (NodeType <= RegexNode.Ref)
            {
                if ((node._options & RegexOptions.IgnoreCase) != 0)
                    ci = true;
                if ((node._options & RegexOptions.RightToLeft) != 0)
                    rtl = true;
            }

            switch (NodeType)
            {
                case RegexNode.Concatenate | BeforeChild:
                case RegexNode.Alternate | BeforeChild:
                case RegexNode.Testref | BeforeChild:
                case RegexNode.Loop | BeforeChild:
                case RegexNode.Lazyloop | BeforeChild:
                    break;

                case RegexNode.Testgroup | BeforeChild:
                    if (CurIndex == 0)
                        SkipChild();
                    break;

                case RegexNode.Empty:
                    PushFC(new RegexFC(true));
                    break;

                case RegexNode.Concatenate | AfterChild:
                    if (CurIndex != 0)
                    {
                        RegexFC child = PopFC();
                        RegexFC cumul = TopFC();

                        _failed = !cumul.AddFC(child, true);
                    }

                    if (!TopFC()._nullable)
                        _skipAllChildren = true;
                    break;

                case RegexNode.Testgroup | AfterChild:
                    if (CurIndex > 1)
                    {
                        RegexFC child = PopFC();
                        RegexFC cumul = TopFC();

                        _failed = !cumul.AddFC(child, false);
                    }
                    break;

                case RegexNode.Alternate | AfterChild:
                case RegexNode.Testref | AfterChild:
                    if (CurIndex != 0)
                    {
                        RegexFC child = PopFC();
                        RegexFC cumul = TopFC();

                        _failed = !cumul.AddFC(child, false);
                    }
                    break;

                case RegexNode.Loop | AfterChild:
                case RegexNode.Lazyloop | AfterChild:
                    if (node._m == 0)
                        TopFC()._nullable = true;
                    break;

                case RegexNode.Group | BeforeChild:
                case RegexNode.Group | AfterChild:
                case RegexNode.Capture | BeforeChild:
                case RegexNode.Capture | AfterChild:
                case RegexNode.Greedy | BeforeChild:
                case RegexNode.Greedy | AfterChild:
                    break;

                case RegexNode.Require | BeforeChild:
                case RegexNode.Prevent | BeforeChild:
                    SkipChild();
                    PushFC(new RegexFC(true));
                    break;

                case RegexNode.Require | AfterChild:
                case RegexNode.Prevent | AfterChild:
                    break;

                case RegexNode.One:
                case RegexNode.Notone:
                    PushFC(new RegexFC(node._ch, NodeType == RegexNode.Notone, false, ci));
                    break;

                case RegexNode.Oneloop:
                case RegexNode.Onelazy:
                    PushFC(new RegexFC(node._ch, false, node._m == 0, ci));
//.........这里部分代码省略.........
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:101,代码来源:RegexFCD.cs


示例18: AddChild

        internal void AddChild(RegexNode newChild) {
            RegexNode reducedChild;

            if (_children == null)
                _children = new List<RegexNode>(4);

            reducedChild = newChild.Reduce();

            _children.Add(reducedChild);
            reducedChild._next = this;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:11,代码来源:RegexNode.cs


示例19: MakeQuantifier

        internal RegexNode MakeQuantifier(bool lazy, int min, int max) {
            RegexNode result;

            if (min == 0 && max == 0)
                return new RegexNode(RegexNode.Empty, _options);

            if (min == 1 && max == 1)
                return this;

            switch (_type) {
                case RegexNode.One:
                case RegexNode.Notone:
                case RegexNode.Set:

                    MakeRep(lazy ? RegexNode.Onelazy : RegexNode.Oneloop, min, max);
                    return this;

                default:
                    result = new RegexNode(lazy ? RegexNode.Lazyloop : RegexNode.Loop, _options, min, max);
                    result.AddChild(this);
                    return result;
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:23,代码来源:RegexNode.cs


示例20: AddUnitNode

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Threading.AutoResetEvent类代码示例发布时间:2022-05-26
下一篇:
C# RegularExpressions.Regex类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap