blob: ad9036ceb162c3b5e45f8b28ac071c6ebfa6321e (
plain)
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
|
#include "getln.h"
#include "sloth.h"
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
(void)argc, (void)argv;
/* Initialize sloth. */
Sloth *const sloth = calloc(1, sizeof(Sloth));
SlothError err;
if (sloth == NULL)
return 1;
/* Read stdin line by line until exhaustion. */
char *line = NULL;
while ((line = getln(stdin)) != NULL) {
err = sloth_push(sloth, line[0]);
if (err != NULL) {
fprintf(stderr, "%s\n", err);
break;
}
sloth_inspect_stack(sloth);
free(line);
}
/* Free everything. */
getln_cleanup();
sloth_deinit(sloth);
free(sloth);
return 0;
}
|