-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
90 lines (72 loc) · 1.1 KB
/
main.cpp
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* Eigenmath by G. Weigt
The starting point for a symbolic computation is in run.cpp
Input is scanned in scan.cpp
Expression evaluation is done in eval.cpp
Output is formatted in display.cpp
*/
#include "defs.h"
#define BUFLEN 100000
static char buf[BUFLEN];
int
main(int argc, char *argv[])
{
int i;
FILE *f;
for (i = 1; i < argc; i++) {
f = fopen(argv[i], "r");
if (f == NULL) {
printf("cannot open %s\n", argv[i]);
exit(1);
}
if (fread(buf, BUFLEN, 1, f) == 0) {
fclose(f);
run(buf);
}
}
for (;;) {
printf("> ");
if (fgets(buf, BUFLEN, stdin) != NULL)
run(buf);
}
}
void
clear_term()
{
}
extern void eval_print(void);
void
eval_display(void)
{
eval_print();
}
void
printstr(const char *s)
{
while (*s)
printchar(*s++);
}
extern int test_flag;
#define OUTBUFLEN 10000
char out_buf[OUTBUFLEN + 1];
int out_count;
void
printchar(int c)
{
if (test_flag && out_count < OUTBUFLEN)
out_buf[out_count++] = c;
fputc(c, stdout);
}
void
printchar_nowrap(int c)
{
printchar(c);
}
void
eval_draw(void)
{
push(symbol(NIL));
}
void
eval_sample(void)
{
}