vector< string > split(const sregex& regex, const string& str) { vector< string > result; sregex_token_iterator tokenIterator(str.begin(), str.end(), regex, -1); sregex_token_iterator end; std::copy(tokenIterator, end, std::back_inserter(result)); return result; }
Element* SymbolDefinitionStructure::identify(const ParseUnit* unit) const { if (unit->getTokens().size() != 2) return NULL; QStringListIterator tokenIterator(unit->getTokens()); QString type = tokenIterator.next(); QString name = tokenIterator.next(); if (unit->hasArguments() || unit->hasBody() || unit->hasScopedAccess()) return NULL; return new SymbolDefinition(type, name); }
Element* DurativeActionStructure::identify(const ParseUnit* unit) const { if (unit->getTokens().size() != 2) return NULL; if (! unit->hasBody() || unit->hasScopedAccess()) return NULL; QStringListIterator tokenIterator(unit->getTokens()); QString type = tokenIterator.next(); if (type != "DurativeAction") return NULL; QString name = tokenIterator.next(); return new DurativeAction(type, name); }