tl.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /***** tl_spin: tl.h *****/
  2. /* Copyright (c) 1995-2000 by Lucent Technologies - Bell Laboratories */
  3. /* All Rights Reserved. This software is for educational purposes only. */
  4. /* Permission is given to distribute this code provided that this intro- */
  5. /* ductory message is not removed and no monies are exchanged. */
  6. /* No guarantee is expressed or implied by the distribution of this code. */
  7. /* Written by Gerard J. Holzmann, Bell Laboratories, U.S.A. */
  8. /* Based on the translation algorithm by Gerth, Peled, Vardi, and Wolper, */
  9. /* presented at the PSTV Conference, held in 1995, Warsaw, Poland 1995. */
  10. /* Send bug-reports and/or questions to: gerard@research.bell-labs.com */
  11. #include <stdio.h>
  12. #include <string.h>
  13. typedef struct Symbol {
  14. char *name;
  15. struct Symbol *next; /* linked list, symbol table */
  16. } Symbol;
  17. typedef struct Node {
  18. short ntyp; /* node type */
  19. struct Symbol *sym;
  20. struct Node *lft; /* tree */
  21. struct Node *rgt; /* tree */
  22. struct Node *nxt; /* if linked list */
  23. } Node;
  24. typedef struct Graph {
  25. Symbol *name;
  26. Symbol *incoming;
  27. Symbol *outgoing;
  28. Symbol *oldstring;
  29. Symbol *nxtstring;
  30. Node *New;
  31. Node *Old;
  32. Node *Other;
  33. Node *Next;
  34. unsigned char isred[64], isgrn[64];
  35. unsigned char redcnt, grncnt;
  36. unsigned char reachable;
  37. struct Graph *nxt;
  38. } Graph;
  39. typedef struct Mapping {
  40. char *from;
  41. Graph *to;
  42. struct Mapping *nxt;
  43. } Mapping;
  44. enum {
  45. ALWAYS=257,
  46. AND, /* 258 */
  47. EQUIV, /* 259 */
  48. EVENTUALLY, /* 260 */
  49. FALSE, /* 261 */
  50. IMPLIES, /* 262 */
  51. NOT, /* 263 */
  52. OR, /* 264 */
  53. PREDICATE, /* 265 */
  54. TRUE, /* 266 */
  55. U_OPER, /* 267 */
  56. V_OPER /* 268 */
  57. #ifdef NXT
  58. , NEXT /* 269 */
  59. #endif
  60. };
  61. Node *Canonical(Node *);
  62. Node *canonical(Node *);
  63. Node *cached(Node *);
  64. Node *dupnode(Node *);
  65. Node *getnode(Node *);
  66. Node *in_cache(Node *);
  67. Node *push_negation(Node *);
  68. Node *right_linked(Node *);
  69. Node *tl_nn(int, Node *, Node *);
  70. Symbol *tl_lookup(char *);
  71. Symbol *getsym(Symbol *);
  72. Symbol *DoDump(Node *);
  73. char *emalloc(int); /* in main.c */
  74. int anywhere(int, Node *, Node *);
  75. int dump_cond(Node *, Node *, int);
  76. int hash(char *); /* in sym.c */
  77. int isalnum_(int); /* in spinlex.c */
  78. int isequal(Node *, Node *);
  79. int tl_Getchar(void);
  80. void *tl_emalloc(int);
  81. void a_stats(void);
  82. void addtrans(Graph *, char *, Node *, char *);
  83. void cache_stats(void);
  84. void dump(Node *);
  85. void exit(int);
  86. void Fatal(char *, char *);
  87. void fatal(char *, char *);
  88. void fsm_print(void);
  89. void releasenode(int, Node *);
  90. void tfree(void *);
  91. void tl_explain(int);
  92. void tl_UnGetchar(void);
  93. void tl_parse(void);
  94. void tl_yyerror(char *);
  95. void trans(Node *);
  96. #define ZN (Node *)0
  97. #define ZS (Symbol *)0
  98. #define Nhash 255 /* must match size in spin.h */
  99. #define True tl_nn(TRUE, ZN, ZN)
  100. #define False tl_nn(FALSE, ZN, ZN)
  101. #define Not(a) push_negation(tl_nn(NOT, a, ZN))
  102. #define rewrite(n) canonical(right_linked(n))
  103. typedef Node *Nodeptr;
  104. #define YYSTYPE Nodeptr
  105. #define Debug(x) { if (tl_verbose) printf(x); }
  106. #define Debug2(x,y) { if (tl_verbose) printf(x,y); }
  107. #define Dump(x) { if (tl_verbose) dump(x); }
  108. #define Explain(x) { if (tl_verbose) tl_explain(x); }
  109. #define Assert(x, y) { if (!(x)) { tl_explain(y); \
  110. Fatal(": assertion failed\n",(char *)0); } }