tl.h 3.8 KB

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