Mamannnnnnnnn !!!!!!!!!!!!!!

This commit is contained in:
2016-03-01 16:13:24 +01:00
parent 336d8d58bd
commit c400284b80
7 changed files with 807 additions and 20 deletions

View File

@@ -1,7 +1,7 @@
#include "analyseur_syntaxyque.h"
int uniteCourante;
int afficheSyntaxyque = 1;
int afficheSyntaxyque = 0;
extern char yytext[100];
extern int nb_ligne;
@@ -608,85 +608,113 @@ void comparaisonBis() {
closeSection( __func__ );
}
void expArith()
n_exp expArith()
{
openSection( __func__ );
n_exp *sreturn;
n_exp *herite_fils;
if( est_premier( _terme_, uniteCourante ) ) {
terme();
expArithBis();
herite_fils = terme();
sreturn = expArithBis(herite_fils);
} else {
syntaxError();
}
closeSection( __func__ );
return sreturn;
}
void expArithBis() {
n_exp expArithBis(n_exp *herite) {
openSection( __func__ );
n_exp *s;
n_exp *sreturn;
n_exp *herite_fils;
if( uniteCourante == PLUS ) {
elementConsome();
uniteCourante = yylex();
terme();
expArithBis();
s = terme();
herite_fils = cree_n_exp_op(plus, herite, s);
sreturn = expArithBis(herite_fils);
} else if( uniteCourante == MOINS) {
elementConsome();
uniteCourante = yylex();
terme();
expArithBis();
s = terme();
erite_fils = cree_n_exp_op(moins, herite, s);
sreturn = expArithBis();
} else if( !est_suivant( _expArithBis_, uniteCourante ) ) {
syntaxError();
} else {
sreturn = herite;
}
closeSection( __func__ );
return sreturn;
}
void terme() {
n_exp terme() {
openSection( __func__ );
n_exp *sreturn;
n_exp *herite_fils;
if( est_premier( _facteur_, uniteCourante ) ) {
facteur();
termeBis();
herite_fils = facteur();
sreturn = termeBis(herite_fils);
} else {
syntaxError();
}
closeSection( __func__ );
return sreturn;
}
void termeBis() {
n_exp *termeBis(n_exp *herite) {
openSection( __func__ );
n_exp *s;
n_exp *sreturn;
n_exp *herite_fils;
if( uniteCourante == FOIS ) {
elementConsome();
uniteCourante = yylex();
facteur();
termeBis();
s = facteur();
herite_fils = cree_n_exp_op(fois, herite, s);
sreturn = termeBis(herite_fils);
} else if( uniteCourante == DIVISE) {
elementConsome();
uniteCourante = yylex();
facteur();
termeBis();
s = facteur();
herite_fils = cree_n_exp_op(divise, herite, s);
sreturn = termeBis(herite_fils);
} else if( !est_suivant( _termeBis_, uniteCourante ) ) {
syntaxError();
} else {
sreturn = herite;
}
closeSection( __func__ );
return sreturn;
}
void facteur() {
n_exp facteur() {
openSection( __func__ );
n_exp *sreturn;
if( uniteCourante == PARENTHESE_OUVRANTE ) {
elementConsome();
uniteCourante = yylex();
expression();
sreturn = expression();
if( uniteCourante == PARENTHESE_FERMANTE ) {
elementConsome();
@@ -695,10 +723,11 @@ void facteur() {
syntaxErrorMsg( "')' été attendu" );
}
} else if( uniteCourante == NOMBRE ) {
sreturn = cree_n_exp_entier(atoi(yytext));
elementConsome();
uniteCourante = yylex();
} else if( est_premier( _appelFct_, uniteCourante ) ) {
appelFct();
appelFct(); // TODOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
} else if( est_premier( _var_, uniteCourante ) ) {
var();
} else if( uniteCourante == LIRE ) {