forked from dannydulai/rpn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpn.h
53 lines (44 loc) · 1.04 KB
/
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
48
49
50
51
52
#include "linenoise.h"
#define VERSION 0.69
#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;
struct object *next;
};
struct command {
char *name;
long numargs;
void (*function)(void);
};
struct macro {
char *name;
char *operation;
struct macro *prev;
struct macro *next;
};
void addcommand(struct command *c);
void completion(const char *, linenoiseCompletions *);
unsigned countstack(void);
void error(char *);
struct command *findcmd(char *);
char *findmacro(char *);
void init_macros(void);
double peeknthnum(unsigned off);
struct object *pop(void);
double popnum(void);
void popobj(struct object *);
void pushnum(double);
struct object *top(void);