This commit is contained in:
Džubara 2024-10-31 23:31:56 +01:00
parent a9c8eb5d28
commit 4dfd9de0cc

View File

@ -3,7 +3,7 @@
int match(char open, char close) { int match(char open, char close) {
return (open == '{' && close == '}') || (open == '[' && close == ']') || return (open == '{' && close == '}') || (open == '[' && close == ']') ||
(open == '(' && close == ')'); (open == '(' && close == ')') || (open == '<' && close == '>');
} }
void check_brackets(const char *code) { void check_brackets(const char *code) {
@ -14,9 +14,9 @@ void check_brackets(const char *code) {
for (int i = 0; code[i] != '\0'; i++) { for (int i = 0; code[i] != '\0'; i++) {
char c = code[i]; char c = code[i];
if (c == '{' || c == '[' || c == '(') { if (c == '{' || c == '[' || c == '(' || c == '<') {
stack[++top] = c; stack[++top] = c;
} else if (c == '}' || c == ']' || c == ')') { } else if (c == '}' || c == ']' || c == ')' || c == '>') {
if (top == -1) { if (top == -1) {
printf("Unexpected closing bracket %c in %d\n", c, i); printf("Unexpected closing bracket %c in %d\n", c, i);
return; return;