00001
00019 #include "parseInt.h"
00020
00024
00025 struct ParseStackFnStruct
00026 {
00027 void ** pData;
00028 int Top;
00029 int Size;
00030 };
00031
00032 struct ParseStackOpStruct
00033 {
00034 int * pData;
00035 int Top;
00036 int Size;
00037 };
00038
00042
00054 Parse_StackFn_t * Parse_StackFnStart( int nDepth )
00055 {
00056 Parse_StackFn_t * p;
00057 p = ALLOC( Parse_StackFn_t, 1 );
00058 memset( p, 0, sizeof(Parse_StackFn_t) );
00059 p->pData = ALLOC( void *, nDepth );
00060 p->Size = nDepth;
00061 return p;
00062 }
00063
00075 bool Parse_StackFnIsEmpty( Parse_StackFn_t * p )
00076 {
00077 return (bool)(p->Top == 0);
00078 }
00079
00091 void Parse_StackFnPush( Parse_StackFn_t * p, void * bFunc )
00092 {
00093 if ( p->Top >= p->Size )
00094 {
00095 printf( "Parse_StackFnPush(): Stack size is too small!\n" );
00096 return;
00097 }
00098 p->pData[ p->Top++ ] = bFunc;
00099 }
00100
00112 void * Parse_StackFnPop( Parse_StackFn_t * p )
00113 {
00114 if ( p->Top == 0 )
00115 {
00116 printf( "Parse_StackFnPush(): Trying to extract data from the empty stack!\n" );
00117 return NULL;
00118 }
00119 return p->pData[ --p->Top ];
00120 }
00121
00133 void Parse_StackFnFree( Parse_StackFn_t * p )
00134 {
00135 FREE( p->pData );
00136 FREE( p );
00137 }
00138
00139
00140
00141
00153 Parse_StackOp_t * Parse_StackOpStart( int nDepth )
00154 {
00155 Parse_StackOp_t * p;
00156 p = ALLOC( Parse_StackOp_t, 1 );
00157 memset( p, 0, sizeof(Parse_StackOp_t) );
00158 p->pData = ALLOC( int, nDepth );
00159 p->Size = nDepth;
00160 return p;
00161 }
00162
00174 bool Parse_StackOpIsEmpty( Parse_StackOp_t * p )
00175 {
00176 return (bool)(p->Top == 0);
00177 }
00178
00190 void Parse_StackOpPush( Parse_StackOp_t * p, int Oper )
00191 {
00192 if ( p->Top >= p->Size )
00193 {
00194 printf( "Parse_StackOpPush(): Stack size is too small!\n" );
00195 return;
00196 }
00197 p->pData[ p->Top++ ] = Oper;
00198 }
00199
00211 int Parse_StackOpPop( Parse_StackOp_t * p )
00212 {
00213 if ( p->Top == 0 )
00214 {
00215 printf( "Parse_StackOpPush(): Trying to extract data from the empty stack!\n" );
00216 return -1;
00217 }
00218 return p->pData[ --p->Top ];
00219 }
00220
00232 void Parse_StackOpFree( Parse_StackOp_t * p )
00233 {
00234 FREE( p->pData );
00235 FREE( p );
00236 }
00237
00238
00242
00243