+++ /dev/null
-#ifndef STreeParser_h\r
-#define STreeParser_h\r
-\r
-/*\r
- * STreeParser.h\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
- * SORCERER 1.00B\r
- * Parr Research Corporation\r
- * with Purdue University and AHPCRC, University of Minnesota\r
- * 1992-1994\r
- */\r
-\r
-/* The programmer should derive a class from SORASTBase; SORASTBase defines\r
- * the minimum public interface that a tree node must follow for SORCERER to\r
- * be able to walk the trees.\r
- */\r
-\r
-/* The @-vars are added by the subclass created by SORCERER; the constructor\r
- * is used to init the @-vars.\r
- */\r
-\r
-#include <stdio.h>\r
-#include <setjmp.h>\r
-#include <stdlib.h>\r
-#include "SASTBase.h"\r
-\r
-#define _DOWN _t=(SORASTBase *)_t->down()\r
-#define _RIGHT _t=(SORASTBase *)_t->right()\r
-\r
-#define _SAVE SORASTBase *_save=_t\r
-#define _RESTORE _t = _save\r
-#define _GUESS_BLOCK STreeParser _st; int _gv; SORASTBase *_savet=NULL;\r
-#define _GUESS {save_state(&_st); \\r
- _savet = _t; \\r
- guessing = 1; \\r
- _gv = setjmp(startofguess.state);}\r
-#define _GUESS_FAIL longjmp(startofguess.state, 1)\r
-#define _GUESS_DONE {restore_state(&_st); _t = _savet;}\r
-#define _MATCH(tok) MATCH(_t,tok)\r
-#define _MATCHRANGE(t1,t2) MATCHRANGE(_t,t1,t2)\r
-#define _WILDCARD WILDCARD(_t)\r
-\r
-#define ast_return(t) *_result = (SORASTBase *)t;\r
-\r
-#define STreeTry(r,p,t) \\r
- (p)->try_result = NULL; \\r
- (p)->sjrv = setjmp((p)->startofguess); \\r
- if ( !(p)->sjrv ) { \\r
- rule(p,t,&try_result); \\r
- (p)->try_ok = 1; \\r
- } \\r
- else { \\r
- (p)->try_ok = 0; \\r
- } \\r
- if ( (p)->try_ok )\r
-\r
-\r
-/* Used only during TRANSFORM mode */\r
-#define TREE_CONSTR_PTRS SORASTBase *_r=NULL,*_s=NULL,*_e=NULL\r
-\r
-typedef struct _Sjmp_buf {\r
- jmp_buf state;\r
- } Sjmp_buf;\r
-\r
-class STreeParser {\r
-protected:\r
- int try_ok, sjrv; /* used by STreeTry macro */\r
- SORASTBase *try_result; /* tree coming back from try */\r
- int guessing;\r
- Sjmp_buf startofguess;\r
-// SORASTBase *t;\r
-\r
- void _mkroot(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *);\r
- void _mkchild(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *);\r
- virtual void mismatched_range(int looking_for, int upper_token, SORASTBase *found);\r
- virtual void missing_wildcard();\r
- virtual void mismatched_token(int looking_for, SORASTBase *found);\r
- virtual void no_viable_alt(char *rulename, SORASTBase *root);\r
- virtual void MATCH(SORASTBase *_t, int tok);\r
- virtual void MATCHRANGE(SORASTBase *_t, int tok, int tok2);\r
- virtual void WILDCARD(SORASTBase *_t);\r
-\r
-public:\r
- STreeParser() { guessing = 0; }\r
- virtual void panic(char *err);\r
- void save_state(STreeParser *);\r
- void restore_state(STreeParser *);\r
-};\r
-\r
-#endif\r