bool qCtxComp::ParseFunc(qStr *in, qStr *out) { char c; // int pop = 0; c = in->GetC(); if (isqsymf(c)) { CStr name(c,1); while ( (c = in->GetC()) != EOF ) { if (c == T_LPAR) { OutFlush(out); qArgAry ary; qObj *obj; if (Find(&obj, name)) { ParseCompArgs(in, &ary, obj->GetQmap()); } else { ParseCompArgs(in, &ary, NULL); } OutFunc(out, name, &ary); return true; } else if (c == T_PCT) { if (name.Length()==0) { break; } else { OutFlush(out); OutFunc(out, name, NULL); return true; } } else if (isqsym(c)) { name << c; } else break; } if (name.Length()!=0) { OutS(T_PCT); } else if (c == T_LPAR) OutS(T_PCT); if (c != EOF) OutS(c); } else { OutC(T_PCT); if (c != EOF && c != T_PCT) { if ((c == T_RP || c == ',' || c == T_LP || c == '"')) { if (!in->UngetC(c) || myStrict) { ThrowF(out, 98, "Invalid syntax '%%%c'.", c); } } else { OutC(c); } } } return false; }
bool qCtx::ParseFunc(qStr *in, qStr *out) { const char *map; char c; // int pop = 0; c = in->GetC(); if (isqsymf(c)) { qObj *obj; CStr name(c,1); while ( (c = in->GetC()) != EOF ) { if (c == T_LP) { qArgAry ary; if (Find(&obj, (const CStr &) name)) { if ((map = obj->GetQmap())) { ParseArgsQmap(in, &ary, map); } else { ParseArgs(in, &ary); } if (myTry) obj->Eval(this, out, &ary); else { try { obj->Eval(this, out, &ary); } catch (qCtxEx ex) { Throw(out, ex); } catch (qCtxExAbort ex) { throw ex; } catch (...) { Throw(out, 999, "Ctx Unhandled exception."); } } return true; } else { if (myStrict) { ThrowF(out, 98, "Function '%s' was not found.", (const char *) name); } else { out->PutC('%'); out->PutS(name); out->PutC(T_LP); ParseArgsLPar(in, out); return false; } } } else if (c == '%') { if (name.Length()==0) { break; } else if (Find(&obj, name)) { obj->Eval(this, out, NULL); return true; } else { if (myStrict) { ThrowF(out, 98, "Function '%s' was not found.", (const char *) name); } break; } } else if (isqsym(c)) { name << c; } else break; } if (name.Length()!=0) { out->PutC('%'); out->PutS(name); } else if (c == T_LP) out->PutC('%'); if (c != EOF) out->PutC(c); } else { out->PutC('%'); if (c != EOF && c != '%') { if ((c == T_RP || c == ',' || c == T_LP || c == '"')) { if (!in->UngetC(c) || myStrict) { ThrowF(out, 98, "Invalid syntax '%%%c'.", c); } } else { out->PutC(c); } } } return false; }