diff --git a/a1/main b/a1/main index 5bc851c..f534ddc 100755 Binary files a/a1/main and b/a1/main differ diff --git a/a1/program.c b/a1/program.c index bd9dc62..4cd5e11 100644 --- a/a1/program.c +++ b/a1/program.c @@ -44,11 +44,14 @@ void check_brackets(const char *line) { return; } } else if (is_closing(ch)) { - if (stack_top >= 0 && stack[stack_top].bracket == matching_bracket(ch)) { + if (stack_top == -1) { + printf("Unexpected closing bracket %c in %d\n", ch, i); + return; + } else if (stack[stack_top].bracket == matching_bracket(ch)) { stack_top--; } else { printf("Crossed bracket %c in %d, expected %c\n", ch, i, - stack_top >= 0 ? matching_bracket(stack[stack_top].bracket) : '#'); + matching_bracket(stack[stack_top].bracket)); return; } }