parser.c

changeset 35
5a71d53d0228
parent 24
c3fa6c2785dd
child 36
63cd573ffbcf
equal deleted inserted replaced
34:828f3afd5c76 35:5a71d53d0228
214 bool alloced_optstack=FALSE; 214 bool alloced_optstack=FALSE;
215 int i, t, ntokens=0; 215 int i, t, ntokens=0;
216 int init_nest_lvl; 216 int init_nest_lvl;
217 bool had_error; 217 bool had_error;
218 int errornest=0; 218 int errornest=0;
219 bool is_default=FALSE;
219 220
220 /* Allocate tokz->optstack if it does not yet exist (if it does, 221 /* Allocate tokz->optstack if it does not yet exist (if it does,
221 * we have been called from an option handler) 222 * we have been called from an option handler)
222 */ 223 */
223 if(!tokz->optstack){ 224 if(!tokz->optstack){
281 282
282 options=lookup_option(tokz->optstack[tokz->nest_lvl], 283 options=lookup_option(tokz->optstack[tokz->nest_lvl],
283 TOK_IDENT_VAL(tokens+0)); 284 TOK_IDENT_VAL(tokens+0));
284 if(options==NULL) 285 if(options==NULL)
285 options=lookup_option(common_opts, TOK_IDENT_VAL(tokens+0)); 286 options=lookup_option(common_opts, TOK_IDENT_VAL(tokens+0));
287 if(options==NULL && (tokz->flags&TOKZ_DEFAULT_OPTION)){
288 options=lookup_option(tokz->optstack[tokz->nest_lvl], "#default");
289 is_default=(options!=NULL);
290 }
286 291
287 if(options==NULL){ 292 if(options==NULL){
288 had_error=TRUE; 293 had_error=TRUE;
289 tokz_warn_error(tokz, tokens->line, E_TOKZ_UNKNOWN_OPTION); 294 tokz_warn_error(tokz, tokens->line, E_TOKZ_UNKNOWN_OPTION);
290 }else{ 295 }else if(!is_default) {
291 had_error=!check_args(tokz, tokens, ntokens, options->argfmt); 296 had_error=!check_args(tokz, tokens, ntokens, options->argfmt);
292 } 297 }
293 298
294 if(had_error) 299 if(had_error)
295 break; 300 break;

mercurial