Remove All errors

This commit is contained in:
2016-02-02 18:15:32 +01:00
parent 707aa5b2ad
commit a9ec673316
2 changed files with 124 additions and 98 deletions

View File

@@ -2,17 +2,39 @@
int uniteCourante;
extern char yytext[100];
extern int nb_ligne;
void openSection( const char * section ) {
affiche_balise_ouvrantexpression( section, 1 );
affiche_balise_ouvrante( section, 1 );
}
void closeSection( const char * section ) {
affiche_balise_fermantexpression( section, 1 );
affiche_balise_fermante( section, 1 );
}
void syntaxError()
{
char token[128];
char nom[128];
nom_token( uniteCourante, nom, token );
fprintf( stderr, "Erreur de syntax, proche de la ligne %d, et de l'unite courante '%s' (%d - %s)\n", nb_ligne, token, uniteCourante, nom );
exit( 1 );
}
void syntaxErrorMsg( const char * msg )
{
char token[128];
char nom[128];
nom_token( uniteCourante, nom, token );
fprintf( stderr, "Erreur de syntax, proche de la ligne %d, et de l'unite courante '%s' (%d - %s)\n", nb_ligne, token, uniteCourante, nom );
fprintf( stderr, "%s\n", msg );
exit( 1 );
}
void programme() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _optDecVariables_, uniteCourante ) ) {
optDecVariables();
@@ -21,11 +43,11 @@ void programme() {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void optDecVariables() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _listeDecVariables_, uniteCourante ) )
{
@@ -36,15 +58,15 @@ void optDecVariables() {
} else {
syntaxErrorMsg( "';' été attendu" );
}
} else if ( !est_suivanterme( _optDecVariables_, uniteCourante ) ) {
} else if ( !est_suivant( _optDecVariables_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void listeDecVariables() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _declarationVariable_, uniteCourante ) ) {
declarationVariable();
@@ -53,26 +75,26 @@ void listeDecVariables() {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void listeDecVariablesBis() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == VIRGULE ) {
uniteCourante = yylex();
declarationVariable();
listeDecVariablesBis();
} else if( !est_suivanterme( _listeDecVariablesBis_, uniteCourante ) ) {
} else if( !est_suivant( _listeDecVariablesBis_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void declarationVariable() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == ENTIER ) {
uniteCourante = yylex();
@@ -88,11 +110,11 @@ void declarationVariable() {
syntaxErrorMsg( "'ENTIER' été attendu" );
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void optTailleTableau() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == CROCHET_OUVRANT ) {
uniteCourante = yylex();
@@ -108,29 +130,29 @@ void optTailleTableau() {
} else {
syntaxErrorMsg( "Un nombre été attendu" );
}
} else if( !est_suivanterme( _optTailleTableau_, uniteCourante ) )
} else if( !est_suivant( _optTailleTableau_, uniteCourante ) )
{
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void listeDecFonctions() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _declarationFonction_, uniteCourante ) ) {
declarationFonction();
listeDecFonctions();
} else if( !est_suivanterme( _listeDecFonctionss_, uniteCourante ) ) {
} else if( !est_suivant( _listeDecFonctions_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void declarationFonction() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == ID_FCT ) {
uniteCourante = yylex();
@@ -142,11 +164,11 @@ void declarationFonction() {
syntaxErrorMsg( "Un identificateur de fonction été attendu" );
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void listeParam() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == PARENTHESE_OUVRANTE ) {
uniteCourante = yylex();
@@ -162,23 +184,23 @@ void listeParam() {
syntaxErrorMsg( "'(' été attendu" );
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void optListeDecVariables() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _listeDecVariables_, uniteCourante ) ) {
listeDecVariables();
} else if( !est_suivanterme( _optListeDecVariables_, uniteCourante ) ) {
} else if( !est_suivant( _optListeDecVariables_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void instruction() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _instructionAffect_, uniteCourante ) ) {
instructionAffect();
@@ -200,11 +222,11 @@ void instruction() {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void instructionAffect() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _var_, uniteCourante ) ) {
var();
@@ -226,11 +248,11 @@ void instructionAffect() {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void instructionBloc() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == ACCOLADE_OUVRANTE ) {
uniteCourante = yylex();
@@ -246,24 +268,24 @@ void instructionBloc() {
syntaxErrorMsg( "'{' été attendu" );
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void listeInstructions() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _instruction_, uniteCourante ) ) {
instruction();
listeInstructions();
} else if( !est_suivanterme( _listeInstructions_, uniteCourante ) ) {
} else if( !est_suivant( _listeInstructions_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void instructionSi() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == SI ) {
uniteCourante = yylex();
@@ -282,25 +304,25 @@ void instructionSi() {
syntaxErrorMsg( "'si' été attendu" );
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void optSinon() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == SINON ) {
uniteCourante = yylex();
instructionBloc();
} else if( !est_suivanterme( _optSinon_, uniteCourante ) ) {
} else if( !est_suivant( _optSinon_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void instructionTantque() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == TANTQUE ) {
uniteCourante = yylex();
@@ -318,11 +340,11 @@ void instructionTantque() {
syntaxErrorMsg( "'tantque' été attendu" );
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void instructionAppel() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _instructionAppel_, uniteCourante ) ) {
appelFct();
@@ -336,11 +358,11 @@ void instructionAppel() {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void instructionRetour() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == RETOUR ) {
uniteCourante = yylex();
@@ -356,11 +378,11 @@ void instructionRetour() {
syntaxErrorMsg( "'retour' été attendu" );
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void instructionEcriture() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == ECRIRE ) {
uniteCourante = yylex();
@@ -388,11 +410,11 @@ void instructionEcriture() {
syntaxErrorMsg( "'ecrire' été attendu" );
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void instructionVide() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == POINT_VIRGULE ) {
uniteCourante = yylex();
@@ -400,11 +422,11 @@ void instructionVide() {
syntaxErrorMsg( "';' été attendu" );
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void expression() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _conjonction_, uniteCourante ) ) {
conjonction();
@@ -413,26 +435,26 @@ void expression() {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void expressionBis() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == OU ) {
uniteCourante = yylex();
conjonction();
expressionBis();
} else if( !est_suivanterme( _expressionBis_, uniteCourante ) ) {
} else if( !est_suivant( _expressionBis_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void conjonction() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _negation_, uniteCourante ) ) {
negation();
@@ -441,26 +463,26 @@ void conjonction() {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void conjonctionBis() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == ET ) {
uniteCourante = yylex();
negation();
conjonctionBis();
} else if( !est_suivanterme( _conjonctionBis_, uniteCourante ) ) {
} else if( !est_suivant( _conjonctionBis_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void negation() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == NON ) {
uniteCourante = yylex();
@@ -472,11 +494,11 @@ void negation() {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void comparaison() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _expression_, uniteCourante ) ) {
expArith();
@@ -485,55 +507,55 @@ void comparaison() {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void comparaisonBis() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == EGAL || uniteCourante == INFERIEUR) {
uniteCourante = yylex();
expArith();
comparaisonBis();
} else if( !est_suivanterme( _comparaisonBis_, uniteCourante ) ) {
} else if( !est_suivant( _comparaisonBis_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void expArith()
{
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _terme_, yylval ) ) {
if( est_premier( _terme_, uniteCourante ) ) {
terme();
expArithBis();
} else {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void expArithBis() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == PLUS || uniteCourante == MOINS) {
uniteCourante = yylex();
terme();
expArithBis();
} else if( !est_suivanterme( _expArithBis_, uniteCourante ) ) {
} else if( !est_suivant( _expArithBis_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void terme() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _facteur_, uniteCourante ) ) {
facteur();
@@ -542,26 +564,26 @@ void terme() {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void termeBis() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == FOIS || ylval == DIVISE ) {
if( uniteCourante == FOIS || uniteCourante == DIVISE ) {
uniteCourante = yylex();
facteur();
termeBis();
} else if( !est_suivanterme( _termeBis_, uniteCourante ) ) {
} else if( !est_suivant( _termeBis_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void facteur() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == PARENTHESE_OUVRANTE ) {
uniteCourante = yylex();
@@ -597,11 +619,11 @@ void facteur() {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void var() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == ID_VAR ) {
uniteCourante = yylex();
@@ -611,11 +633,11 @@ void var() {
syntaxErrorMsg( "Indice de variable été attendu" );
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void optIndice() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == CROCHET_OUVRANT ) {
uniteCourante = yylex();
@@ -627,15 +649,15 @@ void optIndice() {
} else {
syntaxErrorMsg( "']' été attendu" );
}
} else if( !est_suivanterme( _optIndice_, uniteCourante ) ) {
} else if( !est_suivant( _optIndice_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void appelFct() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( uniteCourante == ID_FCT ) {
uniteCourante = yylex();
@@ -657,33 +679,33 @@ void appelFct() {
syntaxErrorMsg( "Identificateur de fonction été attendu" );
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void listeExpressions() {
openSection( __FUNCTION__ );
openSection( __func__ );
if( est_premier( _expression_, uniteCourante ) ) {
expression();
listeExpressionsBis(();
} else if( !est_suivanterme( _listeexpressions_, uniteCourante ) ) {
listeExpressionsBis();
} else if( !est_suivant( _listeExpressions_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}
void listeExpressionsBis(() {
openSection( __FUNCTION__ );
void listeExpressionsBis() {
openSection( __func__ );
if( uniteCourante == VIRGULE ) {
uniteCourante = yylex();
expression();
listeExpressionsBis(();
} else if( !est_suivanterme( _listeexpressionsBis_, uniteCourante ) ) {
listeExpressionsBis();
} else if( !est_suivant( _listeExpressionsBis_, uniteCourante ) ) {
syntaxError();
}
closeSection( __FUNCTION__ );
closeSection( __func__ );
}