+++ /dev/null
-/*\r
- * fcache.c\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain. An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS. However, we do ask\r
- * that credit is given to us for developing PCCTS. By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc... If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS. In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33MR10\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <ctype.h>\r
-\r
-#include "pcctscfg.h"\r
-\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-\r
-#ifdef __USE_PROTOS\r
-CacheEntry *dumpFcache1(char *prev)\r
-#else\r
-CacheEntry *dumpFcache1(prev)\r
- char *prev;\r
-#endif\r
-{\r
- Entry **table=Fcache;\r
-\r
- int low=0;\r
- int hi=0;\r
-\r
- CacheEntry *least=NULL;\r
-\r
- Entry **p;\r
-\r
- for (p=table; p<&(table[HashTableSize]); p++) {\r
-\r
- CacheEntry *q =(CacheEntry *) *p;\r
- \r
- if ( q != NULL && low==0 ) low = p-table;\r
- while ( q != NULL ) {\r
- if (strcmp(q->str,prev) > 0) {\r
- if (least == NULL) {\r
- least=q;\r
- } else {\r
- if (strcmp(q->str,least->str) < 0) {\r
- least=q;\r
- };\r
- };\r
- };\r
- q = q->next;\r
- };\r
-\r
- if ( *p != NULL ) hi = p-table;\r
- }\r
- return least;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void reportFcache(CacheEntry *q)\r
-#else\r
-void reportFcache(q)\r
- CacheEntry *q;\r
-#endif\r
-{\r
- char *qstr;\r
-\r
- fprintf(stdout,"\nrule ");\r
- for (qstr=q->str; *qstr != '*' ; qstr++) {\r
- fprintf(stdout,"%c",*qstr);\r
- };\r
-\r
- qstr++;\r
- if (*qstr == 'i') fprintf(stdout," First[");\r
- if (*qstr == 'o') fprintf(stdout," Follow[");\r
- qstr++;\r
- fprintf(stdout,"%s]",qstr);\r
- if (q->incomplete) fprintf(stdout," *** incomplete ***");\r
- fprintf(stdout,"\n");\r
- MR_dumpTokenSet(stdout,1,q->fset);\r
-}\r
-\r
-void \r
-#ifdef __USE_PROTOS\r
-DumpFcache(void) \r
-#else\r
-DumpFcache() \r
-#endif\r
-{\r
-\r
- char *prev="";\r
- int n=0;\r
- CacheEntry *next;\r
-\r
- fprintf(stdout,"\n\nDump of First/Follow Cache\n");\r
-\r
- for(;;) {\r
- next=dumpFcache1(prev);\r
- if (next == NULL) break;\r
- reportFcache(next);\r
- ++n;\r
- prev=next->str;\r
- };\r
- fprintf(stdout,"\nEnd dump of First/Follow Cache\n");\r
-}\r