extern OBJ _AArrayFold_Sb(OBJ f,OBJ a) /* \ */ { NAT i = 1,l = leng_array(a); OBJ r; if (l == 0){ HLT("\\'ArrayFold: array is empty"); } if (l > 1) { copy_closure(f,l-2); } else { free_closure(f,1); } if (excl_array(a,1)){ r = data_array(a)[0]; while (i < l){ OBJ t = data_array(a)[i]; r = EVAL2(f,t,r); i++; } dispose_array_flat(a); } else { r = data_array(a)[0]; copy_some(r,1); while (i < l){ OBJ t = data_array(a)[i]; copy_some(t,1); r = EVAL2(f,t,r); i++; } decr_array(a,1); } return r; }
extern OBJ _AArrayFold_Ss(OBJ f,OBJ a) /* / */ { NAT i = leng_array(a); OBJ r; if (i == 0){ HLT("/'ArrayFold: array is empty"); } if (i > 1) { copy_closure(f,i-2); } else { free_closure(f,1); } if (excl_array(a,1)){ --i; r = data_array(a)[i]; while (i > 0){ OBJ t; i--; t = data_array(a)[i]; r = EVAL2(f,t,r); } dispose_array_flat(a); } else { --i; r = data_array(a)[i]; copy_some(r,1); while (i > 0){ OBJ t; i--; t = data_array(a)[i]; copy_some(t,1); r = EVAL2(f,t,r); } decr_array(a,1); } return r; }
void print_results (void) { state_number i; /* We used to use just .out if SPEC_NAME_PREFIX (-p) was used, but that conflicts with Posix. */ FILE *out = xfopen (spec_verbose_file, "w"); reduce_output (out); grammar_rules_partial_print (out, _("Rules never reduced"), rule_never_reduced_p); conflicts_output (out); print_grammar (out); /* If the whole state item sets, not only the kernels, are wanted, `closure' will be run, which needs memory allocation/deallocation. */ if (report_flag & report_itemsets) new_closure (nritems); /* Storage for print_reductions. */ shift_set = bitset_create (ntokens, BITSET_FIXED); look_ahead_set = bitset_create (ntokens, BITSET_FIXED); for (i = 0; i < nstates; i++) print_state (out, states[i]); bitset_free (shift_set); bitset_free (look_ahead_set); if (report_flag & report_itemsets) free_closure (); xfclose (out); }
static int alien_callback_gc(lua_State *L) { ffi_closure *ud = alien_checkcallback(L, 1); alien_Callback *ac = (alien_Callback *)ud->user_data; lua_unref(ac->L, ac->fn_ref); if(ac->params) free(ac->params); if(ac->ffi_params) free(ac->ffi_params); free_closure(ud); return 0; }
void print_xml (void) { int level = 0; FILE *out = xfopen (spec_xml_file, "w"); fputs ("<?xml version=\"1.0\"?>\n\n", out); xml_printf (out, level, "<bison-xml-report version=\"%s\" bug-report=\"%s\"" " url=\"%s\">", xml_escape_n (0, VERSION), xml_escape_n (1, PACKAGE_BUGREPORT), xml_escape_n (2, PACKAGE_URL)); fputc ('\n', out); xml_printf (out, level + 1, "<filename>%s</filename>", xml_escape (grammar_file)); /* print grammar */ print_grammar (out, level + 1); new_closure (nritems); no_reduce_set = bitset_create (ntokens, BITSET_FIXED); /* print automaton */ fputc ('\n', out); xml_puts (out, level + 1, "<automaton>"); { state_number i; for (i = 0; i < nstates; i++) print_state (out, level + 2, states[i]); } xml_puts (out, level + 1, "</automaton>"); bitset_free (no_reduce_set); free_closure (); xml_puts (out, 0, "</bison-xml-report>"); { int i; for (i = 0; i < num_escape_bufs; ++i) free (escape_bufs[i].ptr); } xfclose (out); }
int free_config( Config_set **free_start ) { Config_set *ptr; ptr = *free_start; while ( *free_start != NULL ) { ptr = *free_start; // free closure set //if( ptr->set_next != NULL ) free_closure( &(ptr->set_next) ); *free_start = (*free_start)->next; free(ptr); } }
void generate_states (void) { item_number initial_core = 0; state_list *list = NULL; allocate_storage (); new_closure (nritems); /* Create the initial state. The 0 at the lhs is the index of the item of this initial rule. */ state_list_append (0, 1, &initial_core); /* States are queued when they are created; process them all. */ for (list = first_state; list; list = list->next) { state *s = list->state; if (trace_flag & trace_automaton) fprintf (stderr, "Processing state %d (reached by %s)\n", s->number, symbols[s->accessing_symbol]->tag); /* Set up itemset for the transitions out of this state. itemset gets a vector of all the items that could be accepted next. */ closure (s->items, s->nitems); /* Record the reductions allowed out of this state. */ save_reductions (s); /* Find the itemsets of the states that shifts can reach. */ new_itemsets (s); /* Find or create the core structures for those states. */ append_states (s); /* Create the shifts structures for the shifts to those states, now that the state numbers transitioning to are known. */ state_transitions_set (s, nshifts, shiftset); } /* discard various storage */ free_closure (); free_storage (); /* Set up STATES. */ set_states (); }