void do_components( void (*func)(void)) { /** Function: Handles COMPONENTS OF in an item Procedure: 1. IF no next token OR it's not 'OF' OR no next token OR item is not in table OR it's imported, syntax error IF no function Add token as a child of classname Return Save current file position 2. Go to where item starts Read tokens until '{' is found 3. Call function Go back to saved place in file Keep reading until ',' or '}' **/ struct name_table *ntbp; long pos; if (tell_pos(streams.str) < real_start) return; if (!get_token(0, token) || /* step 1 */ strcmp(token, of_w) || !get_token(0, token)) syntax(components_w); if (!func) { add_child(token, add_name(classname, (long)0, 0), 0, (long)-1, 0); *itemname = 'x'; /* to make the test for no itemname fail */ return; } if (!(ntbp = find_name(token))->name || !*ntbp->name || ntbp->pos < 0) syntax(components_w); pos = tell_pos(streams.str); curr_pos = ntbp->pos; fseek(streams.str, ntbp->pos, 0); /* step 2 */ for (*token = 0; get_token(0, token) && *token != '{';); if (*token != '{') syntax(components_w); state = SUB_ITEM; if (func) (*func)(); /* step 3 */ curr_pos = pos; fseek(streams.str, pos, 0); state = IN_ITEM; for (*token = 0; *token != ',' && *token != '}'; get_token(0, token)); end_item(); }
cmd("显示文章", 101); start(); entity("脸图", "string"); entity("编号", "number"); enumcase("窗口背景", "普通窗口", "透明背景", "暗色窗口", end_item()); enumcase("窗口位置", "居上", "居中", "居下", end_item()); stop(); cmd("选项", 102); start(); entity("选项", "stringlist"); enumcase("取消的情况", "无效", "选项1", "选项2", "选项3", "选项4", end_item()); stop(); cmd("数值输入", 103); start(); entity("接受数值的变量", "var"); entity("最大数码", "number"); stop(); cmd("物品选择", 104); start(); entity("接受物品的变量", "var"); entity("最大数码", "number"); stop(); cmd("滚动字幕", 105); start(); entity("卷动速度", "number"); enumcase("快进", "是", "否", end_item()); stop();