void scextend(void) { current_max_scs += MAX_SCS_INCREMENT; ++num_reallocs; scset = reallocate_integer_array( scset, current_max_scs ); scbol = reallocate_integer_array( scbol, current_max_scs ); scxclu = reallocate_integer_array( scxclu, current_max_scs ); sceof = reallocate_integer_array( sceof, current_max_scs ); scname = reallocate_char_ptr_array( scname, current_max_scs ); }
int mkstate(int sym) { if ( ++lastnfa >= current_mns ) { if ( (current_mns += MNS_INCREMENT) >= MAXIMUM_MNS ) lerrif( "input rules are too complicated (>= %d NFA states)", current_mns ); ++num_reallocs; firstst = reallocate_integer_array( firstst, current_mns ); lastst = reallocate_integer_array( lastst, current_mns ); finalst = reallocate_integer_array( finalst, current_mns ); transchar = reallocate_integer_array( transchar, current_mns ); trans1 = reallocate_integer_array( trans1, current_mns ); trans2 = reallocate_integer_array( trans2, current_mns ); accptnum = reallocate_integer_array( accptnum, current_mns ); assoc_rule = reallocate_integer_array( assoc_rule, current_mns ); state_type = reallocate_integer_array( state_type, current_mns ); } firstst[lastnfa] = lastnfa; finalst[lastnfa] = lastnfa; lastst[lastnfa] = lastnfa; transchar[lastnfa] = sym; trans1[lastnfa] = NO_TRANSITION; trans2[lastnfa] = NO_TRANSITION; accptnum[lastnfa] = NIL; assoc_rule[lastnfa] = num_rules; state_type[lastnfa] = current_state_type; /* fix up equivalence classes base on this transition. Note that any * character which has its own transition gets its own equivalence class. * Thus only characters which are only in character classes have a chance * at being in the same equivalence class. E.g. "a|b" puts 'a' and 'b' * into two different equivalence classes. "[ab]" puts them in the same * equivalence class (barring other differences elsewhere in the input). */ if ( sym < 0 ) { /* we don't have to update the equivalence classes since that was * already done when the ccl was created for the first time */ } else if ( sym == SYM_EPSILON ) ++numeps; else { if ( useecs ) /* map NUL's to csize */ mkechar( sym ? sym : csize, nextecm, ecgroup ); } return ( lastnfa ); }
void expand_nxt_chk (void) { int old_max = current_max_xpairs; current_max_xpairs += MAX_XPAIRS_INCREMENT; ++num_reallocs; nxt = reallocate_integer_array (nxt, current_max_xpairs); chk = reallocate_integer_array (chk, current_max_xpairs); memset(chk + old_max, 0, MAX_XPAIRS_INCREMENT * sizeof(int)); }
/* expand_nxt_chk - expand the next check arrays */ void expand_nxt_chk(void) { int old_max = current_max_xpairs; current_max_xpairs += MAX_XPAIRS_INCREMENT; ++num_reallocs; nxt = reallocate_integer_array(nxt, current_max_xpairs); chk = reallocate_integer_array(chk, current_max_xpairs); zero_out((char *) (chk + old_max), (size_t) (MAX_XPAIRS_INCREMENT * sizeof(int))); }
void new_rule(void) { if ( ++num_rules >= current_max_rules ) { ++num_reallocs; current_max_rules += MAX_RULES_INCREMENT; rule_type = reallocate_integer_array( rule_type, current_max_rules ); rule_linenum = reallocate_integer_array( rule_linenum, current_max_rules ); } if ( num_rules > MAX_RULE ) lerrif( "too many rules (> %d)!", MAX_RULE ); rule_linenum[num_rules] = linenum; }
/* mktemplate - create a template entry based on a state, and connect the state * to it */ void mktemplate(int state[], int statenum, int comstate) { int i, numdiff, tmpbase, tmp[CSIZE + 1]; CCLTBL transset[CSIZE + 1]; int tsptr; ++numtemps; tsptr = 0; /* Calculate where we will temporarily store the transition table * of the template in the tnxt[] array. The final transition table * gets created by cmptmps(). */ tmpbase = numtemps * numecs; if (tmpbase + numecs >= current_max_template_xpairs) { current_max_template_xpairs += MAX_TEMPLATE_XPAIRS_INCREMENT; ++num_reallocs; tnxt = reallocate_integer_array(tnxt, current_max_template_xpairs); } for (i = 1; i <= numecs; ++i) { if (state[i] == 0) { tnxt[tmpbase + i] = 0; } else { transset[tsptr++].ch = (Char) i; transset[tsptr].why = cCnone; tnxt[tmpbase + i] = comstate; } } if (usemecs) mkeccl(transset, tsptr, tecfwd, tecbck, numecs, 0); mkprot(tnxt + tmpbase, -numtemps, comstate); /* We rely on the fact that mkprot adds things to the beginning * of the proto queue. */ numdiff = tbldiff(state, firstprot, tmp); mkentry(tmp, numecs, statenum, -numtemps, numdiff); }
int cclinit (void) { if (++lastccl >= current_maxccls) { current_maxccls += MAX_CCLS_INCREMENT; ++num_reallocs; cclmap = reallocate_integer_array (cclmap, current_maxccls); ccllen = reallocate_integer_array (ccllen, current_maxccls); cclng = reallocate_integer_array (cclng, current_maxccls); ccl_has_nl = reallocate_bool_array (ccl_has_nl, current_maxccls); } if (lastccl == 1) /* we're making the first ccl */ cclmap[lastccl] = 0; else /* The new pointer is just past the end of the last ccl. * Since the cclmap points to the \first/ character of a * ccl, adding the length of the ccl to the cclmap pointer * will produce a cursor to the first free space. */ cclmap[lastccl] = cclmap[lastccl - 1] + ccllen[lastccl - 1]; ccllen[lastccl] = 0; cclng[lastccl] = 0; /* ccl's start out life un-negated */ ccl_has_nl[lastccl] = false; return lastccl; }
void increase_max_dfas (void) { current_max_dfas += MAX_DFAS_INCREMENT; ++num_reallocs; base = reallocate_integer_array (base, current_max_dfas); def = reallocate_integer_array (def, current_max_dfas); dfasiz = reallocate_integer_array (dfasiz, current_max_dfas); accsiz = reallocate_integer_array (accsiz, current_max_dfas); dhash = reallocate_integer_array (dhash, current_max_dfas); dss = reallocate_int_ptr_array (dss, current_max_dfas); dfaacc = reallocate_dfaacc_union (dfaacc, current_max_dfas); if (nultrans) nultrans = reallocate_integer_array (nultrans, current_max_dfas); }