Ajout analyse sémantique :

- Verif declaration var & tab
- Verif appel var
This commit is contained in:
2016-03-08 15:57:03 +01:00
parent 2d23d0dc3a
commit 634440714c
10 changed files with 566 additions and 45 deletions

View File

@@ -4,6 +4,32 @@
#include "syntabs.h"
void affiche_n_prog(n_prog *n);
void affiche_l_instr(n_l_instr *n);
void affiche_instr(n_instr *n);
void affiche_instr_si(n_instr *n);
void affiche_instr_tantque(n_instr *n);
void affiche_instr_faire(n_instr *n); /* MODIFIE POUR EVAL */
void affiche_instr_pour(n_instr *n); /* MODIFIE POUR EVAL */
void affiche_instr_affect(n_instr *n);
void affiche_instr_appel(n_instr *n);
void affiche_instr_retour(n_instr *n);
void affiche_instr_ecrire(n_instr *n);
void affiche_l_exp(n_l_exp *n);
void affiche_exp(n_exp *n);
void affiche_varExp(n_exp *n);
void affiche_opExp(n_exp *n);
void affiche_intExp(n_exp *n);
void affiche_lireExp(n_exp *n);
void affiche_appelExp(n_exp *n);
void affiche_l_dec(n_l_dec *n);
void affiche_dec(n_dec *n);
void affiche_foncDec(n_dec *n);
void affiche_varDec(n_dec *n);
void affiche_tabDec(n_dec *n);
void affiche_var(n_var *n);
void affiche_var_simple(n_var *n);
void affiche_var_indicee(n_var *n);
void affiche_appel(n_appel *n);
#endif

View File

@@ -0,0 +1,36 @@
#ifndef __affiche_ARBRE_ABSTRAIT__
#define __affiche_ARBRE_ABSTRAIT__
#include "syntabs.h"
#include "dico.h"
void affiche_t_table(n_prog *n);
void affiche_t_l_instr(n_l_instr *n);
void affiche_t_instr(n_instr *n);
void affiche_t_instr_si(n_instr *n);
void affiche_t_instr_tantque(n_instr *n);
void affiche_t_instr_faire(n_instr *n);
void affiche_t_instr_pour(n_instr *n);
void affiche_t_instr_affect(n_instr *n);
void affiche_t_instr_appel(n_instr *n);
void affiche_t_instr_retour(n_instr *n);
void affiche_t_instr_ecrire(n_instr *n);
void affiche_t_l_exp(n_l_exp *n);
void affiche_t_exp(n_exp *n);
void affiche_t_varExp(n_exp *n);
void affiche_t_opExp(n_exp *n);
void affiche_t_intExp(n_exp *n);
void affiche_t_lireExp(n_exp *n);
void affiche_t_appelExp(n_exp *n);
void affiche_t_l_dec(n_l_dec *n);
void affiche_t_dec(n_dec *n);
void affiche_t_foncDec(n_dec *n);
void affiche_t_varDec(n_dec *n);
void affiche_t_tabDec(n_dec *n);
void affiche_t_var(n_var *n);
void affiche_t_var_simple(n_var *n);
void affiche_t_var_indicee(n_var *n);
void affiche_t_appel(n_appel *n);
#endif

47
header/dico.h Normal file
View File

@@ -0,0 +1,47 @@
#ifndef __DICO__
#define __DICO__
#define _GNU_SOURCE 1
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "syntabs.h"
#define maxDico 100
#define C_VARIABLE_GLOBALE 1
#define C_VARIABLE_LOCALE 2
#define C_ARGUMENT 3
#define T_ENTIER 1
#define T_TABLEAU_ENTIER 2
#define T_FONCTION 3
typedef struct {
char *identif;
int classe; // portée
int type;
int adresse;
int complement; // taille d'un tableau, nombre d'arguments d'une fonction
} desc_identif;
typedef struct {
desc_identif tab[maxDico];
int base;
int sommet;
} dico_;
void entreeFonction(void);
void sortieFonction(void);
int ajouteIdentificateur(char *identif, int classe, int type, int adresse, int complement);
int rechercheExecutable(char *identif);
int rechercheDeclarative(char *identif);
void affiche_dico(void);
dico_ dico;
extern int contexte;
extern int adresseGlobalCourante;
extern int adresseLocaleCourante;
extern int adresseArgumentCourant;
#endif