blob: 7da03dc90a0f611e6206c8fe606b867f79417807 (
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
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
|
#define _GNU_SOURCE
#include "./include/ast.h"
#include "./include/hash_table.h"
#include "./include/lexer.h"
#include "./include/parser.h"
#include "./include/print.h"
#include "./include/stack.h"
#include "./include/token.h"
#include "./include/visitor.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv) {
/* Test Lexer */
/* lexer_t *lexer = init_lexer("'(fasd \"aaaaaaaa\" 4)"); */
/* token_t *t = lexer_collect_next(lexer); */
/* while (t != NULL) { */
/* printf("%d: %s\n", t->type, t->value); */
/* t = lexer_collect_next(lexer); */
/* } */
/* printf("Welcome to the NXS REPL.\n"); */
/* char *buf = malloc(2); */
/* size_t size = 2; */
/* lexer_t *lexer; */
/* lexer = init_lexer("a"); */
/* token_t *t; */
/* while (true) { */
/* printf("> "); */
/* fflush(stdout); */
/* getline(&buf, &size, stdin); */
/* strcat(buf, "\0"); */
/* lexer_reset(lexer, buf); */
/* t = lexer_collect_next(lexer); */
/* while (!lexer->finished) { */
/* printf("%d\t%s\n", t->type, t->value); */
/* t = lexer_collect_next(lexer); */
/* printf("lmao\n"); */
/* } */
/* } */
/* TEST PARSER, VISITOR, PRINTER */
lexer_t *lexer = init_lexer("\"hello world\"");
parser_t *parser = init_parser(lexer);
ast_t *root = parse_expr(parser);
visitor_t *v = init_visitor(root);
ast_t *res = eval_expr(v, root);
print(res);
return 0;
}
|