Files
compilateur-l/src/compilateur-l.c
Xawirses 634440714c Ajout analyse sémantique :
- Verif declaration var & tab
- Verif appel var
2016-03-08 15:57:03 +01:00

52 lines
1.0 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include "analyseur_lexical.h"
#include "analyseur_syntaxyque.h"
#include "affiche_arbre_abstrait.h"
#include "affiche_table_symbole.h"
#include "symboles.h"
extern int uniteCourante;
extern int afficheSyntaxyque;
char yytext[100];
FILE *yyin;
int main(int argc, char **argv) {
yyin = fopen(argv[2], "r");
if(argc < 3 && yyin == NULL){
fprintf(stderr, "impossible d'ouvrir le fichier %s\n", argv[2]);
exit(1);
}
initialise_premiers();
initialise_suivants();
if (!strcmp(argv[1], "-l")) {
test_yylex_internal(yyin);
} else if (!strcmp(argv[1], "-s")) {
afficheSyntaxyque = 1;
uniteCourante = yylex();
programme();
} else if (!strcmp(argv[1], "-a")) {
uniteCourante = yylex();
n_prog *p = programme();
affiche_n_prog(p);
} else if (!strcmp(argv[1], "-t")) {
uniteCourante = yylex();
n_prog *p = programme();
affiche_t_table(p);
} else {
fprintf(stderr, "option Inconue");
exit(1);
}
uniteCourante = yylex();
if(uniteCourante != FIN) {
printf("Erreur EOF");
}
return 0;
}