Beispiel #1
0
void build_current_linkage_recursive(Parse_info * pi, Parse_set *set) {
    if (set == NULL) return;
    if (set->current == NULL) return;

    issue_links_for_choice(pi, set->current);
    build_current_linkage_recursive(pi, set->current->set[0]);
    build_current_linkage_recursive(pi, set->current->set[1]);
}
Beispiel #2
0
void list_links(Parse_info * pi, Parse_set * set, int index) {
     Parse_choice *pc;
     int n;

     if (set == NULL || set->first == NULL) return;
     for (pc = set->first; pc != NULL; pc = pc->next) {
	  n = pc->set[0]->count * pc->set[1]->count;
	  if (index < n) break;
	  index -= n;
     }
     assert(pc != NULL, "walked off the end in list_links");
     issue_links_for_choice(pi, pc);
     list_links(pi, pc->set[0], index % pc->set[0]->count);
     list_links(pi, pc->set[1], index / pc->set[0]->count);
}
Beispiel #3
0
void list_random_links(Parse_info * pi, Parse_set * set) {
     Parse_choice *pc;
     int num_pc, new_index;

     if (set == NULL || set->first == NULL) return;
     num_pc = 0;
     for (pc = set->first; pc != NULL; pc = pc->next) {
	  num_pc++;
     }

     new_index = my_random() % num_pc;
     
     num_pc = 0;
     for (pc = set->first; pc != NULL; pc = pc->next) {
	  if (new_index == num_pc) break;
	  num_pc++;
     }

     assert(pc != NULL, "Couldn't get a random parse choice");
     issue_links_for_choice(pi, pc);
     list_random_links(pi, pc->set[0]);
     list_random_links(pi, pc->set[1]);
}
Beispiel #4
0
static void list_random_links(Linkage lkg, Parse_info pi, Parse_set * set)
{
    Parse_choice *pc;
    int num_pc, new_index;

    if (set == NULL || set->first == NULL) return;
    num_pc = 0;
    for (pc = set->first; pc != NULL; pc = pc->next) {
        num_pc++;
    }

    new_index = rand_r(&pi->rand_state) % num_pc;

    num_pc = 0;
    for (pc = set->first; pc != NULL; pc = pc->next) {
        if (new_index == num_pc) break;
        num_pc++;
    }

    assert(pc != NULL, "Couldn't get a random parse choice");
    issue_links_for_choice(lkg, pc);
    list_random_links(lkg, pi, pc->set[0]);
    list_random_links(lkg, pi, pc->set[1]);
}