1 #ifndef SList_h 2 #define SList_h 3 4 /* 5 * SList.h 6 * 7 * SOFTWARE RIGHTS 8 * 9 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public 10 * domain. An individual or company may do whatever they wish with 11 * source code distributed with SORCERER or the code generated by 12 * SORCERER, including the incorporation of SORCERER, or its output, into 13 * commerical software. 14 * 15 * We encourage users to develop software with SORCERER. However, we do 16 * ask that credit is given to us for developing SORCERER. By "credit", 17 * we mean that if you incorporate our source code into one of your 18 * programs (commercial product, research project, or otherwise) that you 19 * acknowledge this fact somewhere in the documentation, research report, 20 * etc... If you like SORCERER and have developed a nice tool with the 21 * output, please mention that you developed it using SORCERER. In 22 * addition, we ask that this header remain intact in our source code. 23 * As long as these guidelines are kept, we expect to continue enhancing 24 * this system and expect to make other tools available as they are 25 * completed. 26 * 27 * PCCTS 1.33 28 * Terence Parr 29 * Parr Research Corporation 30 * with Purdue University and AHPCRC, University of Minnesota 31 * 1992-1998 32 */ 33 34 #include "pcctscfg.h" 35 36 #include "pccts_stdio.h" 37 #include "pccts_stdlib.h" 38 39 PCCTS_NAMESPACE_STD 40 41 #include "PCCTSAST.h" 42 43 class PCCTS_AST; 44 45 class SListNode { 46 protected: 47 void *_elem; /* pointer to any kind of element */ 48 SListNode *_next; 49 public: 50 SListNode() {_elem=_next=NULL;} 51 virtual ~SListNode() {_elem=_next=NULL;} 52 void *elem() { return _elem; } 53 void setElem(void *e) { _elem = e; } 54 void setNext(SListNode *t) { _next = t; } 55 SListNode *next() { return _next; } 56 }; 57 58 class SList { 59 SListNode *head, *tail; 60 public: 61 SList() {head=tail=NULL;} 62 virtual ~SList() {head=tail=NULL;} 63 virtual void *iterate(SListNode **); 64 virtual void add(void *e); 65 virtual void lfree(); 66 virtual PCCTS_AST *to_ast(SList list); 67 virtual void require(int e,char *err){ if ( !e ) panic(err); } 68 virtual void panic(char *err){ fprintf(stderr, "SList panic: %s\n", err); exit(PCCTS_EXIT_FAILURE); } 69 }; 70 71 #endif 72