This repository has been archived on 2026-05-11. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
prog-104-p-05-2030/The-Nook-GamesTM/Proficiencies/stack.h
T
2026-04-20 20:09:16 +02:00

40 lines
774 B
C

#ifndef STACK_H
#define STACK_H
#include <stdlib.h>
union element_type
{
int operand;
char operator;
};
enum element_tag {
TOKEN_OPERAND,
TOKEN_OPERATOR
};
struct expression_element {
enum element_tag tag;
union element_type data;
};
struct stack {
struct expression_element data;
struct stack *next;
};
/* Push a new element to the stack and returns the new top */
struct stack *stack_push(struct stack *s, struct expression_element element);
/* Pop from the stack and returns its new top */
struct stack *stack_pop(struct stack *s);
/* Empty and frees the whole stack */
void stack_destroy(struct stack **s);
/* Returns the current top of the stack */
struct expression_element stack_peek(struct stack *s);
#endif /* ! STACK_H */