diff --git a/header/util.h b/header/util.h index 355b9ce..ed007c6 100644 --- a/header/util.h +++ b/header/util.h @@ -8,5 +8,6 @@ void affiche_balise_ouvrante(const char *fct_, int trace_xml); void affiche_balise_fermante(const char *fct_, int trace_xml); void affiche_element(char *fct_, char *texte_, int trace_xml); void affiche_texte(char *texte_, int trace_xml); +void affiche_xml_texte( char *texte_ ); #endif diff --git a/src/analyseur_syntaxyque.c b/src/analyseur_syntaxyque.c index 72e97a9..4ad9189 100644 --- a/src/analyseur_syntaxyque.c +++ b/src/analyseur_syntaxyque.c @@ -3,8 +3,6 @@ int uniteCourante; extern char yytext[100]; - - void expArith (void) { affiche_balise_ouvrante("expArith", 1); @@ -17,7 +15,7 @@ void expArith (void) { void expArithBis (void) { affiche_balise_ouvrante("expArithBis", 1); - if(uniteCourante == PLUS) { + if(uniteCourante == PLUS || uniteCourante == MOINS ) { uniteCourante = yylex(); affiche_xml_texte(yytext); @@ -39,7 +37,7 @@ void terme (void) { void termeBis (void) { affiche_balise_ouvrante("termeBis", 1); - if(uniteCourante == FOIS) { + if(uniteCourante == FOIS || uniteCourante == DIVISE) { uniteCourante = yylex(); affiche_xml_texte(yytext); @@ -62,9 +60,15 @@ void facteur (void) { printf("Erreur de syntaxe"); exit(-1); } + uniteCourante = yylex(); + affiche_xml_texte(yytext); + } else if(uniteCourante == NOMBRE) { uniteCourante = yylex(); affiche_xml_texte(yytext); + } else if(uniteCourante == ID_VAR) { + uniteCourante = yylex(); + affiche_xml_texte(yytext); } else { printf("Erreur de syntaxe"); exit(-1); diff --git a/test/expressionMenosDivised b/test/expressionMenosDivised new file mode 100644 index 0000000..b32ad8b --- /dev/null +++ b/test/expressionMenosDivised @@ -0,0 +1 @@ +4 + 8 * (5 / 8) - (9 + 4 / 8) * ($var + $vart) diff --git a/test/expressionPara b/test/expressionPara new file mode 100644 index 0000000..e9d9936 --- /dev/null +++ b/test/expressionPara @@ -0,0 +1 @@ +(5 + 8) + (9 * 4) diff --git a/test/expressionVar b/test/expressionVar new file mode 100644 index 0000000..fa383d0 --- /dev/null +++ b/test/expressionVar @@ -0,0 +1 @@ +4 + $var + 5 * 6