string JSFormater::fDeclare(){ string rtn="var "; get_next_token(); rtn.append(fId()); bool inl1,inl2=false; if(is_tag(cur_token,"=")){ get_next_token(); rtn.append(" = ").append(fAssignExpr()); inl1=true; } while(is_tag(cur_token,",")){ string tmp_v; rtn.push_back(','); get_next_token(); tmp_v.append(fId()); if(is_tag(cur_token,"=")){ inl2=true; get_next_token(); tmp_v.append(" = ").append(fAssignExpr()); }else inl2=false; if(inl1==true || inl2==true){ rtn.append("\n "); }else rtn.push_back(' '); rtn.append(tmp_v); inl1=inl2, inl2=false; } if(is_tag(cur_token,";")){ rtn.append(";"); get_next_token(); } return rtn; }
string JSFormater::fObject(){ string rtn="{"; get_next_token(); if(is_tag(cur_token,"}")) return rtn.append("}"); rtn.append(fId()); if(!is_tag(cur_token,":")) throw 1; else{ rtn.append(" : "); get_next_token(); } rtn.append(fAssignExpr()); while(is_tag(cur_token,",")){ rtn.append(", "); get_next_token(); rtn.append(fId()); if(!is_tag(cur_token,":")) throw 1; else{ rtn.append(" : "); get_next_token(); } rtn.append(fAssignExpr()); } rtn.push_back('}'); get_next_token(); return rtn; }
string JSFormater::fFunction(){ string rtn="function "; get_next_token(); if(is_tag(cur_token,"id")){ rtn.append(fId()); } if(is_tag(cur_token,"(")){ rtn.push_back('('); get_next_token(); if(!is_tag(cur_token,")")){ while(true){ if(is_tag(cur_token,"id")){ rtn.append(cur_token.value); get_next_token(); }else throw 1; if(is_tag(cur_token,",")){ rtn.append(", "); get_next_token(); }else if(is_tag(cur_token,")")) break; else throw 1; } } rtn.push_back(')'); get_next_token(); } if(is_tag(cur_token,"{")){ rtn.append(fBlock()); }else throw 1; return rtn; }
void FmRepair::slotRemoveUnref() { FMFontDb *db(FMFontDb::DB()); QStringList failed; QList<FontItem*> flist(typotek::getInstance()->getTheMainView()->curFonts()); for(int i(0); i < unrefList->count(); ++i) { if(unrefList->item(i)->checkState() == Qt::Checked) { FontItem* curItem = 0; QString fId(unrefList->item(i)->text()); foreach(FontItem* it, flist) { if(it->path() == fId) { curItem = it; break; } } if(!db->Remove(fId)) failed << fId; else if(curItem) flist.removeAll(curItem); } }
string JSFormater::fLeftExpr(){ string rtn; while(is_tag(cur_token,"new")){ rtn.append("new "); get_next_token(); } rtn.append(fPriExpr()); while(true){ if(is_tag(cur_token,"(")){ rtn.append("("); get_next_token(); if(!is_tag(cur_token,")")){ rtn.append(fAssignExpr()); while(is_tag(cur_token,",")){ rtn.append(", "); get_next_token(); rtn.append(fAssignExpr()); } } if(!is_tag(cur_token,")")) throw 1; else{ rtn.append(")"); get_next_token(); } }else if(is_tag(cur_token,".")){ get_next_token(); rtn.append(".").append(fId()); }else if(is_tag(cur_token,"[")){ rtn.append("["); get_next_token(); rtn.append(fExpr()); if(!is_tag(cur_token,"]")) throw 1; else{ rtn.append("]"); get_next_token(); } }else break; } return rtn; }