/** * Returns a list of symbols that corresponds to all the symbols * that tag transitions of the given list. */ symbol_t* symbols_from_transs(Transition* list) { symbol_t res; symbol_t* tmp; res.next=NULL; symbol_t* end=&res; while (list!=NULL) { tmp=list->label; concat_symbols(end,dup_symbols(tmp),&end); list=list->next; } return res.next; }
/** * This function returns a symbol list that matches * everything but the symbols matched by the given * transition list, or NULL if the transition list * matches everything. */ symbol_t* LEXIC_minus_transitions(language_t* language,Transition* trans) { #ifdef NO_C99_VARIABLE_LENGTH_ARRAY symbol_t** POS=(symbol_t**)malloc(sizeof(symbol_t*)*(language->POSs->size)); #else symbol_t* POS[language->POSs->size]; #endif int i; /* First we build an array containing a full symbol for each POS. * For instance, we could have POS[0]=<A>, POS[1]=<V>, etc. */ for (i=0;i<language->POSs->size;i++) { POS[i]=new_symbol_POS((POS_t*)language->POSs->value[i],-1); } symbol_t* tmp; while (trans!=NULL) { tmp=(symbol_t*)trans->label; if (tmp->type==S_LEXIC) { /* If a transition matches everything, then we can stop * and return NULL */ for (i=0;i<language->POSs->size;i++) { free_symbols(POS[i]); } #ifdef NO_C99_VARIABLE_LENGTH_ARRAY free(POS); #endif return NULL; } /* If we have a transition tagged by <A:s>, we have to replace * the POS array cell #z that corresponds to <A> by POS[z]-<A:s>, * that may give something like POS[z]=<A:p> */ symbol_t* minus=symbols_minus_symbol(language,POS[tmp->POS->index],tmp); free_symbols(POS[tmp->POS->index]); POS[tmp->POS->index]=minus; trans=trans->next; } /* Finally, we concatenate all the symbols we have computed into * one symbol list */ symbol_t res; res.next=NULL; symbol_t* end=&res; for (i=0;i<language->POSs->size;i++) { concat_symbols(end,POS[i],NULL); } #ifdef NO_C99_VARIABLE_LENGTH_ARRAY free(POS); #endif return res.next; }