iAdd in grammar :

- var
    - /
    - -
This commit is contained in:
2016-01-26 16:03:37 +01:00
parent e71dc9bae0
commit 1871e6f8c8
5 changed files with 12 additions and 4 deletions

View File

@@ -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_balise_fermante(const char *fct_, int trace_xml);
void affiche_element(char *fct_, char *texte_, int trace_xml); void affiche_element(char *fct_, char *texte_, int trace_xml);
void affiche_texte(char *texte_, int trace_xml); void affiche_texte(char *texte_, int trace_xml);
void affiche_xml_texte( char *texte_ );
#endif #endif

View File

@@ -3,8 +3,6 @@
int uniteCourante; int uniteCourante;
extern char yytext[100]; extern char yytext[100];
void expArith (void) { void expArith (void) {
affiche_balise_ouvrante("expArith", 1); affiche_balise_ouvrante("expArith", 1);
@@ -17,7 +15,7 @@ void expArith (void) {
void expArithBis (void) { void expArithBis (void) {
affiche_balise_ouvrante("expArithBis", 1); affiche_balise_ouvrante("expArithBis", 1);
if(uniteCourante == PLUS) { if(uniteCourante == PLUS || uniteCourante == MOINS ) {
uniteCourante = yylex(); uniteCourante = yylex();
affiche_xml_texte(yytext); affiche_xml_texte(yytext);
@@ -39,7 +37,7 @@ void terme (void) {
void termeBis (void) { void termeBis (void) {
affiche_balise_ouvrante("termeBis", 1); affiche_balise_ouvrante("termeBis", 1);
if(uniteCourante == FOIS) { if(uniteCourante == FOIS || uniteCourante == DIVISE) {
uniteCourante = yylex(); uniteCourante = yylex();
affiche_xml_texte(yytext); affiche_xml_texte(yytext);
@@ -62,9 +60,15 @@ void facteur (void) {
printf("Erreur de syntaxe"); printf("Erreur de syntaxe");
exit(-1); exit(-1);
} }
uniteCourante = yylex();
affiche_xml_texte(yytext);
} else if(uniteCourante == NOMBRE) { } else if(uniteCourante == NOMBRE) {
uniteCourante = yylex(); uniteCourante = yylex();
affiche_xml_texte(yytext); affiche_xml_texte(yytext);
} else if(uniteCourante == ID_VAR) {
uniteCourante = yylex();
affiche_xml_texte(yytext);
} else { } else {
printf("Erreur de syntaxe"); printf("Erreur de syntaxe");
exit(-1); exit(-1);

View File

@@ -0,0 +1 @@
4 + 8 * (5 / 8) - (9 + 4 / 8) * ($var + $vart)

1
test/expressionPara Normal file
View File

@@ -0,0 +1 @@
(5 + 8) + (9 * 4)

1
test/expressionVar Normal file
View File

@@ -0,0 +1 @@
4 + $var + 5 * 6