-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.c
More file actions
37 lines (30 loc) · 784 Bytes
/
main.c
File metadata and controls
37 lines (30 loc) · 784 Bytes
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
#include <stdio.h>
#include <stdlib.h>
#include "9cc.h"
Token tokens[1000];
int main(int argc, char **argv)
{
if (argc != 2)
{
fprintf(stderr, "引数の個数が正しくありません\n");
return 1;
}
char *p = argv[1];
int token_length = tokenize(p);
if (token_length == 0)
{
fprintf(stderr, "No token found");
return 1;
}
Token *ptr = tokens;
Token *token_end = tokens + token_length;
printf(".intel_syntax noprefix\n");
for (; ptr < token_end;)
{
Function *func = parseFunction(&ptr, token_end);
// fprintf(stderr, "parse function %s done\n", func->name);
CodegenFunction(func);
// fprintf(stderr, "function %s done\n", func->name);
}
return 0;
}