-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.h
65 lines (54 loc) · 1.27 KB
/
stack.h
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
62
63
64
65
/*
* Project: Compiler for imperative programing language IFJ20
*
* File: stack.h
* Brief: Stack header file.
*
* Authors: Hladký Tomáš xhladk15@stud.fit.vutbr.cz
* Kostolányi Adam xkosto04@stud.fit.vutbr.cz
* Makiš Jozef xmakis00@stud.fit.vutbr.cz
* Bartko Jakub xbartk07@stud.fit.vutbr.cz
*/
#ifndef IFJ_BHKM_STACK_H
#define IFJ_BHKM_STACK_H
#include "scanner.h"
#include "symtable.h"
/*
* Structure which is element of stack, holds token and pointer to next token
*/
typedef struct stackElem
{
struct stackElem *nextTok;
tToken token;
int originalType;
elem_t *data;
bool expr;
} *stackElemPtr;
/*
* Structure, that holds top element and next element on stack
*/
typedef struct tokenStack
{
stackElemPtr topToken;
} tokenStack;
/*
* Function which initializes stack
*/
void stack_init(tokenStack **stack);
/*
* Function pushes tokPush on the top of the stack
*/
void stack_push(tokenStack *stack, tToken tokPush);
/*
* Function which pops the token on the top of the stack
*/
void stack_pop(tokenStack *stack);
/*
* Function which empties the stack
*/
int stack_count(tokenStack **stack);
/*
* Function which free's the stack
*/
void stack_free(tokenStack **stack);
#endif //IFJ_BHKM_STACK_H