aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
blob: 1efc7975f075720b9b39bf5499a2443a48a4fee9 (plain) (blame)
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
#include <stdio.h>
#include <stdlib.h>

#include "include/util.h"
#include "include/token.h"
#include "include/lexer.h"
#include "include/source.h"

int main(int argc, char* argv[]) {
   char*    source;
   lexer_t* lexer;
   int      in_file;

   source = source_get(argv[1]); 

   lexer = lexer_init(source);
   log_inf("lexer created");

   log_inf("BEGIN INPUT");
   log_raw(lexer->content);
   log_inf("END INPUT");

   in_file = 1;

   while (in_file) {
      token_t* token;
      char* type;

      token = lexer_get_next_token(lexer);
      type = token_get_type(token->type);
      
      log_inf("token type: [%s]\t\ttoken value: [%s]", type, token->value);
      (token->type == TOKEN_EOF) && (in_file = 0);

      token_destroy(token);
   }

   // clean up
   lexer_destroy(lexer);
   //fclose(fsource);
   free(source);

   log_inf("source file closed");

   return 0;
}