Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

AtomParser.h

Go to the documentation of this file.
00001 /***************************************************************************
00002 *cr 
00003 *cr (C) Copyright 1995-2019 The Board of Trustees of the 
00004 *cr University of Illinois 
00005 *cr All Rights Reserved 
00006 *cr 
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010 * RCS INFORMATION:
00011 *
00012 * $RCSfile: AtomParser.h,v $
00013 * $Author: johns $ $Locker: $ $State: Exp $
00014 * $Revision: 1.30 $ $Date: 2019年01月17日 21:20:58 $
00015 *
00016 ***************************************************************************
00017 * DESCRIPTION:
00018 * Basic data types for the yacc/lex interface and for the parse tree
00019 *
00020 ***************************************************************************/
00021 #ifndef ATOMPARSER_H
00022 #define ATOMPARSER_H
00023 
00024 #include "JString.h"
00025 #include "ptrstack.h"
00026 
00027 // the idea about strings is that some can be regexed.
00028 // "This" is a double-quoted string -- can do regex
00029 // 'this' is a single-quoted string -- don't do regex
00030 // this is a raw, or unquoted, string -- don't do regex
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 // depth-first traversal deleting nodes
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 // delete the node once the child nodes have been recorded
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 // breadth-first traversal deleting nodes
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 // delete the node once the child nodes have been recorded
00152 delete tnode;
00153 }
00154 
00155 // swap old and new stacks
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 

Generated on Wed Nov 19 02:45:35 2025 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002

AltStyle によって変換されたページ (->オリジナル) /