forked from xjuric29/ifj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokstack.h
51 lines (40 loc) · 1.12 KB
/
tokstack.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
/**
* @file stacktok.h
* @author Jiri Furda (xfurda00)
* @brief Header file for token stack
* @todo
*/
#ifndef TOKSTACK_H
#define TOKSTACK_H
// --- Includes ---
// Libraries
#include <stdio.h>
// Module dependency
#include "scanner.h" // token_t structure
#include "parser.h" // Token init and free
// --- Constants ---
#define NO_STACK -1 /// Top index for not inicialised stack
#define TOKSTACK_MAX 420 /// @todo Find optial value
#define SUCCESS 0
#define FAIL 1
#define TRUE 1
#define FALSE 0
#define TOK_FAIL TOK_endOfFile /// Representing error return with type tokenType_t
#define TOK_BOOLEAN 100 /// Boolean data type for tokStack
// --- Strucutres ---
typedef struct {
tokenType_t tokArr[TOKSTACK_MAX];
int top;
} tokStack_t;
// --- Functions ---
int tokStack_Init(tokStack_t *stack);
int tokStack_Push(tokStack_t *stack, tokenType_t token);
tokenType_t tokStack_Pop(tokStack_t *stack);
tokenType_t tokStack_Top(tokStack_t *stack);
int tokStack_Empty(tokStack_t *stack);
int tokStack_Full(tokStack_t *stack);
void tokStack_Error(char* msg);
#ifdef TOKSTACKDEBUG
void tokStack_Info(tokStack_t *stack);
#endif
#endif