本文整理汇总了C#中NFA.AddNode方法的典型用法代码示例。如果您正苦于以下问题:C# NFA.AddNode方法的具体用法?C# NFA.AddNode怎么用?C# NFA.AddNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NFA
的用法示例。
在下文中一共展示了NFA.AddNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Lexer
public Lexer(NFA pad, string tag, LAD[] alts)
{
this.pad = pad;
this.alts = alts;
this.tag = tag;
int root = pad.AddNode();
int[] alt_shuffle = new int[alts.Length];
for (int i = 0; i < alts.Length; i++) alt_shuffle[i] = i;
Array.Sort(alt_shuffle, delegate (int i1, int i2) {
int j1, j2;
bool c1, c2;
alts[i1].QueryLiteral(pad, out j1, out c1);
alts[i2].QueryLiteral(pad, out j2, out c2);
return (j1 != j2) ? (j2 - j1) : (i1 - i2);
});
for (int ix = 0; ix < alts.Length; ix++) {
pad.curfate = alt_shuffle[ix];
int target = pad.AddNode();
pad.nodes_l[target].final = true;
alts[alt_shuffle[ix]].ToNFA(pad, root, target);
}
nfates = alts.Length;
fatebuffer = new int[nfates*2+2];
for (int i = 0; i < nfates*2+2; i++)
fatebuffer[i] = -1;
fatebuffer[0] = fatebuffer[1] = 0;
pad.Complete();
// now the NFA nodes are all in tiebreak order by lowest index
if (LtmTrace) {
Dump();
}
start = new LexerState(pad);
start.Add(0);
pad.Close(start);
nil = new LexerState(pad);
pad.dfashare[nil] = nil;
pad.dfashare[start] = start;
}
示例2: ToNFA
public override void ToNFA(NFA pad, int from, int to)
{
int knot = pad.AddNode();
pad.nodes_l[knot].final = true;
pad.AddEdge(from, knot, null);
}
示例3: ToNFA
public override bool ToNFA(NFA pad, int from, int to)
{
int knot = pad.AddNode();
pad.SetFinal(knot);
pad.AddEdge(from, knot, null);
return false;
}
示例4: ToNFA
public override void ToNFA(NFA pad, int from, int to)
{
int knot = pad.AddNode();
pad.AddEdge(from, knot, null);
pad.AddEdge(knot, to, null);
child.ToNFA(pad, knot, knot);
}