Added warnings for unused terminals
This commit is contained in:
parent
75fcdeac4c
commit
0952ae950b
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue