]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Other/Maintained/Tools/Pccts/sorcerer/h/STreeParser.h
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Other / Maintained / Tools / Pccts / sorcerer / h / STreeParser.h
CommitLineData
3eb9473e 1#ifndef STreeParser_h\r
2#define STreeParser_h\r
3\r
4/*\r
5 * STreeParser.h\r
6 *\r
7 * SOFTWARE RIGHTS\r
8 *\r
9 * We reserve no LEGAL rights to SORCERER -- SORCERER is in the public\r
10 * domain. An individual or company may do whatever they wish with\r
11 * source code distributed with SORCERER or the code generated by\r
12 * SORCERER, including the incorporation of SORCERER, or its output, into\r
13 * commerical software.\r
14 *\r
15 * We encourage users to develop software with SORCERER. However, we do\r
16 * ask that credit is given to us for developing SORCERER. By "credit",\r
17 * we mean that if you incorporate our source code into one of your\r
18 * programs (commercial product, research project, or otherwise) that you\r
19 * acknowledge this fact somewhere in the documentation, research report,\r
20 * etc... If you like SORCERER and have developed a nice tool with the\r
21 * output, please mention that you developed it using SORCERER. In\r
22 * addition, we ask that this header remain intact in our source code.\r
23 * As long as these guidelines are kept, we expect to continue enhancing\r
24 * this system and expect to make other tools available as they are\r
25 * completed.\r
26 *\r
27 * SORCERER 1.00B\r
28 * Parr Research Corporation\r
29 * with Purdue University and AHPCRC, University of Minnesota\r
30 * 1992-1994\r
31 */\r
32\r
33/* The programmer should derive a class from SORASTBase; SORASTBase defines\r
34 * the minimum public interface that a tree node must follow for SORCERER to\r
35 * be able to walk the trees.\r
36 */\r
37\r
38/* The @-vars are added by the subclass created by SORCERER; the constructor\r
39 * is used to init the @-vars.\r
40 */\r
41\r
42#include <stdio.h>\r
43#include <setjmp.h>\r
44#include <stdlib.h>\r
45#include "SASTBase.h"\r
46\r
47#define _DOWN _t=(SORASTBase *)_t->down()\r
48#define _RIGHT _t=(SORASTBase *)_t->right()\r
49\r
50#define _SAVE SORASTBase *_save=_t\r
51#define _RESTORE _t = _save\r
52#define _GUESS_BLOCK STreeParser _st; int _gv; SORASTBase *_savet=NULL;\r
53#define _GUESS {save_state(&_st); \\r
54 _savet = _t; \\r
55 guessing = 1; \\r
56 _gv = setjmp(startofguess.state);}\r
57#define _GUESS_FAIL longjmp(startofguess.state, 1)\r
58#define _GUESS_DONE {restore_state(&_st); _t = _savet;}\r
59#define _MATCH(tok) MATCH(_t,tok)\r
60#define _MATCHRANGE(t1,t2) MATCHRANGE(_t,t1,t2)\r
61#define _WILDCARD WILDCARD(_t)\r
62\r
63#define ast_return(t) *_result = (SORASTBase *)t;\r
64\r
65#define STreeTry(r,p,t) \\r
66 (p)->try_result = NULL; \\r
67 (p)->sjrv = setjmp((p)->startofguess); \\r
68 if ( !(p)->sjrv ) { \\r
69 rule(p,t,&try_result); \\r
70 (p)->try_ok = 1; \\r
71 } \\r
72 else { \\r
73 (p)->try_ok = 0; \\r
74 } \\r
75 if ( (p)->try_ok )\r
76\r
77\r
78/* Used only during TRANSFORM mode */\r
79#define TREE_CONSTR_PTRS SORASTBase *_r=NULL,*_s=NULL,*_e=NULL\r
80\r
81typedef struct _Sjmp_buf {\r
82 jmp_buf state;\r
83 } Sjmp_buf;\r
84\r
85class STreeParser {\r
86protected:\r
87 int try_ok, sjrv; /* used by STreeTry macro */\r
88 SORASTBase *try_result; /* tree coming back from try */\r
89 int guessing;\r
90 Sjmp_buf startofguess;\r
91// SORASTBase *t;\r
92\r
93 void _mkroot(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *);\r
94 void _mkchild(SORASTBase **, SORASTBase **, SORASTBase **, SORASTBase *);\r
95 virtual void mismatched_range(int looking_for, int upper_token, SORASTBase *found);\r
96 virtual void missing_wildcard();\r
97 virtual void mismatched_token(int looking_for, SORASTBase *found);\r
98 virtual void no_viable_alt(char *rulename, SORASTBase *root);\r
99 virtual void MATCH(SORASTBase *_t, int tok);\r
100 virtual void MATCHRANGE(SORASTBase *_t, int tok, int tok2);\r
101 virtual void WILDCARD(SORASTBase *_t);\r
102\r
103public:\r
104 STreeParser() { guessing = 0; }\r
105 virtual void panic(char *err);\r
106 void save_state(STreeParser *);\r
107 void restore_state(STreeParser *);\r
108};\r
109\r
110#endif\r