Papa !!!!!!!

This commit is contained in:
2016-03-04 15:49:15 +01:00
parent c400284b80
commit a86fe33ac4
2 changed files with 37 additions and 20 deletions

View File

@@ -19,7 +19,8 @@ void closeSection ( const char * section );
void elementConsome (); void elementConsome ();
void syntaxError (void); void syntaxError (void);
void syntaxErrorMsg( const char * msg ); void syntaxErrorMsg( const char * msg );
void programme (void);
n_prog *programme (void);
void optDecVariables (void); void optDecVariables (void);
void listeDecVariables (void); void listeDecVariables (void);
void listeDecVariablesBis (void); void listeDecVariablesBis (void);
@@ -49,14 +50,14 @@ void negation (void);
void comparaison (void); void comparaison (void);
void comparaisonBis (void); void comparaisonBis (void);
void expression (void); void expression (void);
void expArith (void); n_exp *expArith (void);
void expArithBis (void); n_exp *expArithBis(n_exp *herite);
void terme (void); n_exp *terme (void);
void termeBis (void); n_exp *termeBis(n_exp *herite);
void facteur (void); n_exp *facteur (void);
void var (void); void var (void);
void optIndice (void); void optIndice (void);
void appelFct (void); n_exp *appelFct (void);
void listeExpressions (void); void listeExpressions (void);
void listeExpressionsBis (void); void listeExpressionsBis (void);

View File

@@ -41,17 +41,23 @@ void syntaxErrorMsg( const char * msg )
exit( 1 ); exit( 1 );
} }
void programme() { n_prog *programme() {
openSection( __func__ ); openSection( __func__ );
n_l_dec *herite_var;
n_l_dec *herite_func;
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(); syntaxError();
} else { } else {
optDecVariables(); herite_var = optDecVariables();
listeDecFonctions(); herite_func = listeDecFonctions();
sreturn = cree_n_prog(herite_var, herite_func);
} }
closeSection( __func__ ); closeSection( __func__ );
return sreturn;
} }
void optDecVariables() { void optDecVariables() {
@@ -608,7 +614,7 @@ void comparaisonBis() {
closeSection( __func__ ); closeSection( __func__ );
} }
n_exp expArith() n_exp *expArith()
{ {
openSection( __func__ ); openSection( __func__ );
@@ -626,7 +632,7 @@ n_exp expArith()
return sreturn; return sreturn;
} }
n_exp expArithBis(n_exp *herite) { n_exp *expArithBis(n_exp *herite) {
openSection( __func__ ); openSection( __func__ );
n_exp *s; n_exp *s;
@@ -645,8 +651,8 @@ n_exp expArithBis(n_exp *herite) {
uniteCourante = yylex(); uniteCourante = yylex();
s = terme(); s = terme();
erite_fils = cree_n_exp_op(moins, herite, s); herite_fils = cree_n_exp_op(moins, herite, s);
sreturn = expArithBis(); sreturn = expArithBis(herite_fils);
} else if( !est_suivant( _expArithBis_, uniteCourante ) ) { } else if( !est_suivant( _expArithBis_, uniteCourante ) ) {
syntaxError(); syntaxError();
} else { } else {
@@ -657,7 +663,7 @@ n_exp expArithBis(n_exp *herite) {
return sreturn; return sreturn;
} }
n_exp terme() { n_exp *terme() {
openSection( __func__ ); openSection( __func__ );
n_exp *sreturn; n_exp *sreturn;
@@ -705,7 +711,7 @@ n_exp *termeBis(n_exp *herite) {
return sreturn; return sreturn;
} }
n_exp facteur() { n_exp *facteur() {
openSection( __func__ ); openSection( __func__ );
n_exp *sreturn; n_exp *sreturn;
@@ -727,10 +733,11 @@ n_exp facteur() {
elementConsome(); elementConsome();
uniteCourante = yylex(); uniteCourante = yylex();
} else if( est_premier( _appelFct_, uniteCourante ) ) { } else if( est_premier( _appelFct_, uniteCourante ) ) {
appelFct(); // TODOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO sreturn = appelFct();
} else if( est_premier( _var_, uniteCourante ) ) { } else if( est_premier( _var_, uniteCourante ) ) {
var(); sreturn = var();
} else if( uniteCourante == LIRE ) { } else if( uniteCourante == LIRE ) {
sreturn = cree_n_exp_lire();
elementConsome(); elementConsome();
uniteCourante = yylex(); uniteCourante = yylex();
@@ -752,6 +759,7 @@ n_exp facteur() {
} }
closeSection( __func__ ); closeSection( __func__ );
return sreturn;
} }
void var() { void var() {
@@ -791,10 +799,15 @@ void optIndice() {
closeSection( __func__ ); closeSection( __func__ );
} }
void appelFct() { n_exp *appelFct() {
openSection( __func__ ); openSection( __func__ );
n_l_exp *herite_fils;
n_appel *sreturn;
if( uniteCourante == ID_FCT ) { if( uniteCourante == ID_FCT ) {
char appelName[100];
strcpy(appelName, yytext);
elementConsome(); elementConsome();
uniteCourante = yylex(); uniteCourante = yylex();
@@ -802,7 +815,9 @@ void appelFct() {
elementConsome(); elementConsome();
uniteCourante = yylex(); uniteCourante = yylex();
listeExpressions(); herite_fils = listeExpressions();
sreturn = cree_n_appel(appelName, herite_fils);
if( uniteCourante == PARENTHESE_FERMANTE ) { if( uniteCourante == PARENTHESE_FERMANTE ) {
elementConsome(); elementConsome();
@@ -818,6 +833,7 @@ void appelFct() {
} }
closeSection( __func__ ); closeSection( __func__ );
return cree_n_exp_appel(sreturn);
} }
void listeExpressions() { void listeExpressions() {