Added warnings for unused terminals

This commit is contained in:
kwullaer 2017-01-27 21:16:33 +01:00
parent 75fcdeac4c
commit 0952ae950b
1 changed files with 15 additions and 1 deletions

View File

@ -9,7 +9,6 @@
namespace {
std::set<std::string> getTerminals(std::string file) {
std::set<std::string> terminals;
std::fstream f(file);
return lxs::input::InputParser::getTokens(f);
}
@ -41,6 +40,21 @@ namespace pds {
}
}
bool found_token;
for(auto& term : cnf.grammar.terminals) {
found_token = false;
for(auto& rule : cnf.grammar.rules) {
for(auto& tail_value : rule->tail) {
if (tail_value == term) {
found_token = true;
break;
}
}
if (found_token) break;
}
if (!found_token)
std::cout << "Warning: Terminal '" << term << "' is not been used." << std::endl;
}
return cnf;
}