Node *tl_parse(void) { Node *n = tl_formula(); if (tl_verbose) { printf("formula: "); put_uform(); printf("\n"); } return(n); }
Node *tl_parse(int *cnt, size_t hasuform, char *uform, Miscellaneous *miscell, int *tl_yychar) { int tl_verbose_p = 0; Node *n = tl_formula(cnt, hasuform, uform, miscell, tl_yychar); if (tl_verbose_p) { printf("formula: "); put_uform(uform, miscell); printf("\n"); } return(n); }
void tl_parse(void) { Node *n = tl_formula(); if (tl_verbose) { printf("formula: "); dump(n); printf("\n"); } if (tl_Getchar() != -1) { tl_yyerror("syntax error"); tl_errs++; return; } trans(n); }
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(); break; case NOT: ptr = tl_yylval; tl_yychar = tl_yylex(); ptr->lft = tl_factor(); if (!ptr->lft) { fatal("malformed expression", (char *) 0); } ptr = push_negation(ptr); break; case ALWAYS: tl_yychar = tl_yylex(); ptr = tl_factor(); #ifndef NO_OPT 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 */ } #endif ptr = tl_nn(V_OPER, False, ptr); break; #ifdef NXT case NEXT: tl_yychar = tl_yylex(); ptr = tl_factor(); if (ptr->ntyp == TRUE) break; /* X true = true */ ptr = tl_nn(NEXT, ptr, ZN); break; #endif case CEXPR: tl_yychar = tl_yylex(); ptr = tl_factor(); if (ptr->ntyp != PREDICATE) { tl_yyerror("expected {...} after c_expr"); } ptr = tl_nn(CEXPR, ptr, ZN); break; case EVENTUALLY: tl_yychar = tl_yylex(); ptr = tl_factor(); #ifndef NO_OPT 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 */ } #endif ptr = tl_nn(U_OPER, True, 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: 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; }