示例#1
0
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;
}
示例#2
0
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;
}
示例#3
0
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;
}
示例#4
0
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);

        }
    }
示例#5
0
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;
}