00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ATOMPARSER_H
00022 #define ATOMPARSER_H
00023
00024 #include "JString.h"
00025 #include "ptrstack.h"
00026
00027
00028
00029
00030
00031 enum atomparser_stringtype {DQ_STRING, SQ_STRING, RAW_STRING};
00032
00034 typedef struct atomparser_string {
00035 atomparser_stringtype st;
00036 JString s;
00037 } atomparser_string;
00038
00040 typedef struct atomparser_node {
00041 int node_type;
00042
00043 int extra_type;
00044
00045 double dval;
00046 int ival;
00047 atomparser_string sele;
00048 atomparser_node *left;
00049 atomparser_node *right;
00050
00052 atomparser_node(int nnode_t, int nextra_t = -1) {
00053 node_type = nnode_t;
00054 extra_type = nextra_t;
00055 left = NULL;
00056 right = NULL;
00057 }
00058
00060 #if 1
00070 ~atomparser_node(void) { // destructor
00071 if (left)
00072 delete left;
00073 left=NULL;
00074
00075 if (right)
00076 delete right;
00077 right=NULL;
00078 }
00079 #elif 0
00082 ~atomparser_node(void) { // destructor
00083 if (left == NULL && right == NULL)
00084 return;
00085
00086 PtrStackHandle s = ptrstack_create(128);
00087 atomparser_node *tnode = NULL;
00088
00089 if (left) {
00090 ptrstack_push(s, left);
00091 left=NULL;
00092 }
00093
00094 if (right) {
00095 ptrstack_push(s, right);
00096 right=NULL;
00097 }
00098
00099
00100 while (!ptrstack_pop(s, (void **) &tnode)) {
00101 if (tnode->left) {
00102 ptrstack_push(s, (void *) tnode->left);
00103 tnode->left=NULL;
00104 }
00105
00106 if (tnode->right) {
00107 ptrstack_push(s, (void *) tnode->right);
00108 tnode->right=NULL;
00109 }
00110
00111
00112 delete tnode;
00113 }
00114
00115 ptrstack_destroy(s);
00116 }
00117 #elif 0
00120 ~atomparser_node(void) { // destructor
00121 if (left == NULL && right == NULL)
00122 return;
00123
00124 PtrStackHandle so = ptrstack_create(128);
00125 PtrStackHandle sn = ptrstack_create(128);
00126 atomparser_node *tnode = NULL;
00127
00128 if (left) {
00129 ptrstack_push(so, left);
00130 left=NULL;
00131 }
00132
00133 if (right) {
00134 ptrstack_push(so, right);
00135 right=NULL;
00136 }
00137
00138
00139 while (!ptrstack_empty(so)) {
00140 while (!ptrstack_pop(so, (void **) &tnode)) {
00141 if (tnode->left) {
00142 ptrstack_push(sn, (void *) tnode->left);
00143 tnode->left=NULL;
00144 }
00145
00146 if (tnode->right) {
00147 ptrstack_push(sn, (void *) tnode->right);
00148 tnode->right=NULL;
00149 }
00150
00151
00152 delete tnode;
00153 }
00154
00155
00156 PtrStackHandle stmp = so;
00157 so = sn;
00158 sn = stmp;
00159 }
00160
00161 ptrstack_destroy(so);
00162 ptrstack_destroy(sn);
00163 }
00164 #endif
00165 } atomparser_node;
00166
00168 extern atomparser_node *atomparser_result;
00169
00172 int atomparser_yylookup(const char *s, int len);
00173
00175 extern char *atomparser_yystring;
00176
00178 extern class SymbolTable *atomparser_symbols;
00179
00180 #endif
00181