summaryrefslogtreecommitdiff
path: root/src/voidc.cc
blob: bba510fbe34d48a8d8294a940b1e4ef00855775f (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
#include <cstdio>
#include <cstdlib>

#include "common.cc"
#include "memory.cc"
#include "source.cc"
#include "tokenizer.cc"

static const char* SOURCE = R"(
#include <stdlib.h>

int main() {
  return EXIT_FAILURE;
}

)";

static const char* SOURCE_FILE = "source.c";

int main() {
  String source(SOURCE);
  String file(SOURCE_FILE);

  Buffer_Stack stack{};
  Buffer* buffer = nullptr;

  bool ret = buffer_init(heap_allocator(), &source, &file, &buffer);
  if (!ret) return EXIT_FAILURE;

  buffer_stack_push(&stack, buffer);

  Tokenizer tokenizer(&stack);

  Token token = {};
  while(tokenizer_next(&tokenizer, &token)) 
    fprintf(stdout, "Token(kind: %d, text: %.*s)\n", token.kind, (int)token.text.length, token.text.ptr);
  

}