void addtrans(Graph *col, char *from, Node *op, char *to) { State *b; Transition *t; t = (Transition *) tl_emalloc(sizeof(Transition)); t->name = tl_lookup(to); t->cond = Prune(dupnode(op)); if (tl_verbose) { printf("\n%s <<\t", from); dump(op); printf("\n\t"); dump(t->cond); printf(">> %s\n", t->name->name); } if (t->cond) t->cond = rewrite(t->cond); for (b = never; b; b = b->nxt) if (!strcmp(b->name->name, from)) { t->nxt = b->trans; b->trans = t; return; } b = (State *) tl_emalloc(sizeof(State)); b->name = tl_lookup(from); b->colors = col; b->trans = t; if (!strncmp(from, "accept", 6)) b->accepting = 1; b->nxt = never; never = b; }
static void Addout(char *to, char *from) { Graph *p = findgraph(from); Symbol *s; if (!p) return; s = getsym(tl_lookup(to)); s->next = p->outgoing; p->outgoing = s; }
Symbol * DoDump(Node *n) { if (!n) return ZS; if (n->ntyp == PREDICATE) return n->sym; dumpbuf[0] = '\0'; sdump(n); return tl_lookup(dumpbuf); }
static void ng(Symbol *s, Symbol *in, Node *isnew, Node *isold, Node *next) { Graph *g = (Graph *) tl_emalloc(sizeof(Graph)); if (s) g->name = s; else g->name = tl_lookup(newname()); if (in) g->incoming = dupSlist(in); if (isnew) g->New = flatten(isnew); if (isold) g->Old = Duplicate(isold); if (next) g->Next = flatten(next); push_stack(g); }
void retarget(char *from, char *to) { State *b; Transition *t; Symbol *To = tl_lookup(to); if (tl_verbose) printf("replace %s with %s\n", from, to); for (b = never; b; b = b->nxt) { if (!strcmp(b->name->name, from)) b->redundant = 1; else for (t = b->trans; t; t = t->nxt) { if (!strcmp(t->name->name, from)) t->name = To; } } }
tl_Symbol * DoDump(tl_Node *n) { if (!n) { return ZS; } if (n->ntyp == PREDICATE) { return n->sym; } dumpbuf[0] = '\0'; sdump(n); return tl_lookup(dumpbuf); }
static void fixinit(Node *orig) { Graph *p1, *g; Symbol *q1, *q2 = ZS; ng(tl_lookup("init"), ZS, ZN, ZN, ZN); p1 = pop_stack(); p1->nxt = Nodes_Set; p1->Other = p1->Old = orig; Nodes_Set = p1; for (g = Nodes_Set; g; g = g->nxt) { for (q1 = g->incoming; q1; q1 = q2) { q2 = q1->next; Addout(g->name->name, q1->name); tfree((void *) q1); } g->incoming = ZS; } }
void trans(Node *p) { Node *op; Graph *g; if (!p || tl_errs) return; p = twocases(p); if (tl_verbose || tl_terse) { fprintf(tl_out, "\t/* Normlzd: "); dump(p); fprintf(tl_out, " */\n"); } if (tl_terse) return; op = dupnode(p); ng(ZS, getsym(tl_lookup("init")), p, ZN, ZN); while ((g = Nodes_Stack) != (Graph *) 0) { Nodes_Stack = g->nxt; expand_g(g); } if (newstates) return; fixinit(p); liveness(flatten(op)); /* was: liveness(op); */ mkbuchi(); if (tl_verbose) { printf("/*\n"); printf(" * %d states in Streett automaton\n", Base); printf(" * %d Streett acceptance conditions\n", Max_Red); printf(" * %d Buchi states\n", Total); printf(" */\n"); } }
static int tl_lex(int *cnt, size_t hasuform, char *uform, Miscellaneous *miscell, int *tl_yychar) { int c,ii; do { c = tl_Getchar(cnt, hasuform, uform); miscell->yytext[0] = (char ) c; miscell->yytext[1] = '\0'; if (c <= 0) { Token(';'); } } while (c == ' '); /* '\t' is removed in tl_main.c */ /* get the truth constants true and false and predicates */ if (islower(c)) { getword(c, isalnum_,cnt, hasuform, uform, miscell); if (strcmp("true", miscell->yytext) == 0) { Token(TRUE); } if (strcmp("false", miscell->yytext) == 0) { Token(FALSE); } miscell->tl_yylval = tl_nn(PREDICATE,ZN,ZN,miscell); miscell->type_temp = PREDICATE; miscell->tl_yylval->sym = tl_lookup(miscell->yytext, miscell); /* match predicate index*/ for(ii = 0; ii < miscell->dp_taliro_param.nPred; ii++) { if(miscell->predMap[ii].str != NULL) { if(strcmp(miscell->tl_yylval->sym->name, miscell->predMap[ii].str)==0) { if(miscell->parMap[ii].str == NULL){ miscell->pList.pindex[ii] = PRED; }else{ miscell->pList.pindex[ii] = PREDPAR; } } } } return PREDICATE; } /* get temporal operators */ if (c == '<') { c = tl_Getchar(cnt, hasuform, uform); if (c == '>') { miscell->tl_yylval = tl_nn(EVENTUALLY,ZN,ZN,miscell); miscell->type_temp = EVENTUALLY; mtl_con(cnt, hasuform, uform, miscell,tl_yychar); return EVENTUALLY; } if (c != '-') { tl_UnGetchar(cnt); tl_yyerror("expected '<>' or '<->'", cnt, uform, tl_yychar, miscell); } c = tl_Getchar(cnt, hasuform, uform); if (c == '>') { Token(EQUIV); } tl_UnGetchar(cnt); tl_yyerror("expected '<->'", cnt, uform, tl_yychar, miscell); } switch (c) { case '/' : c = follow('\\', AND, '/', cnt, hasuform, uform, tl_yychar, miscell); break; case '\\': c = follow('/', OR, '\\', cnt, hasuform, uform, tl_yychar, miscell); break; case '&' : c = follow('&', AND, '&', cnt, hasuform, uform, tl_yychar, miscell); break; case '|' : c = follow('|', OR, '|', cnt, hasuform, uform, tl_yychar, miscell); break; case '[' : c = mtl_follow(']', ALWAYS, '[', cnt, hasuform, uform, miscell, tl_yychar); break; case '-' : c = follow('>', IMPLIES, '-', cnt, hasuform, uform, tl_yychar, miscell); break; case '!' : c = NOT; break; case 'U' : miscell->type_temp = U_OPER; mtl_con(cnt, hasuform, uform, miscell,tl_yychar); c = U_OPER; break; case 'R' : miscell->type_temp = V_OPER; mtl_con(cnt, hasuform, uform, miscell,tl_yychar); c = V_OPER; break; case 'X' : miscell->type_temp = NEXT; mtl_con(cnt, hasuform, uform, miscell,tl_yychar); c = NEXT; break; case 'W' : miscell->type_temp = WEAKNEXT; mtl_con(cnt, hasuform, uform, miscell, tl_yychar); c = WEAKNEXT; break; default : break; } Token(c); }
static int tl_lex(void) { int c; do { c = tl_Getchar(); yytext_ltl2ba[0] = (char ) c; yytext_ltl2ba[1] = '\0'; if (c <= 0) { Token(';'); } } while (c == ' '); /* '\t' is removed in tl_main.c */ if (islower(c)) { getword(c, isalnum_); if (strcmp("true", yytext_ltl2ba) == 0) { Token(TRUE); } if (strcmp("false", yytext_ltl2ba) == 0) { Token(FALSE); } tl_yylval = tl_nn(PREDICATE,ZN,ZN); tl_yylval->sym = tl_lookup(yytext_ltl2ba); return PREDICATE; } if (c == '<') { c = tl_Getchar(); if (c == '>') { Token(EVENTUALLY); } if (c != '-') { tl_UnGetchar(); tl_yyerror("expected '<>' or '<->'"); } c = tl_Getchar(); if (c == '>') { Token(EQUIV); } tl_UnGetchar(); tl_yyerror("expected '<->'"); } switch (c) { case '/' : c = follow('\\', AND, '/'); break; case '\\': c = follow('/', OR, '\\'); break; case '&' : c = follow('&', AND, '&'); break; case '|' : c = follow('|', OR, '|'); break; case '[' : c = follow(']', ALWAYS, '['); break; case '-' : c = follow('>', IMPLIES, '-'); break; case '!' : c = NOT; break; case 'U' : c = U_OPER; break; case 'V' : c = V_OPER; break; #ifdef NXT case 'X' : c = NEXT; break; #endif default : break; } Token(c); }
static int tl_lex(void) { int c; do { c = tl_Getchar(); yytext[0] = (char ) c; yytext[1] = '\0'; if (c <= 0) { Token(';'); } } while (c == ' '); /* '\t' is removed in tl_main.c */ if (c == '{' || c == '(') /* new 6.0.0 */ { if (is_predicate(c)) { read_upto_closing(c); tl_yylval = tl_nn(PREDICATE,ZN,ZN); if (!tl_yylval) { fatal("unexpected error 4", (char *) 0); } tl_yylval->sym = tl_lookup(yytext); return PREDICATE; } } if (c == '}') { tl_yyerror("unexpected '}'"); } if (islower(c)) { tl_getword(c, isalnum_); if (strcmp("true", yytext) == 0) { Token(TRUE); } if (strcmp("false", yytext) == 0) { Token(FALSE); } if (strcmp("always", yytext) == 0) { Token(ALWAYS); } if (strcmp("eventually", yytext) == 0) { Token(EVENTUALLY); } if (strcmp("until", yytext) == 0) { Token(U_OPER); } #ifdef NXT if (strcmp("next", yytext) == 0) { Token(NEXT); } #endif if (strcmp("c_expr", yytext) == 0) { Token(CEXPR); } if (strcmp("not", yytext) == 0) { Token(NOT); } tl_yylval = tl_nn(PREDICATE,ZN,ZN); if (!tl_yylval) { fatal("unexpected error 5", (char *) 0); } tl_yylval->sym = tl_lookup(yytext); return PREDICATE; } if (c == '<') { c = tl_Getchar(); if (c == '>') { Token(EVENTUALLY); } if (c != '-') { tl_UnGetchar(); tl_yyerror("expected '<>' or '<->'"); } c = tl_Getchar(); if (c == '>') { Token(EQUIV); } tl_UnGetchar(); tl_yyerror("expected '<->'"); } switch (c) { case '/' : c = tl_follow('\\', AND, '/'); break; case '\\': c = tl_follow('/', OR, '\\'); break; case '&' : c = tl_follow('&', AND, '&'); break; case '|' : c = tl_follow('|', OR, '|'); break; case '[' : c = tl_follow(']', ALWAYS, '['); break; case '-' : c = tl_follow('>', IMPLIES, '-'); break; case '!' : c = NOT; break; case 'U' : c = U_OPER; break; case 'V' : c = V_OPER; break; #ifdef NXT case 'X' : c = NEXT; break; #endif default : break; } Token(c); }
static int tl_lex(void) { int c; do { c = tl_Getchar(); yytext[0] = (char ) c; yytext[1] = '\0'; if (c <= 0) { Token(';'); } } while (c == ' '); /* '\t' is removed in tl_main.c */ if (islower(c)) { getword(c, isalnum_); if (strcmp("true", yytext) == 0) { Token(TRUE); } if (strcmp("false", yytext) == 0) { Token(FALSE); } tl_yylval = tl_nn(PREDICATE,ZN,ZN); tl_yylval->sym = tl_lookup(yytext); return PREDICATE; } if (c == '<') { c = tl_Getchar(); if (c == '>') { // #ifndef TIMED // Token(EVENTUALLY); // #else c = tl_Getchar(); if (c=='_') { float* tmp=(float *) malloc(sizeof(float)*2); tmp=tl_GetIntvl(tmp); Token_t(EVENTUALLY_I,tmp); } else { tl_UnGetchar(); Token(EVENTUALLY); } // #endif } if (c != '-') { tl_UnGetchar(); // #ifdef TIMED tl_yyerror("expected '<>' or '<->' or '<>_' for -DTIMED flag"); // #else // tl_yyerror("expected '<>' or '<->' without DTIMED flag"); // #endif } c = tl_Getchar(); if (c == '>') { Token(EQUIV); } tl_UnGetchar(); tl_yyerror("expected '<->'"); } if (c == '[') { c = tl_Getchar(); if (c == ']') { // #ifndef TIMED // Token(ALWAYS); // #else c = tl_Getchar(); if (c=='_') { float* tmp=(float *)malloc(sizeof(float)*2); tmp=tl_GetIntvl(tmp); Token_t(ALWAYS_I,tmp); } else { tl_UnGetchar(); Token(ALWAYS); } // #endif }else { tl_UnGetchar(); tl_yyerror("expected '[]' or '[]_'"); } } if (c == 'U') { #ifndef TIMED Token(U_OPER); #else c = tl_Getchar(); if (c=='_') { float* tmp=malloc(sizeof(float)*2); tmp=tl_GetIntvl(tmp); Token_t(U_I,tmp); } else { tl_UnGetchar(); Token(U_OPER); } #endif } switch (c) { case '/' : c = follow('\\', AND, '/'); break; case '\\': c = follow('/', OR, '\\'); break; case '&' : c = follow('&', AND, '&'); break; case '|' : c = follow('|', OR, '|'); break; // case '[' : c = follow(']', ALWAYS, '['); break; case '-' : c = follow('>', IMPLIES, '-'); break; case '!' : c = NOT; break; // case 'U' : c = U_OPER; break; case 'V' : c = V_OPER; break; #ifdef NXT case 'X' : c = NEXT; break; #endif default : break; } Token(c); }