Browse Source

Update makefile

Simard Yohan 2 years ago
parent
commit
ef75bd33b8
3 changed files with 11 additions and 9 deletions
  1. 2
    2
      Makefile
  2. 7
    2
      as.y
  3. 2
    5
      test.c

+ 2
- 2
Makefile View File

@@ -1,5 +1,5 @@
1 1
 LEX = flex
2
-YACC = bison -d -v
2
+YACC = bison -d
3 3
 CC = gcc
4 4
 
5 5
 all: compilateur test
@@ -21,4 +21,4 @@ lex.yy.c: al.lex
21 21
 build: compilateur
22 22
 
23 23
 clean:
24
-	rm as.tab.c as.tab.h lex.yy.c compilateur as.output
24
+	rm -f as.tab.c as.tab.h lex.yy.c compilateur as.output test

+ 7
- 2
as.y View File

@@ -185,11 +185,16 @@ void yyerror(char const* err) {
185 185
     exit(1);
186 186
 }
187 187
 
188
-void main(void) {
188
+void main(int argc, char *argv[]) {
189
+    char *output_filename = "output.asm";
190
+    if (argc >= 2) {
191
+        output_filename = argv[1];
192
+    }
189 193
     init();
190 194
 	yyparse();
191 195
 	print_table(&symbol_table);
192
-    FILE *f = fopen("instruction_table.txt", "w+");
196
+    FILE *f = fopen(output_filename, "w+");
193 197
 	write_instruction_table(&instruction_table, f);
194 198
     fclose(f);
195 199
 }
200
+

+ 2
- 5
test.c View File

@@ -2,11 +2,8 @@ int main(){
2 2
     int x, y, z;
3 3
     const PL5_op, b, c;
4 4
     x = 2;
5
-    printf(x);
5
+
6 6
     y = 3 + 3 + x;
7
-    if (x == 2) {
8
-        printf(x);
9
-        printf(y);
10
-    }
7
+
11 8
     x = 3;
12 9
 }

Loading…
Cancel
Save