/* *The"pre"statemusthaveonlyBOS/BOLoutarcs,elsepatternisn't *anchoredleft.IfwehavebothBOSandBOL,theymustgotothesame *nextstate.
*/
st = cnfa->pre;
nextst = -1; for (ca = cnfa->states[st]; ca->co != COLORLESS; ca++)
{ if (ca->co == cnfa->bos[0] || ca->co == cnfa->bos[1])
{ if (nextst == -1)
nextst = ca->to; elseif (nextst != ca->to) return REG_NOMATCH;
} else return REG_NOMATCH;
} if (nextst == -1) return REG_NOMATCH;
/* *Scanthroughsuccessivestates,stoppingassoonaswefindonewith *morethanoneacceptabletransitioncharacter(eithermultiplecolors *onout-arcs,oracolorwithmorethanonememberchr). * *Wecouldfindastatewithmultipleout-arcsthatarealllabeledwith *thesamesingletoncolor;thiscomesfrompatternslike"^ab(cde|cxy)". *Inthatcaseweaddthechr"c"totheoutputstringbutthenexitthe *loopwithnextst==-1.Thisleavesalittlebitonthetable:ifthe *patternislike"^ab(cde|cdy)",wewon'tnoticethat"d"couldbeadded *totheprefix.Butchasingmultipleparallelstatechainsdoesn'tseem *worththetrouble.
*/ do
{
st = nextst;
nextst = -1;
thiscolor = COLORLESS; for (ca = cnfa->states[st]; ca->co != COLORLESS; ca++)
{ /* We can ignore BOS/BOL arcs */ if (ca->co == cnfa->bos[0] || ca->co == cnfa->bos[1]) continue;
/* *...butEOS/EOLarcsterminatethesearch,asdoRAINBOWarcs *andLACONs
*/ if (ca->co == cnfa->eos[0] || ca->co == cnfa->eos[1] ||
ca->co == RAINBOW || ca->co >= cnfa->ncolors)
{
thiscolor = COLORLESS; break;
} if (thiscolor == COLORLESS)
{ /* First plain outarc */
thiscolor = ca->co;
nextst = ca->to;
} elseif (thiscolor == ca->co)
{ /* Another plain outarc for same color */
nextst = -1;
} else
{ /* More than one plain outarc color terminates the search */
thiscolor = COLORLESS; break;
}
} /* Done if we didn't find exactly one color on plain outarcs */ if (thiscolor == COLORLESS) break; /* The color must be a singleton */ if (cm->cd[thiscolor].nschrs != 1) break; /* Must not have any high-color-map entries */ if (cm->cd[thiscolor].nuchrs != 0) break;
/* *Identifythecolor'ssolememberchrandaddittotheprefix *string.Ingeneralthecolormapdatastructuredoesn'tprovidea *waytofindcolormemberchrs,exceptbytryingGETCOLOR()oneach *possiblechrvalue,whichwon'tdoatall.However,forthecases *wecareaboutitshouldbesufficienttotestthe"firstchr"value, *thatisthefirstchreveraddedtothecolor.Therearecases *wherethismightnolongerbeamemberofthecolor(sowedoneed *totest),butnoneofthemarelikelytoariseforacharacterthat *isamemberofacommonprefix.Ifwedohitsuchacornercase, *wejustfalloutwithoutaddinganythingtotheprefixstring.
*/
c = cm->cd[thiscolor].firstchr; if (GETCOLOR(cm, c) != thiscolor) break;
string[(*slength)++] = c;
/* Advance to next state, but only if we have a unique next state */
} while (nextst != -1);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.