parser.c

changeset 20
3f11f764772a
parent 17
a034888a2227
child 22
79fb689317ea
equal deleted inserted replaced
19:3e498ec7abcd 20:3f11f764772a
25 P_BEG_SECT, 25 P_BEG_SECT,
26 P_END_SECT 26 P_END_SECT
27 }; 27 };
28 28
29 29
30 static bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens,
31 const char *fmt);
32
33
34 /* */ 30 /* */
31
35 32
36 static bool opt_include(Tokenizer *tokz, int n, Token *toks); 33 static bool opt_include(Tokenizer *tokz, int n, Token *toks);
37 34
38 35
39 static ConfOpt common_opts[]={ 36 static ConfOpt common_opts[]={
337 errornest++; 334 errornest++;
338 tokz_warn_error(tokz, tokz->line, E_TOKZ_SYNTAX); 335 tokz_warn_error(tokz, tokz->line, E_TOKZ_SYNTAX);
339 break; 336 break;
340 337
341 case P_END_SECT: 338 case P_END_SECT:
342 if(errornest!=0){
343 errornest--;
344 break;
345 }
346
347 if(tokz->nest_lvl==0){ 339 if(tokz->nest_lvl==0){
348 tokz_warn_error(tokz, tokz->line, E_TOKZ_SYNTAX); 340 tokz_warn_error(tokz, tokz->line, E_TOKZ_SYNTAX);
349 had_error=TRUE; 341 had_error=TRUE;
350 break; 342 break;
351 } 343 }
352 344
353 if(!had_error) 345 if(errornest!=0){
354 had_error=!call_end_sect(tokz, tokz->optstack[tokz->nest_lvl]); 346 if(errornest==1){
355 347 call_cancel_sect(tokz, tokz->optstack[tokz->nest_lvl]);
356 tokz->nest_lvl--; 348 tokz->nest_lvl--;
349 }
350 errornest--;
351 }else{
352 if(!had_error)
353 had_error=!call_end_sect(tokz,
354 tokz->optstack[tokz->nest_lvl]);
355
356 tokz->nest_lvl--;
357 }
357 358
358 if(tokz->nest_lvl<init_nest_lvl) 359 if(tokz->nest_lvl<init_nest_lvl)
359 goto eof; 360 goto eof;
360 } 361 }
361 362
362 if(!had_error) 363 if(!had_error)
363 continue; 364 continue;
364 365
365 if(t==P_STMT_SECT) 366 if(t==P_STMT_SECT || t==P_END_SECT){
366 errornest++; 367 errornest++;
368 /*if(t==P_END_SECT)
369 tokz->nest_lvl--;*/
370 }
367 371
368 if(!(tokz->flags&TOKZ_ERROR_TOLERANT)) 372 if(!(tokz->flags&TOKZ_ERROR_TOLERANT))
369 break; 373 break;
370 } 374 }
371 375
444 */ 448 */
445 449
446 450
447 static int arg_match(Token *tok, char c) 451 static int arg_match(Token *tok, char c)
448 { 452 {
449 static const char chs[]={0, 'l', 'd', 'c', 's', 'i', 'b', 0, 0}; 453 char c2=tok->type;
450 char c2;
451 454
452 if(c=='.' || c=='*') 455 if(c=='.' || c=='*')
453 return 0; 456 return 0;
454
455 c2=chs[tok->type];
456 457
457 if(c2==c) 458 if(c2==c)
458 return 0; 459 return 0;
459 460
460 if(c2=='c' && c=='l'){ 461 if(c2=='c' && c=='l'){
565 566
566 return TRUE; 567 return TRUE;
567 } 568 }
568 569
569 570
570 static bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens, 571 bool check_args(const Tokenizer *tokz, Token *tokens, int ntokens,
571 const char *fmt) 572 const char *fmt)
572 { 573 {
573 int i; 574 int i;
574 int e; 575 int e;
575 576
576 if(fmt==NULL){ 577 if(fmt==NULL){

mercurial