** Try to increase the size of the parser stack. Return the number ** of errors. Return 0 on success. */
| 283 | ** of errors. Return 0 on success. |
| 284 | */ |
| 285 | static int yyGrowStack(yyParser *p){ |
| 286 | int newSize; |
| 287 | int idx; |
| 288 | yyStackEntry *pNew; |
| 289 | |
| 290 | newSize = p->yystksz*2 + 100; |
| 291 | idx = p->yytos ? (int)(p->yytos - p->yystack) : 0; |
| 292 | if( p->yystack==&p->yystk0 ){ |
| 293 | pNew = malloc(newSize*sizeof(pNew[0])); |
| 294 | if( pNew ) pNew[0] = p->yystk0; |
| 295 | }else{ |
| 296 | pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); |
| 297 | } |
| 298 | if( pNew ){ |
| 299 | p->yystack = pNew; |
| 300 | p->yytos = &p->yystack[idx]; |
| 301 | #ifndef NDEBUG |
| 302 | if( yyTraceFILE ){ |
| 303 | fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n", |
| 304 | yyTracePrompt, p->yystksz, newSize); |
| 305 | } |
| 306 | #endif |
| 307 | p->yystksz = newSize; |
| 308 | } |
| 309 | return pNew==0; |
| 310 | } |
| 311 | #endif |
| 312 | |
| 313 | /* Datatype of the argument to the memory allocated passed as the |