+++ /dev/null
-/*\r
- * SList.C\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
- * domain. An individual or company may do whatever they wish with\r
- * source code distributed with SORCERER or the code generated by\r
- * SORCERER, including the incorporation of SORCERER, or its output, into\r
- * commerical software.\r
- *\r
- * We encourage users to develop software with SORCERER. However, we do\r
- * ask that credit is given to us for developing SORCERER. 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 SORCERER and have developed a nice tool with the\r
- * output, please mention that you developed it using SORCERER. 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
- * PCCTS 1.33\r
- * Terence Parr\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1992-2000\r
- */\r
-\r
-#define ANTLR_SUPPORT_CODE\r
-\r
-#include "SList.h"\r
-#include "pccts_stdarg.h" // MR23\r
-\r
-/* Iterate over a list of elements; returns ptr to a new element\r
- * in list upon every call and NULL when no more are left.\r
- * Very useful like this:\r
- *\r
- * cursor = mylist;\r
- * while ( (p=mylist->iterate(&cursor)) ) {\r
- * // place with element p\r
- * }\r
- *\r
- * The cursor must be initialized to point to the list to iterate over.\r
- */\r
-void *SList::\r
-iterate(SListNode **cursor)\r
-{\r
- void *e;\r
-\r
- if ( cursor == NULL || *cursor==NULL ) return NULL;\r
- if ( head == *cursor ) { *cursor = (*cursor)->next(); }\r
- e = (*cursor)->elem();\r
- (*cursor) = (*cursor)->next();\r
- return e;\r
-}\r
-\r
-/* add an element to end of list. */\r
-void SList::\r
-add(void *e)\r
-{\r
- SListNode *p, *tail=NULL;\r
- require(e!=NULL, "slist_add: attempting to add NULL list element");\r
-\r
- p = new SListNode;\r
- require(p!=NULL, "add: cannot alloc new list node");\r
- p->setElem(e);\r
- if ( head == NULL )\r
- {\r
- head = tail = p;\r
- }\r
- else /* find end of list */\r
- {\r
- tail->setNext(p);\r
- tail = p;\r
- }\r
-}\r
-\r
-void SList::\r
-lfree()\r
-{\r
- SListNode *p,*q;\r
-\r
- if ( head==NULL ) return; /* empty list */\r
- for (p = head; p!=NULL; p=q)\r
- {\r
- q = p->next();\r
- free(p);\r
- }\r
-}\r
-\r
-PCCTS_AST *SList::\r
-to_ast(SList list)\r
-{\r
- PCCTS_AST *t=NULL, *last=NULL;\r
- SListNode *p;\r
-\r
- for (p = head; p!=NULL; p=p->next())\r
- {\r
- PCCTS_AST *u = (PCCTS_AST *)p->elem();\r
- if ( last==NULL ) last = t = u;\r
- else { last->setRight(u); last = u; }\r
- }\r
- return t;\r
-}\r
-\r
-// MR23\r
-int SList::printMessage(FILE* pFile, const char* pFormat, ...)\r
-{\r
- va_list marker;\r
- va_start( marker, pFormat );\r
- int iRet = vfprintf(pFile, pFormat, marker);\r
- va_end( marker );\r
- return iRet;\r
-}\r