summaryrefslogtreecommitdiffhomepage
path: root/cppbnf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cppbnf.cpp')
-rwxr-xr-xcppbnf.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/cppbnf.cpp b/cppbnf.cpp
index 0b6e58f..4818fc3 100755
--- a/cppbnf.cpp
+++ b/cppbnf.cpp
@@ -39,11 +39,6 @@ namespace {
return result;
}
- bool isTerminal(const std::string& symbol, const BNF& bnf)
- {
- return bnf.find(symbol) == bnf.end();
- }
-
size_t numberOfStartSymbols(const BNF& bnf)
{
// exactly 1 start symbol
@@ -75,7 +70,7 @@ namespace {
for (const auto& list : lists) {
for (const auto& i : list) {
- if (!isTerminal(i, bnf)) {
+ if (!isTerminal(bnf, i)) {
// every non-terminal symbol must be longer that 1 char
if (i.size() == 1) {
std::cerr << "Warning: Non-Terminal symbol " << i << " in " << symbol << " is too short." << std::endl;
@@ -107,7 +102,7 @@ namespace {
for (const auto& [symbol, lists] : bnf) {
for (const auto& list : lists) {
for (const auto& i : list) {
- if (i.size() != 1 && isTerminal(i, bnf)) {
+ if (i.size() != 1 && isTerminal(bnf, i)) {
std::cerr << "Warning: Terminal symbol in " << symbol << " is too long: "s << i << std::endl;
return false;
}
@@ -197,7 +192,7 @@ namespace {
for (auto& [symbol, lists] : bnf) {
for (auto& list : lists) {
for (int i = 0; i < list.size(); i++) {
- if (list[i].size() > 1 && isTerminal(list[i], bnf)) {
+ if (list[i].size() > 1 && isTerminal(bnf, list[i])) {
auto newList = vectorize(list[i]);
list.erase(list.begin() + i);
list.insert(list.begin() + i, newList.begin(), newList.end());