-
Notifications
You must be signed in to change notification settings - Fork 7
/
rpn.h
47 lines (39 loc) · 976 Bytes
/
rpn.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
/*
* rpn - Mycroft <mycroft@datasphere.net>
*/
#define VERSION 0.51
#define MAXSIZE 10
#define DEFBASE 10
#define BASECHAR '#'
#define ERR_DIVBYZERO "Division by zero."
#define ERR_DOMAIN "Argument is outside of function domain."
#define ERR_UNKNOWNCMD "Unknown command."
#define ERR_ARGC "Too few arguments."
struct metastack {
struct object *t;
struct object *b;
struct metastack *n;
size_t d;
};
struct object {
double num;
struct object *prev, *next;
};
struct command {
char *name;
long numargs;
void (*function)(void);
};
struct macro {
char *name, *operation;
struct macro *prev, *next;
};
void addcommand(struct command *c);
struct object *top(void);
char *findmacro(char *);
double popnum(void);
struct object *pop(void);
struct command *findcmd(char *);
void popobj(struct object *), pushnum(double), init_macros(void), error(char *);
unsigned countstack(void);
double peeknthnum(unsigned off);