mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Grammar: Updated ::items to ::augmented, returning the full augmented grammar
This commit is contained in:
parent
5719191467
commit
49ca83ad10
2 changed files with 6 additions and 4 deletions
|
@ -167,17 +167,19 @@ std::vector <std::string> Grammar::terminals () const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::map <std::string, std::vector <std::string>> Grammar::items () const
|
||||
std::vector <std::vector <std::string>> Grammar::augmented () const
|
||||
{
|
||||
std::map <std::string, std::vector <std::string>> results;
|
||||
std::vector <std::vector <std::string>> results {{"S", "-->", _start}};
|
||||
for (auto& rule : _rules)
|
||||
for (auto& production : rule.second)
|
||||
{
|
||||
std::vector <std::string> terms;
|
||||
terms.push_back (rule.first);
|
||||
terms.push_back ("-->");
|
||||
for (auto& token : production)
|
||||
terms.push_back (token._token);
|
||||
|
||||
results.insert (std::pair <std::string, std::vector <std::string>>(rule.first, terms));
|
||||
results.push_back (terms);
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
std::string start () const;
|
||||
std::vector <std::string> rules () const;
|
||||
std::vector <std::string> terminals () const;
|
||||
std::map <std::string, std::vector <std::string>> items () const;
|
||||
std::vector <std::vector <std::string>> augmented () const;
|
||||
std::string dump () const;
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue