本文整理汇总了C#中System.Text.RegularExpressions.RegexNode.Type方法的典型用法代码示例。如果您正苦于以下问题:C# RegexNode.Type方法的具体用法?C# RegexNode.Type怎么用?C# RegexNode.Type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.RegularExpressions.RegexNode
的用法示例。
在下文中一共展示了RegexNode.Type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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];
}
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: PopGroup
/*
* Remember the pushed state (in response to a ')')
*/
internal void PopGroup()
{
_concatenation = _stack;
_alternation = _concatenation._next;
_group = _alternation._next;
_stack = _group._next;
// The first () inside a Testgroup group goes directly to the group
if (_group.Type() == RegexNode.Testgroup && _group.ChildCount() == 0)
{
if (_unit == null)
throw MakeException(SR.IllegalCondition);
_group.AddChild(_unit);
_unit = null;
}
}