blob: 38a4269b667b6075dd43241ca53834440fd94e36 (
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
56
57
58
59
60
61
|
#include "include/main.h"
#include "include/doer.h"
/* FIXME: Segfaults ~30% of the time. No idea why. Thx future self <3. */
int main(int argc, char* argv[]) {
char* src;
pp_t* pp;
lexer_t* lexer;
parser_t* parser;
/* Get source. */
src = source_get(argv[1]);
LOG_DBGF("Source: %s", src);
/* Create pre-processor. */
pp = pp_init(src);
LOG_DBG("Preprocessor created.");
/* Pre-process source. */
pp_run(pp);
free(src);
src = pp->psrc;
LOG_DBGF("pre-processed source: %s", pp->psrc);
/* destroy pre-processor */
pp_destroy(pp);
LOG_DBG("preprocessor ran");
/* create lexer */
lexer = lexer_init(src);
LOG_DBG("lexer created");
/* run lexer */
lexer_run(lexer);
LOG_DBG("lexer ran");
/* Print the lexer's tokens. */
token_print(lexer->tokenl);
/* Create the parser from the lexer's tokens. */
parser = parser_init(lexer->tokenl);
parser_run(parser);
#ifdef DBG
tree_print(parser->tree, 0);
#endif
doer_t* doer = doer_init(parser->tree);
doer_do_block(doer);
target_print(doer->targets);
sudden_death:
/* Clean up. */
doer_destroy(doer);
token_destroy(lexer->tokenl);
lexer_destroy(lexer);
tree_destroy(parser->tree);
parser_destroy(parser);
free(src);
return 0;
}
|