-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.h
More file actions
61 lines (49 loc) · 1.34 KB
/
stack.h
File metadata and controls
61 lines (49 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* IFJ20 - Stack library
* Authors:
* Mario Harvan, xharva03
*/
#ifndef STACK_H
#define STACK_H
#include "scanner.h"
#include <stdbool.h>
typedef struct{
unsigned int size; //size of array
unsigned int itemCnt; //number of items in stack
unsigned int stackPosition; //position of last item in stack
Token* arrPtr;
} Stack;
/**
* @brief Function will init empty stack
* @return Pointer to stack or null when init fails
*/
Stack* stackInit();
/**
* @brief Function will check if stack is empty
* @param Pointer to stack
* @return true when stack is empty, or false if its not
*/
bool stackIsEmpty(Stack *stack);
/**
* @brief Function will return token from top of stack
* @param Pointer to stack
* @return Token on top of stack, or empty token when stack is empty
*/
Token stackPeek(Stack *stack);
/**
* @brief Funtion will add token at top of stack
* @param Pointer to stack
* @param Token to push
*/
void stackPush(Stack *stack, Token token);
/**
* @brief Funtion will remove token from top of stack and returns it
* @param Pointer to stack
* @return Token from top of stack, or empty token when stack is empty
*/
Token stackPop(Stack *stack);
/**
* @brief Function will free stack
* @param Pointer to stack
*/
void stackFree(Stack *stack);
#endif