-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
27 lines (24 loc) · 669 Bytes
/
Copy pathmain.c
File metadata and controls
27 lines (24 loc) · 669 Bytes
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
#include "monkey/repl.h"
#include "monkey/stream.h"
#include "monkey/user.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, const char* argv[]) {
(void)argc;
(void)argv;
char* user = CurrentUser();
if (user == NULL) {
(void)fprintf(stderr, "Could not get current user.\n");
return EXIT_FAILURE;
}
printf("Hello %s! This is the Monkey programming language!\n", user);
free(user);
printf("Feel free to type in commands\n");
Stream* reader = StreamFromFile(stdin);
Stream* writer = StreamFromFile(stdout);
MONKEY_REPL(.reader = reader, .writer = writer);
CloseStream(reader);
CloseStream(writer);
return EXIT_SUCCESS;
}