summaryrefslogtreecommitdiff
path: root/src/main.c
blob: 7271728e58187a1df95a953a03b5382a5a463061 (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
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
91
92
93
94
95
96
#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) {
  /* DONE: TEST LEXER */
  /* lexer_t *lexer = init_lexer("'(fasd asdf)"); */
  /* token_t *t = lexer_collect_next(lexer); */
  /* while (t != NULL) { */
  /*   printf("%d: %s\n", t->type, t->value); */
  /*   t = lexer_collect_next(lexer); */
  /* } */

  /* TODO: TEST REPL POSSIBILITY */
  /* 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"); */
  /*   } */
  /* } */

  /* DONE: TEST PARSER, VISITOR, PRINTER (self evaluating types) */
  /* lexer_t *lexer = init_lexer("\"hello world\""); */
  /* parser_t *parser = init_parser(lexer); */
  /* visitor_t *visitor = init_visitor(parser); */
  /* ast_t *root = eval(visitor); */
  /* print_root(root); */

  /* DONE: TEST PARSING LISTS */
  /* lexer_t *lexer = init_lexer("(hello (world #f))"); */
  /* parser_t *parser = init_parser(lexer); */
  /* ast_t *root = parse_all(parser); */
  /* ast_t *list = root->subnodes[0]; */
  /* ast_t *hello = list->car; */
  /* ast_t *inner = list->cdr->car; */
  /* ast_t *world = inner->car; */
  /* ast_t *fal = inner->cdr->car; */
  /* printf("%s\n", hello->string_value); */
  /* printf("%s\n", world->string_value); */
  /* printf("%d\n", fal->bool_value); */

  /* DONE: TEST PARSING FUNCTIONS */
  /* lexer_t *lexer = init_lexer("(lambda (x) (y))"); */
  /* parser_t *parser = init_parser(lexer); */
  /* ast_t *root = parse_all(parser); */
  /* ast_t *func = root->subnodes[0]; */
  /* ast_t *args = func->car; */
  /* ast_t *expr = func->cdr; */
  /* printf("%d\t%s\t\%s\n", func->type, args->car->string_value, */
  /*        expr->car->string_value); */

  /* DONE: TEST PARSING QUOTE */
  /* lexer_t *lexer = init_lexer("'(hello)"); */
  /* parser_t *parser = init_parser(lexer); */
  /* ast_t *root = parse_all(parser); */
  /* ast_t *quote = root->subnodes[0]; */
  /* printf("%s\n", quote->cdr->car->car->string_value); */

  /* DONE: TEST PARSING AND STORING BINDINGS */
  /* lexer_t *lexer = init_lexer("(bind x \"hello world\")"); */
  /* parser_t *parser = init_parser(lexer); */
  /* ast_t *root = parse_all(parser); */
  /* if (hash_table_exists(parser->symbol_table, "x")) { */
  /*   printf("YES!\n"); */
  /*   ast_t *str = hash_table_get(parser->symbol_table, "x"); */
  /*   printf("%s\n", str->string_value); */
  /* } */

  /* TODO: TEST HASH TABLE COLLISIONS */
  /* TODO: TEST LIST EVALUATION */
  return 0;
}