-
Notifications
You must be signed in to change notification settings - Fork 1
/
asmer.cpp
45 lines (37 loc) · 854 Bytes
/
asmer.cpp
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
#include "src/asm_parser/Parser.h"
#include <string>
#include <cstring>
#include <stdio.h>
#include "asmer.h"
using namespace std;
using namespace asmer;
bool showAss = false;
int print_help () {
fprintf(stderr,
"usage: ./asmer [options] file.s 可用的选项:\n"
" -s 翻译汇编为机器指令,并生成可重定向elf二进制文件\n"
" -print 打印token\n"
);
return 0;
}
/**
* @param argv
*/
int asmgen(char* argv[],bool run = false)
{
return 0;
}
int print_ast(char* argv[]){
Parser p(argv[2]);
p.printToken();
return 0;
}
int main(int argc,char* argv[])
{
if (argc < 3) return print_help();
if (!strcmp(argv[1], "-s"))
return asmgen(argv,false);
if (!strcmp(argv[1], "-print"))
return print_ast(argv);
return print_help();
}