mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Grammar: Converted from std::vector to std::set for metadata
This commit is contained in:
parent
ed138fc819
commit
c62c6448d2
2 changed files with 9 additions and 8 deletions
|
@ -144,24 +144,24 @@ std::string Grammar::start () const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::vector <std::string> Grammar::rules () const
|
||||
std::set <std::string> Grammar::rules () const
|
||||
{
|
||||
std::vector <std::string> results;
|
||||
std::set <std::string> results;
|
||||
for (auto& rule : _rules)
|
||||
results.push_back (rule.first);
|
||||
results.insert (rule.first);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::vector <std::string> Grammar::terminals () const
|
||||
std::set <std::string> Grammar::terminals () const
|
||||
{
|
||||
std::vector <std::string> results;
|
||||
std::set <std::string> results;
|
||||
for (auto& rule : _rules)
|
||||
for (auto& production : rule.second)
|
||||
for (auto& token : production)
|
||||
if (_rules.find (token._token) == _rules.end ())
|
||||
results.push_back (token._token);
|
||||
results.insert (token._token);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <FS.h>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
@ -39,8 +40,8 @@ public:
|
|||
void loadFromFile (File&);
|
||||
void loadFromString (const std::string&);
|
||||
std::string start () const;
|
||||
std::vector <std::string> rules () const;
|
||||
std::vector <std::string> terminals () const;
|
||||
std::set <std::string> rules () const;
|
||||
std::set <std::string> terminals () const;
|
||||
std::string dump () const;
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue