fuck that shit
This commit is contained in:
@@ -44,28 +44,32 @@ void syntaxErrorMsg( const char * msg )
|
||||
n_prog *programme() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_l_dec *herite_var;
|
||||
n_l_dec *herite_func;
|
||||
n_l_dec *herite_var = NULL;
|
||||
n_l_dec *herite_func = NULL;
|
||||
n_prog *sreturn;
|
||||
|
||||
if( !est_premier( _optDecVariables_, uniteCourante ) && !est_premier( _listeDecFonctions_, uniteCourante ) && !est_suivant( _listeDecFonctions_, uniteCourante )) {
|
||||
if( !est_premier( _optDecVariables_, uniteCourante )
|
||||
&& !est_premier( _listeDecFonctions_, uniteCourante )
|
||||
&& !est_suivant( _listeDecFonctions_, uniteCourante )) {
|
||||
syntaxError();
|
||||
} else {
|
||||
herite_var = optDecVariables();
|
||||
herite_func = listeDecFonctions();
|
||||
sreturn = cree_n_prog(herite_var, herite_func);
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
sreturn = cree_n_prog(herite_var, herite_func);
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void optDecVariables() {
|
||||
n_l_dec *optDecVariables() {
|
||||
n_l_dec *sreturn = NULL;
|
||||
|
||||
openSection( __func__ );
|
||||
|
||||
|
||||
if( est_premier( _listeDecVariables_, uniteCourante ) )
|
||||
{
|
||||
listeDecVariables();
|
||||
sreturn = listeDecVariables();
|
||||
|
||||
if( uniteCourante == POINT_VIRGULE ) {
|
||||
elementConsome();
|
||||
@@ -76,51 +80,70 @@ void optDecVariables() {
|
||||
} else if ( !est_suivant( _optDecVariables_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void listeDecVariables() {
|
||||
n_l_dec *listeDecVariables() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_dec *herite_var = NULL;
|
||||
n_l_dec *herite_Liste_var = NULL;
|
||||
n_l_dec *sreturn = NULL;
|
||||
if( est_premier( _declarationVariable_, uniteCourante ) ) {
|
||||
declarationVariable();
|
||||
listeDecVariablesBis();
|
||||
herite_var = declarationVariable();
|
||||
herite_Liste_var = listeDecVariablesBis();
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
sreturn = cree_n_l_dec(herite_var, herite_Liste_var);
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void listeDecVariablesBis() {
|
||||
n_l_dec *listeDecVariablesBis() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_dec *herite_dec_var = NULL;
|
||||
n_l_dec *herite_liste_var = NULL;
|
||||
n_l_dec *sreturn = NULL;
|
||||
if( uniteCourante == VIRGULE ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
declarationVariable();
|
||||
listeDecVariablesBis();
|
||||
herite_dec_var = declarationVariable();
|
||||
herite_liste_var = listeDecVariablesBis();
|
||||
sreturn = cree_n_l_dec(herite_dec_var, herite_liste_var);
|
||||
} else if( !est_suivant( _listeDecVariablesBis_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void declarationVariable() {
|
||||
n_dec *declarationVariable() {
|
||||
openSection( __func__ );
|
||||
|
||||
char *name = NULL;
|
||||
n_dec *sreturn = NULL;
|
||||
int taille = 0;
|
||||
|
||||
if( uniteCourante == ENTIER ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
if( uniteCourante == ID_VAR ) {
|
||||
name = duplique_chaine(yytext);
|
||||
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
taille = optTailleTableau();
|
||||
if (taille == 0){
|
||||
|
||||
sreturn = cree_n_dec_var(name);
|
||||
}
|
||||
else
|
||||
sreturn = cree_n_dec_tab(name, taille);
|
||||
|
||||
optTailleTableau();
|
||||
} else {
|
||||
syntaxErrorMsg( "Un identificateur de variable été attendu" );
|
||||
}
|
||||
@@ -129,17 +152,19 @@ void declarationVariable() {
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void optTailleTableau() {
|
||||
int optTailleTableau() {
|
||||
openSection( __func__ );
|
||||
|
||||
int taille = 0;
|
||||
if( uniteCourante == CROCHET_OUVRANT ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
if( uniteCourante == NOMBRE ) {
|
||||
elementConsome();
|
||||
taille = atoi(yytext);
|
||||
uniteCourante = yylex();
|
||||
|
||||
if( uniteCourante == CROCHET_FERMANT ) {
|
||||
@@ -157,46 +182,59 @@ void optTailleTableau() {
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return taille;
|
||||
}
|
||||
|
||||
void listeDecFonctions() {
|
||||
n_l_dec *listeDecFonctions() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_dec *herite_dec = NULL;
|
||||
n_l_dec *herite_Liste_dec = NULL;
|
||||
n_l_dec *sreturn = NULL;
|
||||
if( est_premier( _declarationFonction_, uniteCourante ) || est_premier( _listeDecFonctions_, uniteCourante ) ) {
|
||||
declarationFonction();
|
||||
listeDecFonctions();
|
||||
herite_dec = declarationFonction();
|
||||
herite_Liste_dec =listeDecFonctions();
|
||||
sreturn = cree_n_l_dec (herite_dec, herite_Liste_dec);
|
||||
} else if( !est_suivant( _listeDecFonctions_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void declarationFonction() {
|
||||
n_dec * declarationFonction() {
|
||||
openSection( __func__ );
|
||||
|
||||
char *name;
|
||||
n_l_dec *param = NULL;
|
||||
n_l_dec *variables = NULL;
|
||||
n_instr *corps = NULL;
|
||||
n_dec *sreturn;
|
||||
if( uniteCourante == ID_FCT ) {
|
||||
name = duplique_chaine(yytext);
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
listeParam();
|
||||
optDecVariables();
|
||||
instructionBloc();
|
||||
param = listeParam();
|
||||
variables = optDecVariables();
|
||||
corps = instructionBloc();
|
||||
|
||||
} else {
|
||||
syntaxErrorMsg( "Un identificateur de fonction été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
|
||||
sreturn = cree_n_dec_fonc(name,param,variables,corps);
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void listeParam() {
|
||||
n_l_dec *listeParam() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_l_dec *sreturn = NULL;
|
||||
if( uniteCourante == PARENTHESE_OUVRANTE ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
optListeDecVariables();
|
||||
sreturn = optListeDecVariables();
|
||||
|
||||
if( uniteCourante == PARENTHESE_FERMANTE ) {
|
||||
elementConsome();
|
||||
@@ -209,59 +247,65 @@ void listeParam() {
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void optListeDecVariables() {
|
||||
n_l_dec *optListeDecVariables() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_l_dec *sreturn = NULL;
|
||||
if( est_premier( _listeDecVariables_, uniteCourante ) ) {
|
||||
listeDecVariables();
|
||||
sreturn = listeDecVariables();
|
||||
} else if( !est_suivant( _optListeDecVariables_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void instruction() {
|
||||
n_instr *instruction() {
|
||||
openSection( __func__ );
|
||||
n_instr *sreturn = NULL;
|
||||
|
||||
if( est_premier( _instructionAffect_, uniteCourante ) ) {
|
||||
instructionAffect();
|
||||
sreturn = instructionAffect();
|
||||
} else if( est_premier( _instructionBloc_, uniteCourante ) ) {
|
||||
instructionBloc();
|
||||
sreturn = instructionBloc();
|
||||
} else if( est_premier( _instructionSi_, uniteCourante ) ) {
|
||||
instructionSi();
|
||||
sreturn = instructionSi();
|
||||
} else if( est_premier( _instructionTantque_, uniteCourante ) ) {
|
||||
instructionTantque();
|
||||
sreturn = instructionTantque();
|
||||
} else if( est_premier( _instructionAppel_, uniteCourante ) ) {
|
||||
instructionAppel();
|
||||
sreturn = instructionAppel();
|
||||
} else if( est_premier( _instructionRetour_, uniteCourante ) ) {
|
||||
instructionRetour();
|
||||
sreturn = instructionRetour();
|
||||
} else if( est_premier( _instructionEcriture_, uniteCourante ) ) {
|
||||
instructionEcriture();
|
||||
sreturn = instructionEcriture();
|
||||
} else if( est_premier( _instructionPour_, uniteCourante ) ) {
|
||||
instructionPour();
|
||||
sreturn = instructionPour();
|
||||
} else if( est_premier( _instructionVide_, uniteCourante ) ) {
|
||||
instructionVide();
|
||||
sreturn = instructionVide();
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void instructionAffect() {
|
||||
n_instr *instructionAffect() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_instr *sreturn = NULL;
|
||||
n_var *herite_var = NULL;
|
||||
n_exp *herite_exp = NULL;
|
||||
if( est_premier( _var_, uniteCourante ) ) {
|
||||
var();
|
||||
|
||||
herite_var = var();
|
||||
|
||||
if( uniteCourante == EGAL ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
herite_exp = expression();
|
||||
|
||||
if( uniteCourante == POINT_VIRGULE ) {
|
||||
elementConsome();
|
||||
@@ -277,16 +321,21 @@ void instructionAffect() {
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
sreturn = cree_n_instr_affect(herite_var, herite_exp);
|
||||
return sreturn;
|
||||
|
||||
}
|
||||
|
||||
void instructionBloc() {
|
||||
n_instr *instructionBloc() {
|
||||
openSection( __func__ );
|
||||
n_instr *sreturn = NULL;
|
||||
n_l_instr *herite_list_inst = NULL;
|
||||
|
||||
if( uniteCourante == ACCOLADE_OUVRANTE ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
listeInstructions();
|
||||
herite_list_inst = listeInstructions();
|
||||
|
||||
if( uniteCourante == ACCOLADE_FERMANTE ) {
|
||||
elementConsome();
|
||||
@@ -299,36 +348,45 @@ void instructionBloc() {
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
sreturn = cree_n_instr_bloc(herite_list_inst);
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void listeInstructions() {
|
||||
n_l_instr *listeInstructions() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_instr *instru = NULL;
|
||||
n_l_instr *listeInstru = NULL;
|
||||
n_l_instr *sreturn = NULL;
|
||||
if( est_premier( _instruction_, uniteCourante ) || est_premier( _listeInstructions_, uniteCourante ) ) {
|
||||
instruction();
|
||||
listeInstructions();
|
||||
instru = instruction();
|
||||
listeInstru = listeInstructions();
|
||||
sreturn = cree_n_l_instr(instru, listeInstru);
|
||||
} else if( !est_suivant( _listeInstructions_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void instructionSi() {
|
||||
n_instr *instructionSi() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_instr *sreturn;
|
||||
n_exp *test = NULL;
|
||||
n_instr *alors = NULL;
|
||||
n_instr *sinon = NULL;
|
||||
if( uniteCourante == SI ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
test = expression();
|
||||
|
||||
if( uniteCourante == ALORS ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
instructionBloc();
|
||||
optSinon();
|
||||
alors = instructionBloc();
|
||||
sinon = optSinon();
|
||||
} else {
|
||||
syntaxErrorMsg( "'alors' été attendu" );
|
||||
}
|
||||
@@ -337,37 +395,43 @@ void instructionSi() {
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
sreturn = cree_n_instr_si(test, alors, sinon);
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void optSinon() {
|
||||
n_instr *optSinon() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_instr *sreturn;
|
||||
if( uniteCourante == SINON ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
instructionBloc();
|
||||
sreturn = instructionBloc();
|
||||
} else if( !est_suivant( _optSinon_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void instructionTantque() {
|
||||
n_instr *instructionTantque() {
|
||||
openSection( __func__ );
|
||||
n_instr *sreturn;
|
||||
n_exp *test;
|
||||
n_instr *faire;
|
||||
|
||||
if( uniteCourante == TANTQUE ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
test = expression();
|
||||
|
||||
if( uniteCourante == FAIRE ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
instructionBloc();
|
||||
faire =instructionBloc();
|
||||
} else {
|
||||
syntaxErrorMsg( "'faire' été attendu" );
|
||||
}
|
||||
@@ -375,14 +439,17 @@ void instructionTantque() {
|
||||
syntaxErrorMsg( "'tantque' été attendu" );
|
||||
}
|
||||
|
||||
sreturn = cree_n_instr_tantque(test, faire);
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void instructionAppel() {
|
||||
n_instr *instructionAppel() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_instr *sreturn;
|
||||
n_appel *app;
|
||||
if( est_premier( _instructionAppel_, uniteCourante ) ) {
|
||||
appelFct();
|
||||
app = appelFct();
|
||||
|
||||
if( uniteCourante == POINT_VIRGULE ) {
|
||||
elementConsome();
|
||||
@@ -394,17 +461,21 @@ void instructionAppel() {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
sreturn = cree_n_instr_appel(app);
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void instructionRetour() {
|
||||
n_instr *instructionRetour() {
|
||||
openSection( __func__ );
|
||||
n_instr *sreturn;
|
||||
n_exp *expr;
|
||||
|
||||
if( uniteCourante == RETOUR ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
expr = expression();
|
||||
|
||||
if( uniteCourante == POINT_VIRGULE ) {
|
||||
elementConsome();
|
||||
@@ -415,13 +486,16 @@ void instructionRetour() {
|
||||
} else {
|
||||
syntaxErrorMsg( "'retour' été attendu" );
|
||||
}
|
||||
sreturn = cree_n_instr_retour(expr);
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void instructionEcriture() {
|
||||
n_instr *instructionEcriture() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_instr *sreturn = NULL;
|
||||
n_exp *expr = NULL;
|
||||
if( uniteCourante == ECRIRE ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
@@ -430,7 +504,7 @@ void instructionEcriture() {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
expr = expression();
|
||||
|
||||
if( uniteCourante == PARENTHESE_FERMANTE ) {
|
||||
elementConsome();
|
||||
@@ -451,31 +525,37 @@ void instructionEcriture() {
|
||||
} else {
|
||||
syntaxErrorMsg( "'ecrire' été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
sreturn = cree_n_instr_ecrire(expr);
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void instructionPour() {
|
||||
n_instr *instructionPour() {
|
||||
openSection( __func__ );
|
||||
n_instr *init = NULL;
|
||||
n_exp *test = NULL;
|
||||
n_instr *incr = NULL;
|
||||
n_instr *faire = NULL;
|
||||
n_instr *sreturn = NULL;
|
||||
|
||||
if( uniteCourante == POUR ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
instructionAffect();
|
||||
expression();
|
||||
init = instructionAffect();
|
||||
test = expression();
|
||||
|
||||
if( uniteCourante == POINT_VIRGULE ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
instructionAffect();
|
||||
incr = instructionAffect();
|
||||
|
||||
if( uniteCourante == FAIRE ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
instructionBloc();
|
||||
faire = instructionBloc();
|
||||
|
||||
} else {
|
||||
syntaxErrorMsg( "'faire' été attendu" );
|
||||
@@ -488,138 +568,162 @@ void instructionPour() {
|
||||
syntaxErrorMsg( "'pour' été attendu" );
|
||||
}
|
||||
|
||||
sreturn = cree_n_instr_pour(init,test,incr,faire);
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void instructionVide() {
|
||||
n_instr *instructionVide() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_instr * sreturn = NULL;
|
||||
if( uniteCourante == POINT_VIRGULE ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
} else {
|
||||
syntaxErrorMsg( "';' été attendu" );
|
||||
}
|
||||
|
||||
sreturn = cree_n_instr_vide();
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void expression() {
|
||||
n_exp *expression() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_exp *herite_conj = NULL;
|
||||
n_exp *sreturn = NULL;
|
||||
if( est_premier( _conjonction_, uniteCourante ) ) {
|
||||
conjonction();
|
||||
expressionBis();
|
||||
herite_conj = conjonction();
|
||||
sreturn = expressionBis(herite_conj);
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void expressionBis() {
|
||||
n_exp *expressionBis(n_exp *herite) {
|
||||
openSection( __func__ );
|
||||
|
||||
n_exp *conj = NULL;
|
||||
n_exp *sreturn = herite;
|
||||
|
||||
if( uniteCourante == OU ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
conjonction();
|
||||
expressionBis();
|
||||
conj = conjonction();
|
||||
herite = cree_n_exp_op(ou, herite,conj);
|
||||
sreturn = expressionBis(herite);
|
||||
} else if( !est_suivant( _expressionBis_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void conjonction() {
|
||||
n_exp *conjonction() {
|
||||
n_exp *sreturn;
|
||||
n_exp *herite_neg = NULL;
|
||||
openSection( __func__ );
|
||||
|
||||
if( est_premier( _negation_, uniteCourante ) ) {
|
||||
negation();
|
||||
conjonctionBis();
|
||||
herite_neg = negation();
|
||||
sreturn = conjonctionBis(herite_neg);
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void conjonctionBis() {
|
||||
n_exp *conjonctionBis(n_exp *herite) {
|
||||
openSection( __func__ );
|
||||
|
||||
n_exp *sreturn = herite;
|
||||
n_exp *herite_neg = NULL;
|
||||
if( uniteCourante == ET ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
negation();
|
||||
conjonctionBis();
|
||||
herite_neg = negation();
|
||||
herite_neg = cree_n_exp_op(et, herite, herite_neg);
|
||||
sreturn = conjonctionBis(herite_neg);
|
||||
} else if( !est_suivant( _conjonctionBis_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void negation() {
|
||||
n_exp *negation() {
|
||||
n_exp *sreturn = NULL;
|
||||
n_exp *expression = NULL;
|
||||
openSection( __func__ );
|
||||
|
||||
if( uniteCourante == NON ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
comparaison();
|
||||
expression = comparaison();
|
||||
sreturn = cree_n_exp_op(non,expression,NULL);
|
||||
} else if (est_premier( _comparaison_, uniteCourante )) {
|
||||
comparaison();
|
||||
sreturn = comparaison();
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void comparaison() {
|
||||
n_exp *comparaison() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_exp *sreturn = NULL;
|
||||
n_exp *herite_exp = NULL;
|
||||
if( est_premier( _expression_, uniteCourante ) ) {
|
||||
expArith();
|
||||
comparaisonBis();
|
||||
herite_exp = expArith();
|
||||
sreturn = comparaisonBis(herite_exp);
|
||||
} else {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void comparaisonBis() {
|
||||
n_exp *comparaisonBis(n_exp *herite) {
|
||||
openSection( __func__ );
|
||||
|
||||
n_exp *sreturn = herite;
|
||||
n_exp *herite_exp = NULL;
|
||||
if( uniteCourante == EGAL) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
expArith();
|
||||
comparaisonBis();
|
||||
herite_exp = expArith();
|
||||
herite_exp = cree_n_exp_op(egal,herite,herite_exp);
|
||||
sreturn = comparaisonBis(herite_exp);
|
||||
} else if( uniteCourante == INFERIEUR) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
expArith();
|
||||
comparaisonBis();
|
||||
herite_exp = expArith();
|
||||
herite_exp = cree_n_exp_op(inf,herite,herite_exp);
|
||||
sreturn = comparaisonBis(herite_exp);
|
||||
|
||||
} else if( !est_suivant( _comparaisonBis_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
n_exp *expArith()
|
||||
{
|
||||
openSection( __func__ );
|
||||
|
||||
n_exp *sreturn;
|
||||
n_exp *herite_fils;
|
||||
n_exp *sreturn = NULL;
|
||||
n_exp *herite_fils = NULL;
|
||||
|
||||
if( est_premier( _terme_, uniteCourante ) ) {
|
||||
herite_fils = terme();
|
||||
@@ -635,9 +739,9 @@ n_exp *expArith()
|
||||
n_exp *expArithBis(n_exp *herite) {
|
||||
openSection( __func__ );
|
||||
|
||||
n_exp *s;
|
||||
n_exp *sreturn;
|
||||
n_exp *herite_fils;
|
||||
n_exp *s = NULL;
|
||||
n_exp *sreturn = NULL;
|
||||
n_exp *herite_fils = NULL;
|
||||
|
||||
if( uniteCourante == PLUS ) {
|
||||
elementConsome();
|
||||
@@ -666,8 +770,8 @@ n_exp *expArithBis(n_exp *herite) {
|
||||
n_exp *terme() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_exp *sreturn;
|
||||
n_exp *herite_fils;
|
||||
n_exp *sreturn = NULL;
|
||||
n_exp *herite_fils = NULL;
|
||||
|
||||
if( est_premier( _facteur_, uniteCourante ) ) {
|
||||
herite_fils = facteur();
|
||||
@@ -683,9 +787,9 @@ n_exp *terme() {
|
||||
n_exp *termeBis(n_exp *herite) {
|
||||
openSection( __func__ );
|
||||
|
||||
n_exp *s;
|
||||
n_exp *sreturn;
|
||||
n_exp *herite_fils;
|
||||
n_exp *s = NULL;
|
||||
n_exp *sreturn = NULL;
|
||||
n_exp *herite_fils = NULL;
|
||||
|
||||
if( uniteCourante == FOIS ) {
|
||||
elementConsome();
|
||||
@@ -714,7 +818,7 @@ n_exp *termeBis(n_exp *herite) {
|
||||
n_exp *facteur() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_exp *sreturn;
|
||||
n_exp *sreturn = NULL;
|
||||
|
||||
if( uniteCourante == PARENTHESE_OUVRANTE ) {
|
||||
elementConsome();
|
||||
@@ -733,13 +837,13 @@ n_exp *facteur() {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
} else if( est_premier( _appelFct_, uniteCourante ) ) {
|
||||
sreturn = appelFct();
|
||||
sreturn = cree_n_exp_appel(appelFct());
|
||||
} else if( est_premier( _var_, uniteCourante ) ) {
|
||||
sreturn = var();
|
||||
sreturn = cree_n_exp_var(var());
|
||||
} else if( uniteCourante == LIRE ) {
|
||||
sreturn = cree_n_exp_lire();
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
sreturn = cree_n_exp_lire();
|
||||
|
||||
if( uniteCourante == PARENTHESE_OUVRANTE ) {
|
||||
elementConsome();
|
||||
@@ -762,29 +866,37 @@ n_exp *facteur() {
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void var() {
|
||||
n_var *var() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_var *sreturn = NULL;
|
||||
n_exp *indice = NULL;
|
||||
if( uniteCourante == ID_VAR ) {
|
||||
char *appelName;
|
||||
appelName = duplique_chaine(yytext);
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
optIndice();
|
||||
indice = optIndice();
|
||||
if (indice == NULL)
|
||||
sreturn = cree_n_var_simple(appelName);
|
||||
else
|
||||
sreturn = cree_n_var_indicee(appelName,indice);
|
||||
} else {
|
||||
syntaxErrorMsg( "Indice de variable été attendu" );
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void optIndice() {
|
||||
n_exp *optIndice() {
|
||||
openSection( __func__ );
|
||||
n_exp *sreturn = NULL;
|
||||
|
||||
if( uniteCourante == CROCHET_OUVRANT ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
sreturn = expression();
|
||||
|
||||
if( uniteCourante == CROCHET_FERMANT ) {
|
||||
elementConsome();
|
||||
@@ -797,17 +909,18 @@ void optIndice() {
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
n_exp *appelFct() {
|
||||
n_appel *appelFct() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_l_exp *herite_fils;
|
||||
n_appel *sreturn;
|
||||
n_l_exp *herite_fils = NULL;
|
||||
n_appel *sreturn = NULL;
|
||||
|
||||
if( uniteCourante == ID_FCT ) {
|
||||
char appelName[100];
|
||||
strcpy(appelName, yytext);
|
||||
char *appelName;
|
||||
appelName = duplique_chaine(yytext);
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
@@ -833,34 +946,42 @@ n_exp *appelFct() {
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return cree_n_exp_appel(sreturn);
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void listeExpressions() {
|
||||
n_l_exp *listeExpressions() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_l_exp *sreturn = NULL;
|
||||
n_exp *herite_exp = NULL;
|
||||
n_l_exp *expression_liste = NULL;
|
||||
|
||||
if( est_premier( _expression_, uniteCourante ) || est_premier( _listeExpressionsBis_, uniteCourante ) ) {
|
||||
expression();
|
||||
listeExpressionsBis();
|
||||
herite_exp = expression();
|
||||
expression_liste = listeExpressionsBis();
|
||||
sreturn = cree_n_l_exp(herite_exp,expression_liste);
|
||||
} else if( !est_suivant( _listeExpressions_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
return sreturn;
|
||||
}
|
||||
|
||||
void listeExpressionsBis() {
|
||||
n_l_exp *listeExpressionsBis() {
|
||||
openSection( __func__ );
|
||||
|
||||
n_l_exp *sreturn = NULL;
|
||||
n_exp *herite_exp = NULL;
|
||||
n_l_exp *herite_l_exp = NULL;
|
||||
if( uniteCourante == VIRGULE ) {
|
||||
elementConsome();
|
||||
uniteCourante = yylex();
|
||||
|
||||
expression();
|
||||
listeExpressionsBis();
|
||||
herite_exp = expression();
|
||||
herite_l_exp = listeExpressionsBis();
|
||||
sreturn = cree_n_l_exp(herite_exp,herite_l_exp);
|
||||
} else if( !est_suivant( _listeExpressionsBis_, uniteCourante ) ) {
|
||||
syntaxError();
|
||||
}
|
||||
|
||||
closeSection( __func__ );
|
||||
}
|
||||
return sreturn;
|
||||
}
|
||||
Reference in New Issue
Block a user