static Node * tl_level(int nr) { int i; Node *ptr = ZN; if (nr < 0) return tl_factor(); ptr = tl_level(nr-1); again: for (i = 0; i < 4; i++) if (tl_yychar == prec[nr][i]) { tl_yychar = tl_yylex(); ptr = tl_nn(prec[nr][i], ptr, tl_level(nr-1)); ptr = bin_simpler(ptr); goto again; } if (!ptr) tl_yyerror("syntax error"); #if 0 printf("level %d: ", nr); tl_explain(ptr->ntyp); printf("\n"); #endif return ptr; }
static Node *tl_level(int nr) { int i; Node *ptr = ZN; Interval LocInter; if (nr < 0) return tl_factor(); ptr = tl_level(nr-1); again: for (i = 0; i < 4; i++) if (tl_yychar == prec[nr][i]) { if (nr==0 && (i==0 || i==1)) LocInter = TimeCon; tl_yychar = tl_yylex(); ptr = tl_nn(prec[nr][i],ptr,tl_level(nr-1)); if (nr==0 && (i==0 || i==1)) ptr->time = LocInter; if(tl_simp_log) ptr = bin_simpler(ptr); else ptr = bin_minimal(ptr); goto again; } if (!ptr) tl_yyerror("syntax error"); #if 0 printf("level %d: ", nr); tl_explain(ptr->ntyp); printf("\n"); #endif return ptr; }
static Node *tl_level(int nr, int *cnt, size_t hasuform, char *uform, Miscellaneous *miscell, int *tl_yychar) { int i; Node *ptr = ZN; Interval LocInter; int tl_simp_log_p = 0; static int prec[2][4] = { { U_OPER, V_OPER, 0, 0}, /* left associative */ { OR, AND, IMPLIES, EQUIV, }, /* left associative */ }; if (nr < 0) return tl_factor(cnt, hasuform, uform, miscell, tl_yychar); ptr = tl_level(nr-1, cnt, hasuform, uform, miscell, tl_yychar); again: for (i = 0; i < 4; i++) if ((*tl_yychar) == prec[nr][i]) { if (nr==0 && (i==0 || i==1)) LocInter = miscell->TimeCon; (*tl_yychar) = tl_yylex(cnt, hasuform, uform, miscell, tl_yychar); ptr = tl_nn(prec[nr][i],ptr,tl_level(nr-1, cnt, hasuform, uform, miscell, tl_yychar), miscell); if (nr==0 && (i==0 || i==1)) ptr->time = LocInter; if(tl_simp_log_p) ptr = bin_simpler(ptr,miscell,cnt,uform, tl_yychar); else ptr = bin_minimal(ptr,miscell,cnt,uform, tl_yychar); goto again; } if (!ptr) tl_yyerror("syntax error", cnt, uform, tl_yychar, miscell); #if 0 printf("level %d: ", nr); tl_explain(ptr->ntyp); printf("\n"); #endif return ptr; }
static Node *tl_factor(void) { Node *ptr = ZN; switch (tl_yychar) { case '(': ptr = tl_formula(); if (tl_yychar != ')') tl_yyerror("expected ')'"); tl_yychar = tl_yylex(); goto simpl; case NOT: ptr = tl_yylval; tl_yychar = tl_yylex(); ptr->lft = tl_factor(); ptr = push_negation(ptr); goto simpl; case ALWAYS: ptr = tl_nn(V_OPER, False, ptr); ptr->time = TimeCon; tl_yychar = tl_yylex(); ptr->rgt = tl_factor(); if(tl_simp_log) { /* must be modified! */ if (ptr->ntyp == V_OPER) { if (ptr->lft->ntyp == FALSE) break; /* [][]p = []p */ ptr = ptr->rgt; /* [] (p V q) = [] q */ } } goto simpl; case NEXT: ptr = tl_nn(NEXT, ZN, ZN); ptr->time = TimeCon; tl_yychar = tl_yylex(); ptr->lft = tl_factor(); goto simpl; case WEAKNEXT: ptr = tl_nn(WEAKNEXT, ZN, ZN); ptr->time = TimeCon; tl_yychar = tl_yylex(); ptr->lft = tl_factor(); goto simpl; case EVENTUALLY: ptr = tl_nn(U_OPER, True, ZN); ptr->time = TimeCon; tl_yychar = tl_yylex(); ptr->rgt = tl_factor(); if(tl_simp_log) { /* this must be modified */ if (ptr->ntyp == U_OPER && ptr->lft->ntyp == TRUE) break; /* <><>p = <>p */ if (ptr->ntyp == U_OPER) { /* <> (p U q) = <> q */ ptr = ptr->rgt; /* fall thru */ } } /* goto simpl; case IMPLIES: ptr = tl_nn(OR, Not(ptr->lft), ptr->rgt); goto simpl; case EQUIV: a = tl_nn(AND,dupnode(ptr->lft),dupnode(ptr->rgt)); b = tl_nn(AND,Not(ptr->lft),Not(ptr->rgt)); ptr = tl_nn(OR, a, b); */ simpl: if (tl_simp_log) ptr = bin_simpler(ptr); break; case PREDICATE: ptr = tl_yylval; tl_yychar = tl_yylex(); break; case TRUE: case FALSE: ptr = tl_yylval; tl_yychar = tl_yylex(); break; } if (!ptr) tl_yyerror("expected predicate"); #if 0 printf("factor: "); tl_explain(ptr->ntyp); printf("\n"); #endif return ptr; }
static Node * tl_factor(void) { Node *ptr = ZN; switch (tl_yychar) { case '(': ptr = tl_formula(); if (tl_yychar != ')') tl_yyerror("expected ')'"); tl_yychar = tl_yylex(); goto simpl; case NOT: ptr = tl_yylval; tl_yychar = tl_yylex(); ptr->lft = tl_factor(); ptr = push_negation(ptr); goto simpl; case ALWAYS: tl_yychar = tl_yylex(); ptr = tl_factor(); if(tl_simp_log) { if (ptr->ntyp == FALSE || ptr->ntyp == TRUE) break; /* [] false == false */ if (ptr->ntyp == V_OPER) { if (ptr->lft->ntyp == FALSE) break; /* [][]p = []p */ ptr = ptr->rgt; /* [] (p V q) = [] q */ } } ptr = tl_nn(V_OPER, False, ptr); goto simpl; #ifdef NXT case NEXT: tl_yychar = tl_yylex(); ptr = tl_factor(); if ((ptr->ntyp == TRUE || ptr->ntyp == FALSE)&& tl_simp_log) break; /* X true = true , X false = false */ ptr = tl_nn(NEXT, ptr, ZN); goto simpl; #endif case EVENTUALLY: tl_yychar = tl_yylex(); ptr = tl_factor(); if(tl_simp_log) { if (ptr->ntyp == TRUE || ptr->ntyp == FALSE) break; /* <> true == true */ if (ptr->ntyp == U_OPER && ptr->lft->ntyp == TRUE) break; /* <><>p = <>p */ if (ptr->ntyp == U_OPER) { /* <> (p U q) = <> q */ ptr = ptr->rgt; /* fall thru */ } } ptr = tl_nn(U_OPER, True, ptr); simpl: if (tl_simp_log) ptr = bin_simpler(ptr); break; case PREDICATE: ptr = tl_yylval; tl_yychar = tl_yylex(); break; case TRUE: case FALSE: ptr = tl_yylval; tl_yychar = tl_yylex(); break; } if (!ptr) tl_yyerror("expected predicate"); #if 0 printf("factor: "); tl_explain(ptr->ntyp); printf("\n"); #endif return ptr; }
static Node *tl_factor(int *cnt, size_t hasuform, char *uform, Miscellaneous *miscell, int *tl_yychar) { Node *ptr = ZN; int tl_simp_log_p = 0; switch ((*tl_yychar)) { case '(': ptr = tl_formula(cnt, hasuform, uform, miscell, tl_yychar); if ((*tl_yychar) != ')') tl_yyerror("expected ')'", cnt, uform, tl_yychar, miscell); (*tl_yychar) = tl_yylex(cnt, hasuform, uform, miscell, tl_yychar); goto simpl; case NOT: ptr = miscell->tl_yylval; (*tl_yychar) = tl_yylex(cnt, hasuform, uform, miscell, tl_yychar); ptr->lft = tl_factor(cnt, hasuform, uform, miscell, tl_yychar); ptr = push_negation(ptr, miscell, cnt, uform, tl_yychar); goto simpl; case ALWAYS: ptr = tl_nn(ALWAYS, False, ZN, miscell); ptr->time = miscell->TimeCon; (*tl_yychar) = tl_yylex(cnt, hasuform, uform, miscell, tl_yychar); ptr->rgt = tl_factor(cnt, hasuform, uform, miscell, tl_yychar); goto simpl; case NEXT: ptr = tl_nn(NEXT, ZN, ZN, miscell); ptr->time = miscell->TimeCon; (*tl_yychar) = tl_yylex(cnt, hasuform, uform, miscell, tl_yychar); ptr->lft = tl_factor(cnt, hasuform, uform, miscell, tl_yychar); goto simpl; case WEAKNEXT: ptr = tl_nn(WEAKNEXT, ZN, ZN, miscell); ptr->time = miscell->TimeCon; (*tl_yychar) = tl_yylex(cnt, hasuform, uform, miscell, tl_yychar); ptr->lft = tl_factor(cnt, hasuform, uform, miscell, tl_yychar); goto simpl; case EVENTUALLY: ptr = tl_nn(EVENTUALLY, True, ZN, miscell); ptr->time = miscell->TimeCon; (*tl_yychar) = tl_yylex(cnt, hasuform, uform, miscell, tl_yychar); ptr->rgt = tl_factor(cnt, hasuform, uform, miscell, tl_yychar); goto simpl; /* case IMPLIES: ptr = tl_nn(OR, Not(ptr->lft), ptr->rgt); goto simpl; /* case EQUIV: a = tl_nn(AND,dupnode(ptr->lft),dupnode(ptr->rgt)); b = tl_nn(AND,Not(ptr->lft),Not(ptr->rgt)); ptr = tl_nn(OR, a, b); */ simpl: if (tl_simp_log_p) ptr = bin_simpler(ptr,miscell,cnt,uform, tl_yychar); break; case PREDICATE: ptr = miscell->tl_yylval; (*tl_yychar) = tl_yylex(cnt, hasuform, uform, miscell, tl_yychar); break; case TRUE: case FALSE: ptr = miscell->tl_yylval; (*tl_yychar) = tl_yylex(cnt, hasuform, uform, miscell, tl_yychar); break; } if (!ptr) tl_yyerror("expected predicate", cnt, uform, tl_yychar, miscell); #if 0 printf("factor: "); tl_explain(ptr->ntyp); printf("\n"); #endif return ptr; }