Lines Matching full:state
245 xmlRegStatePtr state;
288 xmlRegStatePtr state;/* the current state */
290 int nextbranch; /* the next transition to explore in that state */
291 int *counts; /* save the automata state if it has some */
309 xmlRegStatePtr state;/* the current state */
310 int transno; /* the current transition on that state */
321 * The state of the automata if any
338 int errStateNo; /* the error state number */
339 xmlRegStatePtr errState; /* the error state */
341 int *errCounts; /* counters at the error state */
349 static void xmlRegFreeState(xmlRegStatePtr state);
460 * 3/ build a table state x atom for the transitions
545 * state corresponds to the state type.
551 xmlRegStatePtr state;
557 state = ret->states[i];
559 transitions[stateno * (nbatoms + 1)] = state->type;
561 for (j = 0;j < state->nbTrans;j++) {
562 trans = &(state->trans[j]);
588 printf("Indet: state %d trans %d, atom %d to %d : %d to %d\n",
604 printf("State %d trans %d: atom %d to %d : %d to %d\n",
870 xmlRegexpErrMemory(ctxt, "allocating state");
881 * @state: the regexp state
883 * Free a regexp state
886 xmlRegFreeState(xmlRegStatePtr state) {
887 if (state == NULL)
890 if (state->trans != NULL)
891 xmlFree(state->trans);
892 if (state->transTo != NULL)
893 xmlFree(state->transTo);
894 xmlFree(state);
1138 xmlRegPrintState(FILE *output, xmlRegStatePtr state) {
1141 fprintf(output, " state: ");
1142 if (state == NULL) {
1146 if (state->type == XML_REGEXP_START_STATE)
1148 if (state->type == XML_REGEXP_FINAL_STATE)
1151 fprintf(output, "%d, %d transitions:\n", state->no, state->nbTrans);
1152 for (i = 0;i < state->nbTrans; i++) {
1153 xmlRegPrintTrans(output, &(state->trans[i]));
1337 xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
1343 if (state == NULL) {
1344 ERROR("add state: state is NULL");
1348 ERROR("add state: target is NULL");
1357 for (nrtrans = state->nbTrans - 1; nrtrans >= 0; nrtrans--) {
1358 xmlRegTransPtr trans = &(state->trans[nrtrans]);
1365 state->no, target->no);
1371 if (state->maxTrans == 0) {
1372 state->maxTrans = 8;
1373 state->trans = (xmlRegTrans *) xmlMalloc(state->maxTrans *
1375 if (state->trans == NULL) {
1377 state->maxTrans = 0;
1380 } else if (state->nbTrans >= state->maxTrans) {
1382 state->maxTrans *= 2;
1383 tmp = (xmlRegTrans *) xmlRealloc(state->trans, state->maxTrans *
1387 state->maxTrans /= 2;
1390 state->trans = tmp;
1393 printf("Add trans from %d to %d ", state->no, target->no);
1406 state->trans[state->nbTrans].atom = atom;
1407 state->trans[state->nbTrans].to = target->no;
1408 state->trans[state->nbTrans].counter = counter;
1409 state->trans[state->nbTrans].count = count;
1410 state->trans[state->nbTrans].nd = 0;
1411 state->nbTrans++;
1412 xmlRegStateAddTransTo(ctxt, target, state->no);
1416 xmlRegStatePush(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state) {
1417 if (state == NULL) return(-1);
1423 xmlRegexpErrMemory(ctxt, "adding state");
1433 xmlRegexpErrMemory(ctxt, "adding state");
1439 state->no = ctxt->nbStates;
1440 ctxt->states[ctxt->nbStates++] = state;
1447 * @from: the from state
1448 * @to: the target state or NULL for building a new one
1459 ctxt->state = to;
1470 * @from: the from state
1471 * @to: the target state or NULL for building a new one
1480 ctxt->state = to;
1488 * @from: the from state
1489 * @to: the target state or NULL for building a new one
1499 ctxt->state = to;
1507 * @from: the from state
1508 * @to: the target state or NULL for building a new one
1518 ctxt->state = to;
1526 * @from: the from state
1527 * @to: the target state or NULL for building a new one
1560 ctxt->state = to;
1568 * transition done to the state after end of atom.
1569 * 1. set transition from atom start to new state
1570 * 2. set transition from atom end to this state.
1573 xmlFAGenerateEpsilonTransition(ctxt, atom->stop, ctxt->state);
1589 * create the final state now if needed
1625 inter = ctxt->state;
1662 ctxt->state = newstate;
1683 ctxt->state = to;
1699 * Do not pollute the target state by adding transitions from
1718 ctxt->state = end;
1749 * @fromnr: the from state
1750 * @tonr: the to state
1777 printf("State %d is final, so %d becomes final\n", tonr, fromnr);
1836 * reduced to state elimination:
1840 * If X is the start state then make Y the start state, else replace the
1846 xmlRegStatePtr state, tmp;
1849 state = ctxt->states[statenr];
1850 if (state == NULL)
1852 if (state->nbTrans != 1)
1854 if (state->type == XML_REGEXP_UNREACH_STATE)
1857 if ((state->trans[0].atom == NULL) &&
1858 (state->trans[0].to >= 0) &&
1859 (state->trans[0].to != statenr) &&
1860 (state->trans[0].counter < 0) &&
1861 (state->trans[0].count < 0)) {
1862 newto = state->trans[0].to;
1864 if (state->type == XML_REGEXP_START_STATE) {
1874 for (i = 0;i < state->nbTransTo;i++) {
1875 tmp = ctxt->states[state->transTo[i]];
1890 if (state->type == XML_REGEXP_FINAL_STATE)
1893 state->nbTrans = 0;
1895 state->type = XML_REGEXP_UNREACH_STATE;
1910 xmlRegStatePtr state;
1921 state = ctxt->states[statenr];
1922 if ((state != NULL) && (state->type == XML_REGEXP_UNREACH_STATE)) {
1924 printf("Removed unreachable state %d\n", statenr);
1926 xmlRegFreeState(state);
1942 state = ctxt->states[statenr];
1943 if (state == NULL)
1945 if ((state->nbTrans == 0) &&
1946 (state->type != XML_REGEXP_FINAL_STATE)) {
1947 state->type = XML_REGEXP_SINK_STATE;
1949 for (transnr = 0;transnr < state->nbTrans;transnr++) {
1950 if ((state->trans[transnr].atom == NULL) &&
1951 (state->trans[transnr].to >= 0)) {
1952 if (state->trans[transnr].to == statenr) {
1953 state->trans[transnr].to = -1;
1958 } else if (state->trans[transnr].count < 0) {
1959 int newto = state->trans[transnr].to;
1966 state->trans[transnr].to = -2;
1967 state->mark = XML_REGEXP_MARK_START;
1969 newto, state->trans[transnr].counter);
1970 state->mark = XML_REGEXP_MARK_NORMAL;
1985 state = ctxt->states[statenr];
1986 if (state == NULL)
1988 for (transnr = 0;transnr < state->nbTrans;transnr++) {
1989 xmlRegTransPtr trans = &(state->trans[transnr]);
2003 state = ctxt->states[statenr];
2004 if (state != NULL)
2005 state->reached = XML_REGEXP_MARK_NORMAL;
2007 state = ctxt->states[0];
2008 if (state != NULL)
2009 state->reached = XML_REGEXP_MARK_START;
2010 while (state != NULL) {
2012 state->reached = XML_REGEXP_MARK_VISITED;
2014 * Mark all states reachable from the current reachable state
2016 for (transnr = 0;transnr < state->nbTrans;transnr++) {
2017 if ((state->trans[transnr].to >= 0) &&
2018 ((state->trans[transnr].atom != NULL) ||
2019 (state->trans[transnr].count >= 0))) {
2020 int newto = state->trans[transnr].to;
2032 * find the next accessible state not explored
2036 state = ctxt->states[statenr];
2037 if ((state != NULL) && (state->reached ==
2039 target = state;
2044 state = target;
2047 state = ctxt->states[statenr];
2048 if ((state != NULL) && (state->reached == XML_REGEXP_MARK_NORMAL)) {
2050 printf("Removed unreachable state %d\n", statenr);
2052 xmlRegFreeState(state);
2125 * memory too, so let's force the automata to save state
2558 xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
2565 if (state == NULL)
2571 nbTrans = state->nbTrans;
2573 t1 = &(state->trans[transnr]);
2610 xmlRegStatePtr state;
2626 state = ctxt->states[statenr];
2627 if (state == NULL)
2629 if (state->nbTrans < 2)
2631 for (transnr = 0;transnr < state->nbTrans;transnr++) {
2632 t1 = &(state->trans[transnr]);
2644 t2 = &(state->trans[i]);
2662 state = ctxt->states[statenr];
2663 if (state == NULL)
2665 if (state->nbTrans < 2)
2668 for (transnr = 0;transnr < state->nbTrans;transnr++) {
2669 t1 = &(state->trans[transnr]);
2680 t2 = &(state->trans[i]);
2719 * from a state since there is no need to set-up rollback
3017 * Saving and restoring state of an execution context *
3024 printf("state: %d:%d:idx %d", exec->state->no, exec->transno, exec->index);
3080 exec->rollbacks[exec->nbRollbacks].state = exec->state;
3109 exec->state = exec->rollbacks[exec->nbRollbacks].state;
3149 exec->state = comp->states[0];
3165 ((exec->state != NULL) &&
3166 (exec->state->type != XML_REGEXP_FINAL_STATE)))) {
3171 * If end of input on non-terminal state, rollback, however we may
3183 if (exec->transno < exec->state->nbTrans) {
3184 trans = &exec->state->trans[exec->transno];
3195 for (;exec->transno < exec->state->nbTrans;exec->transno++) {
3196 trans = &exec->state->trans[exec->transno];
3258 if (exec->state->nbTrans > exec->transno + 1) {
3279 xmlRegStatePtr state = exec->state;
3285 exec->state = to;
3288 exec->state = state;
3336 (exec->state->nbTrans > exec->transno + 1))) {
3378 printf("entering state %d\n", trans->to);
3380 exec->state = comp->states[trans->to];
3391 if ((exec->transno != 0) || (exec->state->nbTrans == 0)) {
3398 printf("rollback from state %d on %d:%c\n", exec->state->no,
3472 exec->state = comp->states[0];
3635 * Returns: 1 if the regexp reached a final state, 0 if non-final, and
3643 int state = exec->index;
3651 * are we at a final state ?
3653 if (comp->compact[state * (comp->nbstrings + 1)] ==
3664 * Examine all outside transitions from current state
3667 target = comp->compact[state * (comp->nbstrings + 1) + i + 1];
3674 comp->transdata[state * comp->nbstrings + i], data);
3677 printf("entering state %d\n", target);
3691 * Failed to find an exit transition out from current state for the
3695 printf("failed to find a transition for %s on state %d\n", value, state);
3701 exec->errStateNo = state;
3718 * Returns: 1 if the regexp reached a final state, 0 if non-final, and
3741 if (exec->state->type == XML_REGEXP_FINAL_STATE)
3765 (exec->state->type != XML_REGEXP_FINAL_STATE)))) {
3768 * End of input on non-terminal state, rollback, however we may
3776 for (;exec->transno < exec->state->nbTrans;exec->transno++) {
3777 trans = &exec->state->trans[exec->transno];
3794 * Check all counted transitions from the current state
3799 for (i = 0;i < exec->state->nbTrans;i++) {
3800 t = &exec->state->trans[i];
3832 * Check all counted transitions from the current state
3834 for (i = 0;i < exec->state->nbTrans;i++) {
3835 t = &exec->state->trans[i];
3887 if (exec->state->nbTrans > exec->transno + 1) {
3917 xmlRegStatePtr state = exec->state;
3923 exec->state = to;
3929 exec->state = state;
3954 if (exec->state->nbTrans > exec->transno + 1) {
3975 printf("entering state %d\n", trans->to);
3981 * entering a sink state, save the current state as error
3982 * state.
3987 exec->errState = exec->state;
3991 exec->state = exec->comp->states[trans->to];
4023 if ((exec->transno != 0) || (exec->state->nbTrans == 0)) {
4027 * store the current state as the error state.
4029 if ((progress) && (exec->state != NULL) &&
4030 (exec->state->type != XML_REGEXP_SINK_STATE)) {
4035 exec->errState = exec->state;
4059 return(exec->state->type == XML_REGEXP_FINAL_STATE);
4077 * Returns: 1 if the regexp reached a final state, 0 if non-final, and
4095 state, 0 if non-final, and
4149 * @terminal: return value if this was a terminal state
4172 int target, i, state;
4178 state = exec->errStateNo;
4180 state = exec->index;
4183 if (comp->compact[state * (comp->nbstrings + 1)] ==
4190 target = comp->compact[state * (comp->nbstrings + 1) + i + 1];
4199 target = comp->compact[state * (comp->nbstrings + 1) + i + 1];
4211 xmlRegStatePtr state;
4214 if (exec->state->type == XML_REGEXP_FINAL_STATE)
4222 state = exec->errState;
4224 if (exec->state == NULL) return(-1);
4225 state = exec->state;
4228 (transno < state->nbTrans) && (nb < maxval);
4230 trans = &state->trans[transno];
4272 (transno < state->nbTrans) && (nb < maxval);
4274 trans = &state->trans[transno];
4308 * @terminal: return value if this was a terminal state
4313 * state and the @values array will be updated with them. The string values
4332 * @terminal: return value if this was a terminal state
4338 * state and the @values array will be updated with them. The string values
4384 (exec->state->type != XML_REGEXP_FINAL_STATE))) {
4387 * End of input on non-terminal state, rollback, however we may
4395 for (;exec->transno < exec->state->nbTrans;exec->transno++) {
4396 trans = &exec->state->trans[exec->transno];
4429 if (exec->state->nbTrans > exec->transno + 1) {
4450 xmlRegStatePtr state = exec->state;
4456 exec->state = to;
4459 exec->state = state;
4481 if (exec->state->nbTrans > exec->transno + 1) {
4500 printf("entering state %d\n", trans->to);
4502 exec->state = exec->comp->states[trans->to];
4513 if ((exec->transno != 0) || (exec->state->nbTrans == 0)) {
5209 xmlFAGenerateEpsilonTransition(ctxt, ctxt->state, NULL);
5210 start0 = ctxt->state;
5211 xmlFAGenerateEpsilonTransition(ctxt, ctxt->state, NULL);
5212 start = ctxt->state;
5227 ctxt->atom->stop = ctxt->state;
5273 previous = ctxt->state;
5279 previous = ctxt->state;
5288 previous = ctxt->state;
5307 start = ctxt->state;
5312 printf("State %d is final\n", ctxt->state->no);
5314 ctxt->state->type = XML_REGEXP_FINAL_STATE;
5317 ctxt->end = ctxt->state;
5320 end = ctxt->state;
5323 ctxt->state = start;
5328 ctxt->state = end;
5397 ctxt->start = ctxt->state = xmlRegNewState(ctxt);
5409 ctxt->end = ctxt->state;
5543 ctxt->start = ctxt->state = xmlRegNewState(ctxt);
5575 * Initial state lookup
5577 * Returns the initial state of the automata
5589 * @state: a state in this automata
5591 * Makes that state a final state
5596 xmlAutomataSetFinalState(xmlAutomataPtr am, xmlAutomataStatePtr state) {
5597 if ((am == NULL) || (state == NULL))
5599 state->type = XML_REGEXP_FINAL_STATE;
5611 * If @to is NULL, this creates first a new target state in the automata
5612 * and then adds a transition from the @from state to the target state
5615 * Returns the target state or NULL in case of error
5638 return(am->state);
5651 * If @to is NULL, this creates first a new target state in the automata
5652 * and then adds a transition from the @from state to the target state
5655 * Returns the target state or NULL in case of error
5696 return(am->state);
5709 * If @to is NULL, this creates first a new target state in the automata
5710 * and then adds a transition from the @from state to the target state
5715 * Returns the target state or NULL in case of error
5762 return(am->state);
5777 * If @to is NULL, this creates first a new target state in the automata
5778 * and then adds a transition from the @from state to the target state
5782 * Returns the target state or NULL in case of error
5843 am->state = to;
5846 to = am->state;
5864 * If @to is NULL, this creates first a new target state in the automata
5865 * and then adds a transition from the @from state to the target state
5869 * Returns the target state or NULL in case of error
5909 am->state = to;
5912 to = am->state;
5931 * If @to is NULL, this creates first a new target state in the automata
5932 * and then adds a transition from the @from state to the target state
5937 * Returns the target state or NULL in case of error
5995 am->state = to;
6011 * If @to is NULL, this creates first a new target state in the automata
6012 * and then adds a transition from the @from state to the target state
6017 * Returns the target state or NULL in case of error
6054 am->state = to;
6062 * Create a new disconnected state in the automata
6064 * Returns the new state or NULL in case of error
6083 * If @to is NULL, this creates first a new target state in the automata
6084 * and then adds an epsilon transition from the @from state to the
6085 * target state
6087 * Returns the target state or NULL in case of error
6096 return(am->state);
6107 * If @to is NULL, this creates first a new target state in the automata
6108 * and then adds a an ALL transition from the @from state to the
6109 * target state. That transition is an epsilon transition allowed only when
6112 * Returns the target state or NULL in case of error
6121 return(am->state);
6157 * If @to is NULL, this creates first a new target state in the automata
6158 * and then adds an epsilon transition from the @from state to the target state
6161 * Returns the target state or NULL in case of error
6170 return(am->state);
6181 * If @to is NULL, this creates first a new target state in the automata
6182 * and then adds an epsilon transition from the @from state to the target state
6185 * Returns the target state or NULL in case of error
6194 return(am->state);