QList<RulePtr> Grammar::makeRuleList(const QVariantList& ruleListData) const { QList<RulePtr> rules; QListIterator<QVariant> iter(ruleListData); while (iter.hasNext()) { QVariantMap ruleData = iter.next().toMap(); rules << makeRule(ruleData); } return rules; }
QMap<int, RulePtr> Grammar::makeCaptures(const QVariantMap& capturesData) const { QMap<int, RulePtr> captures; QMapIterator<QString, QVariant> iter(capturesData); while (iter.hasNext()) { iter.next(); int num = iter.key().toInt(); QVariantMap data = iter.value().toMap(); captures[num] = makeRule(data); } return captures; }
QMap<QString, RulePtr> Grammar::readRepository(const QVariantMap& syntaxData) const { QMap<QString, RulePtr> repository; QVariantMap repositoryData = syntaxData.value("repository").toMap(); QMapIterator<QString, QVariant> iter(repositoryData); while (iter.hasNext()) { iter.next(); QVariantMap ruleData = iter.value().toMap(); repository["#" + iter.key()] = makeRule(ruleData); } return repository; }
Node *findRule(char *name) { Node *n; char *ptr; for (ptr= name; *ptr; ptr++) if ('-' == *ptr) *ptr= '_'; for (n= rules; n; n= n->any.next) { assert(Rule == n->type); if (!strcmp(name, n->rule.name)) return n; } return makeRule(name); }
void FLAccessControlLists::installACL(const QString &idacl) { QDomDocument doc("ACL"); QDomElement root = doc.createElement("ACL"); doc.appendChild(root); QDomElement name = doc.createElement("name"); root.appendChild(name); QDomText n = doc.createTextNode(idacl); name.appendChild(n); FLSqlQuery q; q.setTablesList("flacs"); q.setSelect("idac,tipo,nombre,iduser,idgroup,degrupo,permiso"); q.setFrom("flacs"); q.setWhere(QString::fromLatin1("idacl='") + idacl + QString::fromLatin1("'")); q.setOrderBy("prioridad DESC,tipo"); q.setForwardOnly(true); if (q.exec()) { uint step = 0; QProgressDialog progress(QApplication::tr("Instalando control de acceso..."), 0, q.size(), 0, 0, true); progress.setCaption(QApplication::tr("Instalando ACL")); progress.setMinimumDuration(0); progress.setProgress(++step); while (q.next()) { makeRule(&q, &doc); progress.setProgress(++step); } FLSqlConnections::database()->managerModules()->setContent("acl.xml", "sys", doc.toString()); } }
void endNameList() { if (name) { // if only one name to left of : startNameList(); // it hasn't been put in list yet name = NULL; } else CLEAR(actionFlags, A_TARGET); // clear target flag if (buf[1]) SET(currentFlags, F2_DOUBLECOLON); // so addItemToList() if (!list) // won't expand names makeError(currentLine, SYNTAX_NO_TARGET_NAME); // of dependents if (ON(actionFlags, A_RULE)) { BOOL fBatch; // A rule with a doublecolon on the dependency line // is a "batch rule", i.e., a rule that applies the // command block in batch mode for all affected // dependents. fBatch = !!(ON(currentFlags, F2_DOUBLECOLON)); makeRule(list, fBatch); FREE_STRINGLIST(list); } else if (!(list->next) && doSpecial(list->text)) { // special pseudotarget ... FREE(list->text); // don't need ".SUFFIXES" etc FREE_STRINGLIST(list); } else // regular target targetList = list; list = NULL; // We are now looking for a dependent SET(actionFlags, A_DEPENDENT); }
void SyntaxHighlighter::buildRules() { std::wstringstream wss; for (const auto& cmd : COMMANDS) { wss << L"^" << cmd << L"\\b"; commandHighlightingRules.append(makeRule(wss.str(), commandNameFormat, commandNameFormat)); wss.str(L""); } wss << L"\\s" << PARAM_PREFIX << L"\\s+"; paramHighlightingRules.append(makeRule(wss.str(), parameterPrefixFormat, parameterPrefixFormat)); wss.str(L""); for (const auto& param : PARAMS) { wss << L"\\s+" << param << L"\\b"; paramHighlightingRules.append(makeRule(wss.str(), parameterNameFormat, parameterNameFormat)); wss.str(L""); } for (const auto& param : PARAMS) { for (const auto& order : ORDERS) { wss << L"\\s+" << param << L"\\s+" << order << L"\\b"; orderHighlightingRules.append(makeRule(wss.str(), orderNameFormat, parameterNameFormat)); wss.str(L""); } } wss << L"\\s+" << ORDER_PREFIX << L"\\s+"; orderPrefixHighlightingRule.append(makeRule(wss.str(), orderPrefixFormat, orderPrefixFormat)); wss.str(L""); for (const auto& symbol : SYMBOLS) { wss << symbol; symbolHighlightingRule.append(makeRule(wss.str(), symbolFormat, symbolFormat)); wss.str(L""); } }
RuleI* RuleMaker::makeRuleFromConsts(const std::string& i_group) { std::vector<std::string> ruleOutLayers = Consts::get("outputLayers", i_group).toVector<std::string>(); if(ruleOutLayers.empty()) AutomapLog::report("Empty output layer list from Consts: "+i_group, AutomapLog::Type::Warning); std::vector<Param> ruleIndexes = Consts::get("indexes", i_group); if(ruleIndexes.empty()) AutomapLog::report("Empty indexes from Consts: "+i_group, AutomapLog::Type::Warning); size_t ruleRotations = 0, ruleAnimationFrames = 0, ruleAnimationShift = 0; if(Consts::isExist("rotation", i_group)) ruleRotations = Consts::get("rotation", i_group); if(Consts::isExist("animation_frames", i_group)) ruleAnimationFrames = Consts::get("animation_frames", i_group); if(Consts::isExist("animation_shift", i_group)) ruleAnimationShift = Consts::get("animation_shift", i_group); RuleI* rule = makeRule(ruleRotations); for( size_t i =0; i<ruleOutLayers.size(); ++i ) { rule->assignIndex(i, ruleOutLayers[i]); } for( size_t i =0; i<ruleIndexes.size(); ++i ) { std::vector<Param> tinfo = ruleIndexes.at(i); if(tinfo.size()!=5) { AutomapLog::report("Cannot create TileInfo from Consts"+i_group, AutomapLog::Type::Error); continue; } TileInfo info(tinfo[0],tinfo[1],tinfo[2],tinfo[3],tinfo[4]); size_t ind = makeInfoGetIndex(i+1, info); tinfo = ruleIndexes.at(ind-1); if(tinfo.size()!=5) { AutomapLog::report("Cannot create TileInfo from Consts"+i_group, AutomapLog::Type::Error); continue; } info.path = (std::string)tinfo[0]; info.x = (size_t)tinfo[1]; info.y = (size_t)tinfo[2]; info.w = (size_t)tinfo[3]; info.h = (size_t)tinfo[4]; if(ruleAnimationFrames && ruleAnimationShift) { std::vector<TileInfo> anim; for(size_t frame = 0; frame<ruleAnimationFrames; ++frame) { anim.push_back( TileInfo(info.path, info.x + frame*ruleAnimationShift, info.y, info.w, info.h)); } setAnimation(anim, info); } //TileInfo info(tinfo[0], tinfo[1], tinfo[2], tinfo[3], tinfo[4]); if(info.name()=="") AutomapLog::report("Empty name for tileset from Consts: "+i_group, AutomapLog::Type::Error); rule->assignIndex(i+1, info); } return rule; }
RulePtr Grammar::readSyntaxData(const QVariantMap& syntaxData) const { QVariantMap rootData; rootData["patterns"] = syntaxData.value("patterns"); return makeRule(rootData); }