summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--grammer.cpp13
-rw-r--r--test-cpp.cpp4
2 files changed, 5 insertions, 12 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?
diff --git a/test-cpp.cpp b/test-cpp.cpp
index 6727966..2a67b38 100644
--- a/test-cpp.cpp
+++ b/test-cpp.cpp
@@ -30,7 +30,7 @@ protected:
}
};
-#if 0
+#if 1
TEST_F(CppTest, preprocessing_tokenize) {
CPP cpp;
auto pp_tokens = cpp.preprocessing_tokenize("int main() { return 1; }");
@@ -40,7 +40,7 @@ TEST_F(CppTest, preprocessing_tokenize) {
auto tokens = cpp.tokens_from_pptokens(pp_tokens);
ASSERT_EQ(tokens.size(), 9);
-#if 1
+#if 0
for (auto &i: tokens) {
std::cout << i.type << ": " << i.value << std::endl;
}