From a86fe33ac48b5b3e0e15a7ffe0f033e2166e90aa Mon Sep 17 00:00:00 2001 From: Xawirses Date: Fri, 4 Mar 2016 15:49:15 +0100 Subject: [PATCH] Papa !!!!!!! --- header/analyseur_syntaxyque.h | 15 +++++++------ src/analyseur_syntaxyque.c | 42 ++++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/header/analyseur_syntaxyque.h b/header/analyseur_syntaxyque.h index 60f53c4..e6550ff 100644 --- a/header/analyseur_syntaxyque.h +++ b/header/analyseur_syntaxyque.h @@ -19,7 +19,8 @@ void closeSection ( const char * section ); void elementConsome (); void syntaxError (void); void syntaxErrorMsg( const char * msg ); -void programme (void); + +n_prog *programme (void); void optDecVariables (void); void listeDecVariables (void); void listeDecVariablesBis (void); @@ -49,14 +50,14 @@ void negation (void); void comparaison (void); void comparaisonBis (void); void expression (void); -void expArith (void); -void expArithBis (void); -void terme (void); -void termeBis (void); -void facteur (void); +n_exp *expArith (void); +n_exp *expArithBis(n_exp *herite); +n_exp *terme (void); +n_exp *termeBis(n_exp *herite); +n_exp *facteur (void); void var (void); void optIndice (void); -void appelFct (void); +n_exp *appelFct (void); void listeExpressions (void); void listeExpressionsBis (void); diff --git a/src/analyseur_syntaxyque.c b/src/analyseur_syntaxyque.c index 854b833..0841f74 100644 --- a/src/analyseur_syntaxyque.c +++ b/src/analyseur_syntaxyque.c @@ -41,17 +41,23 @@ void syntaxErrorMsg( const char * msg ) exit( 1 ); } -void programme() { +n_prog *programme() { 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 )) { syntaxError(); } else { - optDecVariables(); - listeDecFonctions(); + herite_var = optDecVariables(); + herite_func = listeDecFonctions(); + sreturn = cree_n_prog(herite_var, herite_func); } closeSection( __func__ ); + return sreturn; } void optDecVariables() { @@ -608,7 +614,7 @@ void comparaisonBis() { closeSection( __func__ ); } -n_exp expArith() +n_exp *expArith() { openSection( __func__ ); @@ -626,7 +632,7 @@ n_exp expArith() return sreturn; } -n_exp expArithBis(n_exp *herite) { +n_exp *expArithBis(n_exp *herite) { openSection( __func__ ); n_exp *s; @@ -645,8 +651,8 @@ n_exp expArithBis(n_exp *herite) { uniteCourante = yylex(); s = terme(); - erite_fils = cree_n_exp_op(moins, herite, s); - sreturn = expArithBis(); + herite_fils = cree_n_exp_op(moins, herite, s); + sreturn = expArithBis(herite_fils); } else if( !est_suivant( _expArithBis_, uniteCourante ) ) { syntaxError(); } else { @@ -657,7 +663,7 @@ n_exp expArithBis(n_exp *herite) { return sreturn; } -n_exp terme() { +n_exp *terme() { openSection( __func__ ); n_exp *sreturn; @@ -705,7 +711,7 @@ n_exp *termeBis(n_exp *herite) { return sreturn; } -n_exp facteur() { +n_exp *facteur() { openSection( __func__ ); n_exp *sreturn; @@ -727,10 +733,11 @@ n_exp facteur() { elementConsome(); uniteCourante = yylex(); } else if( est_premier( _appelFct_, uniteCourante ) ) { - appelFct(); // TODOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO + sreturn = appelFct(); } else if( est_premier( _var_, uniteCourante ) ) { - var(); + sreturn = var(); } else if( uniteCourante == LIRE ) { + sreturn = cree_n_exp_lire(); elementConsome(); uniteCourante = yylex(); @@ -752,6 +759,7 @@ n_exp facteur() { } closeSection( __func__ ); + return sreturn; } void var() { @@ -791,10 +799,15 @@ void optIndice() { closeSection( __func__ ); } -void appelFct() { +n_exp *appelFct() { openSection( __func__ ); + n_l_exp *herite_fils; + n_appel *sreturn; + if( uniteCourante == ID_FCT ) { + char appelName[100]; + strcpy(appelName, yytext); elementConsome(); uniteCourante = yylex(); @@ -802,7 +815,9 @@ void appelFct() { elementConsome(); uniteCourante = yylex(); - listeExpressions(); + herite_fils = listeExpressions(); + sreturn = cree_n_appel(appelName, herite_fils); + if( uniteCourante == PARENTHESE_FERMANTE ) { elementConsome(); @@ -818,6 +833,7 @@ void appelFct() { } closeSection( __func__ ); + return cree_n_exp_appel(sreturn); } void listeExpressions() {