summaryrefslogtreecommitdiffhomepage
path: root/grammer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'grammer.cpp')
-rw-r--r--grammer.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/grammer.cpp b/grammer.cpp
index cc285b9..4bcdd4d 100644
--- a/grammer.cpp
+++ b/grammer.cpp
@@ -38,7 +38,8 @@ void Compiler::Validate() const
{
// A program is non empty
if (nodes.size() == 0)
- throw std::runtime_error("");
+ return;
+ //throw std::runtime_error("Program is empty");
// Consistency check for nodes
if (root_node_id >= nodes.size())
@@ -539,12 +540,6 @@ bool Compiler::match(std::vector<std::string> symbol_list, size_t begin, size_t
{
// TODO: isTerminal() necessary here?
- std::cout << "DEBUG: Matching:";
- for (auto symbol: symbol_list) {
- std::cout << " |" << symbol << "|";
- }
- std::cout << std::endl;
-
// match terminal symbols at start
while (begin < end && isTerminal(bnf, tokens[begin].type) && symbol_list.size() > 0 && symbol_list.front() == tokens[begin].type) {
begin++;
@@ -570,10 +565,8 @@ bool Compiler::match(std::vector<std::string> symbol_list, size_t begin, size_t
auto it{bnf.find(symbol_list.front())};
if (it != bnf.end()) {
for (std::vector<std::string> list: it->second) { // iterate over alternatives
- std::cout << "ALTERNATIVE for " << symbol_list.front() << " with " << list.size() << std::endl;
list.insert(list.end(), symbol_list.begin() + 1, symbol_list.end());
- std::cout << "Min: " << minimumSymbolsNeeded(list) << ", end-begin: " << (end-begin) << std::endl;
- if (minimumSymbolsNeeded(list) > end - begin) // stop recursion
+ if (minimumSymbolsNeeded(list) > end - begin) // stop recursion
continue;
// TODO: recurse last?