mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Grammar: Added ::terminals
This commit is contained in:
parent
35d246aa32
commit
0cd1d48290
2 changed files with 14 additions and 0 deletions
|
@ -153,6 +153,19 @@ std::vector <std::string> Grammar::rules () const
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::vector <std::string> Grammar::terminals () const
|
||||||
|
{
|
||||||
|
std::vector <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);
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Grammar::dump () const
|
std::string Grammar::dump () const
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
void loadFromString (const std::string&);
|
void loadFromString (const std::string&);
|
||||||
std::string start () const;
|
std::string start () const;
|
||||||
std::vector <std::string> rules () const;
|
std::vector <std::string> rules () const;
|
||||||
|
std::vector <std::string> terminals () const;
|
||||||
std::string dump () const;
|
std::string dump () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue