extension sans fonction a revoir le non

This commit is contained in:
sylvain099
2016-01-29 22:07:40 +01:00
parent 1871e6f8c8
commit d168ca8f22
4 changed files with 115 additions and 3 deletions

View File

@@ -3,6 +3,104 @@
int uniteCourante; int uniteCourante;
extern char yytext[100]; extern char yytext[100];
void ou(void);
void ouBis(void);
void et(void);
void etBis(void);
void non(void);
void nonBis(void);
void egal(void);
void egalBis(void);
void expArith(void);
void expArithBis(void);
void terme(void);
void termeBis(void);
void facteur(void);
void ou (void){
affiche_balise_ouvrante("ou", 1);
et();
ouBis();
affiche_balise_fermante("ou", 1);
}
void ouBis(void){
affiche_balise_ouvrante("ouBis", 1);
if(uniteCourante == OU){
uniteCourante = yylex();
affiche_xml_texte(yytext);
ou();
}
affiche_balise_fermante("ouBis", 1);
}
void et(void){
affiche_balise_ouvrante("et", 1);
non();
etBis();
affiche_balise_fermante("et", 1);
}
void etBis(void){
affiche_balise_ouvrante("etBis", 1);
if(uniteCourante == ET){
uniteCourante = yylex();
affiche_xml_texte(yytext);
et();
}
affiche_balise_fermante("etBis", 1);
}
void non(void){
affiche_balise_ouvrante("non", 1);
egal();
nonBis();
affiche_balise_fermante("non", 1);
}
void nonBis(void){
affiche_balise_ouvrante("etBis", 1);
if(uniteCourante == NON){
uniteCourante = yylex();
affiche_xml_texte(yytext);
non();
}
affiche_balise_fermante("etBis", 1);
}
void egal(void){
affiche_balise_ouvrante("egal", 1);
expArith();
egalBis();
affiche_balise_fermante("egal", 1);
}
void egalBis(void){
affiche_balise_ouvrante("egalBis", 1);
if(uniteCourante == NON){
uniteCourante = yylex();
affiche_xml_texte(yytext);
egal();
}
affiche_balise_fermante("egalBis", 1);
}
void expArith (void) { void expArith (void) {
affiche_balise_ouvrante("expArith", 1); affiche_balise_ouvrante("expArith", 1);
@@ -54,7 +152,7 @@ void facteur (void) {
uniteCourante = yylex(); uniteCourante = yylex();
affiche_xml_texte(yytext); affiche_xml_texte(yytext);
expArith(); ou();
if(uniteCourante != PARENTHESE_FERMANTE) { if(uniteCourante != PARENTHESE_FERMANTE) {
printf("Erreur de syntaxe"); printf("Erreur de syntaxe");
@@ -69,7 +167,19 @@ void facteur (void) {
} else if(uniteCourante == ID_VAR) { } else if(uniteCourante == ID_VAR) {
uniteCourante = yylex(); uniteCourante = yylex();
affiche_xml_texte(yytext); affiche_xml_texte(yytext);
} else { } else if(uniteCourante == CROCHET_OUVRANT){
uniteCourante = yylex();
affiche_xml_texte(yytext);
ou();
if(uniteCourante != CROCHET_FERMANT) {
printf("Erreur de syntaxe");
exit(-1);
}
uniteCourante = yylex();
affiche_xml_texte(yytext);
}
else {
printf("Erreur de syntaxe"); printf("Erreur de syntaxe");
exit(-1); exit(-1);
} }

View File

@@ -21,7 +21,7 @@ int main(int argc, char **argv) {
uniteCourante = yylex(); uniteCourante = yylex();
affiche_xml_texte(yytext); affiche_xml_texte(yytext);
expArith(); ou();
uniteCourante = yylex(); uniteCourante = yylex();

View File

@@ -0,0 +1 @@
(!!!var & var) | (10 -4) & 10 < (5/3)

1
test/expressionOuEt Normal file
View File

@@ -0,0 +1 @@
(1 + 1) | (2 * 3) & 5