This commit is contained in:
2026-04-20 20:09:16 +02:00
commit a97f290271
22 changed files with 451 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#include "stack.h"
struct stack *stack_push(struct stack *s, struct expression_element e)
{
struct stack *new = malloc(sizeof(struct stack));
new->next = NULL;
new->data = e;
if (s == NULL)
return new;
new->next = s;
return new;
}
struct stack *stack_pop(struct stack *s)
{
if (!s)
return NULL;
struct stack *next = s->next;
free(s);
return next;
}
void stack_destroy(struct stack **s)
{
if(!s)
return;
while (*s)
{
*s = stack_pop(*s);
}
}
struct expression_element stack_peek(struct stack *s)
{
return s->data;
}