1 /***** tl_spin: tl_main.c *****/
4 * This file is part of the public release of Spin. It is subject to the
5 * terms in the LICENSE file that is included in this source directory.
6 * Tool documentation is available at http://spinroot.com
8 * Based on the translation algorithm by Gerth, Peled, Vardi, and Wolper,
9 * presented at the PSTV Conference, held in 1995, Warsaw, Poland 1995.
16 int newstates = 0; /* debugging only */
23 unsigned long All_Mem = 0;
26 static char uform[4096];
27 static int hasuform=0, cnt=0;
29 extern void cache_stats(void);
30 extern void a_stats(void);
45 { return uform[cnt+n];
55 for (i = 0; i < hasuform; i++)
56 { if (uform[i] == '(')
58 && ((uform[i-1] == '"' && uform[i+1] == '"')
59 || (uform[i-1] == '\'' && uform[i+1] == '\'')))
63 } else if (uform[i] == ')')
65 && ((uform[i-1] == '"' && uform[i+1] == '"')
66 || (uform[i-1] == '\'' && uform[i+1] == '\'')))
74 tl_yyerror("parentheses not balanced");
81 fprintf(tl_out, "%s", uform);
92 { extern int Stack_mx;
93 printf("total memory used: %9ld\n", All_Mem);
94 printf("largest stack sze: %9d\n", Stack_mx);
100 tl_main(int argc, char *argv[])
102 extern int xspin, s_trail;
104 tl_verbose = 0; /* was: tl_verbose = verbose; */
105 if (xspin && s_trail)
107 /* generating claims for a replay should
108 be done the same as when generating the
109 pan.c that produced the error-trail */
111 { tl_clutter = 1-xspin; /* use -X -f to turn off uncluttering */
118 memset(uform, 0, sizeof(uform));
121 claim_name = (char *) 0;
128 while (argc > 1 && argv[1][0] == '-')
130 switch (argv[1][1]) {
131 case 'd': newstates = 1; /* debugging mode */
133 case 'f': argc--; argv++;
134 for (i = 0; argv[1][i]; i++)
135 { if (argv[1][i] == '\t'
136 || argv[1][i] == '\n')
139 strcpy(uform, argv[1]);
140 hasuform = (int) strlen(uform);
142 case 'v': tl_verbose++;
144 case 'n': tl_terse = 1;
146 case 'c': argc--; argv++;
147 claim_name = (char *) emalloc(strlen(argv[1])+1);
148 strcpy(claim_name, argv[1]);
150 default : printf("spin -f: saw '-%c'\n", argv[1][1]);
157 nogood: printf("usage:\tspin [-v] [-n] -f formula\n");
158 printf(" -v verbose translation\n");
159 printf(" -n normalize tl formula and exit\n");
167 if (tl_verbose) tl_stats();
172 fprintf(tl_out, "("); \
174 fprintf(tl_out, a); \
184 case OR: Binop(" || "); break;
185 case AND: Binop(" && "); break;
186 case U_OPER: Binop(" U "); break;
187 case V_OPER: Binop(" V "); break;
190 fprintf(tl_out, "X");
191 fprintf(tl_out, " (");
193 fprintf(tl_out, ")");
197 fprintf(tl_out, "!");
198 fprintf(tl_out, " (");
200 fprintf(tl_out, ")");
203 fprintf(tl_out, "false");
206 fprintf(tl_out, "true");
209 fprintf(tl_out, "(%s)", n->sym->name);
212 fprintf(tl_out, "c_expr");
213 fprintf(tl_out, " {");
215 fprintf(tl_out, "}");
218 fprintf(tl_out, " D ");
221 printf("Unknown token: ");
231 case ALWAYS: printf("[]"); break;
232 case EVENTUALLY: printf("<>"); break;
233 case IMPLIES: printf("->"); break;
234 case EQUIV: printf("<->"); break;
235 case PREDICATE: printf("predicate"); break;
236 case OR: printf("||"); break;
237 case AND: printf("&&"); break;
238 case NOT: printf("!"); break;
239 case U_OPER: printf("U"); break;
240 case V_OPER: printf("V"); break;
242 case NEXT: printf("X"); break;
244 case CEXPR: printf("c_expr"); break;
245 case TRUE: printf("true"); break;
246 case FALSE: printf("false"); break;
247 case ';': printf("end of formula"); break;
248 default: printf("%c", n); break;
253 tl_non_fatal(char *s1, char *s2)
254 { extern int tl_yychar;
259 printf(s1, s2); /* prevent a compiler warning */
266 if (tl_yychar != -1 && tl_yychar != 0)
268 tl_explain(tl_yychar);
271 printf("\ntl_spin: %s\n---------", uform);
272 for (i = 0; i < cnt; i++)
282 Fatal(s1, (char *) 0);
286 Fatal(char *s1, char *s2)
288 tl_non_fatal(s1, s2);