# HG changeset patch # User tuomov # Date 967461336 -7200 # Node ID 79fb689317ea6c6d28041ba1024e727b490301bd # Parent 6d4282804e7333fb96213162d6cfcd7e8563d440 trunk: changeset 25 Parser error handling fixes diff -r 6d4282804e73 -r 79fb689317ea parser.c --- a/parser.c Mon Aug 28 12:24:32 2000 +0200 +++ b/parser.c Mon Aug 28 13:15:36 2000 +0200 @@ -69,11 +69,7 @@ if(!TOK_IS_OP(tok)){ if(ntokens==1 && !had_comma){ - /*if(!TOK_IS_IDENT(tok)){ - e=E_TOKZ_IDENTIFIER_EXPECTED; - goto handle_error; - }*/ - + /* first token */ had_comma=2; }else{ if(had_comma==0) @@ -244,8 +240,6 @@ tok_init(&tokens[i]); - /* The loop - */ while(1){ had_error=FALSE; @@ -275,14 +269,16 @@ E_TOKZ_IDENTIFIER_EXPECTED); } - if(had_error) - break; - if(t==P_STMT){ if(find_beg_sect(tokz)) t=P_STMT_SECT; } + if(had_error) + break; + + /* Got the statement and its type */ + options=lookup_option(tokz->optstack[tokz->nest_lvl], TOK_IDENT_VAL(tokens+0)); if(options==NULL) @@ -298,6 +294,8 @@ if(had_error) break; + /* Found the option and arguments are ok */ + if(options->opts!=NULL){ if(t!=P_STMT_SECT){ had_error=TRUE; @@ -306,7 +304,8 @@ tokz_warn_error(tokz, tokz->line, E_TOKZ_MAX_NEST); had_error=TRUE; }else{ - tokz->optstack[++tokz->nest_lvl]=options->opts; + tokz->nest_lvl++; + tokz->optstack[tokz->nest_lvl]=options->opts; } }else if(t==P_STMT_SECT){ had_error=TRUE; @@ -336,23 +335,18 @@ break; case P_END_SECT: - if(tokz->nest_lvl==0){ + if(tokz->nest_lvl+errornest==0){ tokz_warn_error(tokz, tokz->line, E_TOKZ_SYNTAX); had_error=TRUE; + } + + if(had_error) break; - } if(errornest!=0){ - if(errornest==1){ - call_cancel_sect(tokz, tokz->optstack[tokz->nest_lvl]); - tokz->nest_lvl--; - } errornest--; }else{ - if(!had_error) - had_error=!call_end_sect(tokz, - tokz->optstack[tokz->nest_lvl]); - + had_error=!call_end_sect(tokz, tokz->optstack[tokz->nest_lvl]); tokz->nest_lvl--; } @@ -363,11 +357,8 @@ if(!had_error) continue; - if(t==P_STMT_SECT || t==P_END_SECT){ + if(t==P_STMT_SECT) errornest++; - /*if(t==P_END_SECT) - tokz->nest_lvl--;*/ - } if(!(tokz->flags&TOKZ_ERROR_TOLERANT)) break;