Update makefile
This commit is contained in:
parent
e3ea8ee709
commit
ef75bd33b8
3 changed files with 11 additions and 9 deletions
4
Makefile
4
Makefile
|
@ -1,5 +1,5 @@
|
||||||
LEX = flex
|
LEX = flex
|
||||||
YACC = bison -d -v
|
YACC = bison -d
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
all: compilateur test
|
all: compilateur test
|
||||||
|
@ -21,4 +21,4 @@ lex.yy.c: al.lex
|
||||||
build: compilateur
|
build: compilateur
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm as.tab.c as.tab.h lex.yy.c compilateur as.output
|
rm -f as.tab.c as.tab.h lex.yy.c compilateur as.output test
|
||||||
|
|
9
as.y
9
as.y
|
@ -185,11 +185,16 @@ void yyerror(char const* err) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void) {
|
void main(int argc, char *argv[]) {
|
||||||
|
char *output_filename = "output.asm";
|
||||||
|
if (argc >= 2) {
|
||||||
|
output_filename = argv[1];
|
||||||
|
}
|
||||||
init();
|
init();
|
||||||
yyparse();
|
yyparse();
|
||||||
print_table(&symbol_table);
|
print_table(&symbol_table);
|
||||||
FILE *f = fopen("instruction_table.txt", "w+");
|
FILE *f = fopen(output_filename, "w+");
|
||||||
write_instruction_table(&instruction_table, f);
|
write_instruction_table(&instruction_table, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
test.c
7
test.c
|
@ -2,11 +2,8 @@ int main(){
|
||||||
int x, y, z;
|
int x, y, z;
|
||||||
const PL5_op, b, c;
|
const PL5_op, b, c;
|
||||||
x = 2;
|
x = 2;
|
||||||
printf(x);
|
|
||||||
y = 3 + 3 + x;
|
y = 3 + 3 + x;
|
||||||
if (x == 2) {
|
|
||||||
printf(x);
|
|
||||||
printf(y);
|
|
||||||
}
|
|
||||||
x = 3;
|
x = 3;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue