aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/lexer/token.h7
-rw-r--r--module-test/ast.cc6
2 files changed, 11 insertions, 2 deletions
diff --git a/include/lexer/token.h b/include/lexer/token.h
index 5494009..65ef830 100644
--- a/include/lexer/token.h
+++ b/include/lexer/token.h
@@ -1,6 +1,6 @@
#pragma once
-#include <string>lexer
+#include <string>
#include "lexer/enum_type.h"
#include "lexer/shared.h"
@@ -72,6 +72,11 @@ void bracket_depth_changer(char c, int &bracket_depth)
{
bracket_depth--;
println("changed depth: {}", bracket_depth);
+ if (bracket_depth < 0)
+ {
+ cerr << "Ooooops bracket unmatched, quitting" << endl;
+ exit(-1); // TODO: std::expected or what, rather than quitting
+ }
return;
}
}
diff --git a/module-test/ast.cc b/module-test/ast.cc
index f9dcbb8..1710f23 100644
--- a/module-test/ast.cc
+++ b/module-test/ast.cc
@@ -28,7 +28,7 @@ constexpr int MAXLINE = 1024;
int main()
{
- int test_case = 5;
+ int test_case = 6;
string s;
switch (test_case)
@@ -51,6 +51,10 @@ int main()
case 5:
s = "alpha || beta && (gamma || epsilon)";
break;
+ case 6:
+ // bracket matching test
+ s = ")alpha && beta(";
+ break;
default:
return 0;
}