本文整理汇总了C#中NFA.Close方法的典型用法代码示例。如果您正苦于以下问题:C# NFA.Close方法的具体用法?C# NFA.Close怎么用?C# NFA.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NFA
的用法示例。
在下文中一共展示了NFA.Close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Next
public LexerState Next(NFA nf, int ch)
{
LexerState l;
if (dfc.TryGetValue(ch, out l))
return l;
l = new LexerState(nf);
for (int i = 0; i < nstates.Length; i++) {
int bm = nstates[i];
for (int j = 0; j < 32; j++) {
if ((bm & (1 << j)) == 0)
continue;
foreach (NFA.Edge e in nf.nodes[32*i + j].edges) {
if (e.when != null && e.when.Accepts(ch))
l.Add(e.to);
}
}
}
nf.Close(l);
LexerState cl;
if (!nf.dfashare.TryGetValue(l, out cl)) {
nf.dfashare[l] = cl = l;
}
dfc[ch] = cl;
return cl;
}
示例3: Next
public LexerState Next(NFA nf, int ch)
{
LexerState l;
if (dfc.TryGetValue(ch, out l))
return l;
l = new LexerState(nf);
for (int i = 0; i < nstates.Length; i++) {
int bm = nstates[i];
for (int j = 0; j < 32; j++) {
if ((bm & (1 << j)) == 0)
continue;
int ei = 0, eimax = 0;
var es = nf.EdgesOf(32*i + j, ref ei, ref eimax);
while (ei != eimax) {
var e = es[ei++];
if (e.when == ch || e.when == -1 && e.when_cc.Accepts(ch))
l.Add(e.to);
}
}
}
nf.Close(l);
LexerState cl;
if (!nf.dfashare.TryGetValue(l, out cl)) {
nf.dfashare[l] = cl = l;
}
dfc[ch] = cl;
return cl;
}