Пример #1
0
/* Complete inclusion check. First fast checks to eliminate simple
   cases. Eventually defaults to a complete check */
bool regexp_inclusion(regexp r1, regexp r2) {
  /* a hashtable of visited states (positions in the regexps) */
  //  unsigned char visited[8192];

  /* Fast equality check */
  if (!strcmp((char *)r1->expr,(char *)r2->expr)) {
    return TRUE;
  }		

  /* Fast disinclusion check */
  else if (regexp_fast_disinclusion(r1, r2) == 1) {
    return FALSE;
  }
 
  /* Complete inclusion check */
  else {
    bool result = FALSE;
    region temp = newregion();
    hash_table visited = make_hash_table(temp, 32, state_hash, state_eq);
    /* TODO: I'd prefer to use a worklist instead of recursion */
    result = regexp_complete_inclusion(r1, r2, 0, 0, visited);
    deleteregion(temp);
    return result;
  }

}
Пример #2
0
void deleteregion_ptr(region *r)
{
  region tmp = *r;

  *r = NULL;
  deleteregion(tmp);
}
Пример #3
0
void mr_dyck_reset()
{
  deleteregion(mr_dyckregion);
  mr_dyckregion = NULL;
  mr_all_nodes = NULL;
  mr_k_hash = NULL;
  mr_o_hash = NULL;
  mr_c_hash = NULL;
  mr_seen_indices = NULL;
  mr_s_constructor = NULL;
  mr_n_constructor = NULL;
  mr_p_constructor = NULL;
  mr_start_constructor = NULL;

#ifdef DEBUG_ERRONEOUS_EDGES
  mr_erroneous_sources = NULL;
  mr_erroneous_sink = NULL;
#endif

  state = mr_dyck_raw;
}
Пример #4
0
int main() {
    FILE *fp;
    char line[100];
    char buf[20];
    int n1, n2, i, j;
    region r;
    double t1, t2;

    nonspec_init();
    dyck_init(TRUE);

    for(i = 0; i < 200000; i++) {
        nodes[i] = NULL;
    }

    t1 = gettime();
    fp = fopen("graph.txt", "r");
    if (fp == NULL) exit(EXIT_FAILURE);
    while ((fgets(line, 100, fp)) != NULL) {
        if (j % 1000 == 0) {
            t2 = gettime();
            //printf("1000 lines in %f seconds: ", t2 - t1); fflush(stdout);
            printf("%s", line);
            fflush(stdout);
            t1 = t2;
        }
        j++;
        switch(line[0]) {
        case '\n' :
            break;
        case '(' :
            sscanf(line+1, "%d %d %d", &n1, &n2, &i);
            make_dyck_open_edge(nodes[n1],nodes[n2],i);
            break;
        case ')' :
            sscanf(line+1, "%d %d %d", &n1, &n2, &i);
            make_dyck_close_edge(nodes[n1],nodes[n2],i);
            break;
        case 's' :
            sscanf(line+1, "%d %d", &n1, &n2);
            make_dyck_subtype_edge(nodes[n1], nodes[n2]);
            break;
        case 'g' :
            sscanf(line+1, "%d", &n1);
            mark_dyck_node_global(nodes[n1]);
            break;
        case 'c' :
            sscanf(line+1, "%d", &n1);
            if (n1 >= NUMNODES) {
                printf("Aborting:  Increase NUMNODES\n");
                exit(1);
            }
            sprintf(buf, "n%d", n1);
            nodes[n1] = make_tagged_dyck_node(buf);
            break;
        case 'm' :
            sscanf(line+1, "%d %d", &n1, &n2);
            dyck_check_reaches(nodes[n1], nodes[n2]);
            break;
        case 'p' :
            sscanf(line+1, "%d %d", &n1, &n2);
            dyck_check_pn_reaches(nodes[n1], nodes[n2]);
            break;
        case 'M' :
            sscanf(line+1, "%d", &n1);
            r = newregion();
            rdyck_reaches(r, nodes[n1]);
            deleteregion(r);
            //dyck_reaches(nodes[n1]);
            break;
        case 'P' :
            sscanf(line+1, "%d", &n1);
            r = newregion();
            rdyck_pn_reaches(r, nodes[n1]);
            deleteregion(r);
            break;
        }
    }
    return EXIT_SUCCESS;
}