本文整理匯總了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;
}
示例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];
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例10: StartGroup
internal void StartGroup(RegexNode openGroup)
{
this._group = openGroup;
this._alternation = new RegexNode(0x18, this._options);
this._concatenation = new RegexNode(0x19, this._options);
}
示例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);
}
示例12: AddUnitType
internal void AddUnitType(int type)
{
this._unit = new RegexNode(type, this._options);
}
示例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();
}
}
}
示例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)
//.........這裏部分代碼省略.........
示例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;
}