- switch (adef->type & AT_TYPE_MASK)
- {
- case AT_STRING:
- t = next_token();
- if (t != TOK_STRING)
- parse_error("Parameter %s must be a string", adef->name);
- val = new arg_string(token);
- break;
- case AT_DOUBLE:
- t = next_token();
- if (t != TOK_NUMBER)
- parse_error("Parameter %s must be a number", adef->name);
- val = new arg_double(token_num);
- break;
- case AT_DIMEN:
- val = new arg_double(parse_dimen(adef));
- break;
- default:
- abort();
+ if (has_value)
+ {
+ switch (type)
+ {
+ case AT_STRING:
+ t = next_token();
+ if (t != TOK_STRING)
+ parse_error("Parameter %s must be a string", adef->name);
+ val = new arg_string(token);
+ break;
+ case AT_INT:
+ t = next_token();
+ if (t != TOK_NUMBER || !token_is_int())
+ parse_error("Parameter %s must be an integer", adef->name);
+ val = new arg_int((int) token_num);
+ break;
+ case AT_DOUBLE:
+ t = next_token();
+ if (t != TOK_NUMBER)
+ parse_error("Parameter %s must be a number", adef->name);
+ val = new arg_double(token_num);
+ break;
+ case AT_DIMEN:
+ val = new arg_double(parse_dimen(adef));
+ break;
+ case AT_SWITCH:
+ t = next_token();
+ if (t != TOK_NUMBER || !token_is_int() || ((int) token_num != 0 && (int) token_num != 1))
+ parse_error("Parameter %s must be a switch", adef->name);
+ val = new arg_int((int) token_num);
+ break;
+ default:
+ abort();
+ }
+ }
+ else
+ {
+ if (type == AT_SWITCH)
+ val = new arg_int(1);
+ else
+ parse_error("Parameter %s must have a value", adef->name);