-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmicro.c
More file actions
executable file
·52 lines (44 loc) · 1.54 KB
/
micro.c
File metadata and controls
executable file
·52 lines (44 loc) · 1.54 KB
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
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include "headers/micro.h"
#include "headers/parser.h"
FILE * in;
FILE * out;
RegTS TS[1000] = { {"begin", BEGIN}, {"end", END}, {"read", READ}, {"write", WRITE},{"scaneof", SCANEOF}, {"$", 99} };
char token_buffer[MAXIDLEN];
TOKEN token;
int flagToken = 0;
int main(int argc, char * argv[])
{
printf("\n\n*******************COMPILADOR DE MICRO*******************\n\n");
int l = strlen(argv[1]);
if ( argc == 1 ){
printf("Error. Ingresar el nombre del archivo fuente y el nombre del archivo de salida\n");
return -1;
}
if ( argv[1][l-1] != 'm' || argv[1][l-2] != '.' ){
printf("Error. El archivo fuente debe finalizar con \".m\"\n");
return -1;
}
if ( (in = fopen(argv[1], "r") ) == NULL ){
printf("No se pudo abrir archivo fuente\n");
return -1;
}
out = fopen("bin/salida.micro", "w");
/* -------------- Iniciamos el proceso de compilacion: -------------- */
system_goal();
/* -------------- Terminado el proceso, cerramos los archivos: -------------- */
fclose(in);
fclose(out);
system("gcc -o Ensamblador/Traductor Ensamblador/ensamblador.c -w");
system("./Ensamblador/Traductor");
system("nasm -f elf bin/salida.asm");
system("ld -m elf_i386 bin/salida.o -o bin/salida");
printf("\n\n*******************EJECUTANDO ENSAMBLADOR*******************\n\n");
system("./bin/salida");
printf("\n\n");
return 0;
}