-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperations.h
More file actions
58 lines (47 loc) · 1.05 KB
/
operations.h
File metadata and controls
58 lines (47 loc) · 1.05 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
#ifndef OPERATIONS_H
#define OPERATIONS_H
#include <complex.h>
#include <stdbool.h>
#include "sstack.h"
#include "cstack.h"
#define OP_COUNT 32
#define OP_NAME_SIZE 10
#define CONSTANT_NAME_SIZE 10
enum op_types {
UNARY_OP_TYPE,
BINARY_OP_TYPE
};
enum op_priorities
{
NOT_OP_PRIORITY = -1,
BRACKETS_PRIORITY,
PLUSMINUS_PRIORITY,
MULTIPLYDIVIDE_PRIORITY,
BINARY_FUNC_PRIORITY,
UNARY_FUNC_PRIORITY
};
typedef struct binary_op {
char name[OP_NAME_SIZE];
_Dcomplex(*func)(_Dcomplex, _Dcomplex);
int priority;
bool is_bracket;
} binary_op;
typedef struct unary_op {
char name[OP_NAME_SIZE];
_Dcomplex(*func)(_Dcomplex);
int priority;
bool is_bracket;
} unary_op;
typedef struct constant {
char name[CONSTANT_NAME_SIZE];
_Dcomplex value;
} constant;
bool get_const(const char* name, _Dcomplex* buffer);
int get_priority(const char* op);
bool is_bracket_op(const char* op);
bool is_bracket_op_c(const char op);
bool is_op(const char* op);
bool is_op_c(const char op);
bool is_unary(const char* op);
bool process_op(cstack* st, const char* op);
#endif