blob: 2284444ff3859d47831c09db56d99f6dded048f2 (
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
47
48
49
50
51
52
53
54
55
|
#include <stdio.h>
#include <stdlib.h>
#include "include/util.h"
#include "include/hlkt.h"
#include "include/source.h"
#include "include/token.h"
#include "include/pp.h"
#include "include/lexer.h"
int main(int argc, char* argv[]) {
char* src; /* the source "code" */
pp_t* pp;
lexer_t* lexer;
/* get source */
src = source_get(argv[1]);
HLKT_ASS(src);
log_dbg("source gotten");
log_inf("source: %s", src);
/* create pre-processor */
pp = pp_init(src);
HLKT_ASS(pp);
log_dbg("preprocessor created");
/* pre-process source */
pp_run(pp);
free(src);
src = pp->psrc;
log_inf("pre-processed source: %s", pp->psrc);
/* destroy pre-processor */
pp_destroy(pp);
HLKT_ASS(src);
log_dbg("preprocessor ran");
/* create lexer */
lexer = lexer_init(src);
HLKT_ASS(lexer);
HLKT_ASS(lexer->src == src);
log_dbg("lexer created");
/* run lexer */
lexer_run(lexer);
log_dbg("lexer ran");
/* clean up lexer stuff */
if (lexer->tokenl) { token_destroy(lexer->tokenl); } /* temp until parser eats tokens */
lexer_destroy(lexer);
free(src);
HLKT_LOG();
return 0;
}
|