-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstack.h
More file actions
65 lines (50 loc) · 1.13 KB
/
stack.h
File metadata and controls
65 lines (50 loc) · 1.13 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
62
63
64
65
#ifndef _STACK_H
#define _STACK_H
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include <ctype.h>
#include "eval.h"
typedef enum {
T_NUMBER,
T_OPERATOR,
T_VARIABLE,
} T_TYPE;
typedef struct token
{
union value
{
double num; //T_NUMBER
operator* op; //T_OPERATOR
char var; //T_VARIABLE
}value;
T_TYPE type;
}token;
typedef struct tokenNode
{
token _token;
struct tokenNode* next;
}tokenNode;
typedef enum {NOT_OK, OK} Tboolean;
typedef struct
{
tokenNode *tokenTop;
int top;
}tokenStack;
typedef struct tokenQueue
{
tokenNode *head, *tail;
int size;
}tokenQueue;
void initialize_queue(tokenQueue*);
void enqueue(tokenQueue*,token token);
Tboolean dequeue(tokenQueue* queue,token *token);
void print_queue(tokenQueue* queue);
void free_queue(tokenQueue* queue);
int convert_to_array(token* tokens,tokenQueue* queue);
void initialize_stack (tokenStack *Pstack);
void push (tokenStack *Pstack, token item);
Tboolean pop (tokenStack *Pstack, token *Pitem);
Tboolean peek(tokenStack *PStack, token* token);
void free_stack (tokenStack *Pstack);
#endif