Partage
  • Partager sur Facebook
  • Partager sur Twitter

Flex Bison

    3 janvier 2022 à 16:49:01

    Bonjour à tous et bonne année, 

    J'ai réalisé un compilateur d'un petit langage donné j'ai fais l'analyseur lexical et syntaxique à l'aide du flex/bison et la table des symboles mais quand j'exécute la commande bison -d SyntaxiqueProjet.y je trouve cette erreur SyntaxiqueProjet.y: conflits: 1 décalage/réduction 

    En plus quand j'exécute la commande gcc lex.yy.c SyntaxiqueProjet.tab.c -lfl -ly -o comp2021.exe y a trop de warning 

    j' aurai ça :

    Microsoft Windows [version 10.0.19042.1415]

    (c) Microsoft Corporation. Tous droits réservés.

    C:\Users\sg info>cd C:\Users\sg info\OneDrive - Ecole Nationale Supérieure des Travaux Publics\Bureau\Documents\COMPIL

    C:\Users\sg info\OneDrive - Ecole Nationale Supérieure des Travaux Publics\Bureau\Documents\COMPIL>flex LexicalProjet.l

    C:\Users\sg info\OneDrive - Ecole Nationale Supérieure des Travaux Publics\Bureau\Documents\COMPIL>bison -d SyntaxiqueProjet.y

    SyntaxiqueProjet.y: conflits: 1 décalage/réduction

    C:\Users\sg info\OneDrive - Ecole Nationale Supérieure des Travaux Publics\Bureau\Documents\COMPIL>gcc lex.yy.c SyntaxiqueProjet.tab.c -lfl -ly -o comp2021.exe

    In file included from LexicalProjet.l:3:

    TableDesSymboles.h: In function 'initialiseTableau':

    TableDesSymboles.h:371:22: warning: 'sizeof' on array function parameter 'tableau' will return size of 'compatibilite *' [-Wsizeof-array-argument]

      371 |   int taille = sizeof(tableau);

          |                      ^

    TableDesSymboles.h:369:38: note: declared here

      369 | void initialiseTableau(compatibilite tableau[]){

          |                        ~~~~~~~~~~~~~~^~~~~~~~~

    LexicalProjet.l: At top level:

    LexicalProjet.l:5:11: warning: type defaults to 'int' in declaration of 'nb_ligne' [-Wimplicit-int]

        5 |    extern nb_ligne;

          |           ^~~~~~~~

    LexicalProjet.l:6:11: warning: type defaults to 'int' in declaration of 'Col' [-Wimplicit-int]

        6 |    extern Col;

          |           ^~~

    SyntaxiqueProjet.y: In function 'yyparse':

    SyntaxiqueProjet.y:62:8: warning: implicit declaration of function 'rechercheNonDeclare' [-Wimplicit-function-declaration]

       62 |    if (rechercheNonDeclare($1)==0) {insererType($1,sauvType);}

          |        ^~~~~~~~~~~~~~~~~~~

    SyntaxiqueProjet.y:62:60: warning: implicit declaration of function 'insererType' [-Wimplicit-function-declaration]

       62 |    if (rechercheNonDeclare($1)==0) {insererType($1,sauvType);}

          |                                                            ^~~

    SyntaxiqueProjet.y:75:6: warning: implicit declaration of function 'CodeCst' [-Wimplicit-function-declaration]

       75 |      CodeCst($2);

          |      ^~~~~~~

    SyntaxiqueProjet.y:78:10: warning: implicit declaration of function 'CompType' [-Wimplicit-function-declaration]

       78 |      if (CompType($2,"INTEGER")==0) {printf("Erreur semantique a la ligne %d : ICOMPATIBILITE DE TYPE de la variable %s \n", nb_ligne, $2);}

          |          ^~~~~~~~

    SyntaxiqueProjet.y:114:9: warning: implicit declaration of function 'VerifIDFConst' [-Wimplicit-function-declaration]

      114 |     if (VerifIDFConst($1)==1){printf("Erreur semantique a la ligne  %d : la variable %s est une constante, affectation impossible\n",nb_ligne,$1);}

          |         ^~~~~~~~~~~~~

    SyntaxiqueProjet.y:243:24: warning: implicit declaration of function 'NbrSgnFormat' [-Wimplicit-function-declaration]

      243 |     if (NbrIdf != 1 || NbrSgnFormat($3)!=1)

          |                        ^~~~~~~~~~~~

    SyntaxiqueProjet.y:246:8: warning: implicit declaration of function 'insererSignFormat' [-Wimplicit-function-declaration]

      246 |        insererSignFormat($3,tableau);

          |        ^~~~~~~~~~~~~~~~~

    SyntaxiqueProjet.y:247:11: warning: implicit declaration of function 'verifierCompatibilite' [-Wimplicit-function-declaration]

      247 |       if (verifierCompatibilite(tableau,NbrIdf)!=0)

          |           ^~~~~~~~~~~~~~~~~~~~~

    SyntaxiqueProjet.y:249:7: warning: implicit declaration of function 'initialiseTableau' [-Wimplicit-function-declaration]

      249 |       initialiseTableau(tableau);

          |       ^~~~~~~~~~~~~~~~~

    SyntaxiqueProjet.tab.c:1942:7: warning: implicit declaration of function 'yyerror'; did you mean 'yyerrok'? [-Wimplicit-function-declaration]

     1942 |       yyerror (YY_("syntax error"));

          |       ^~~~~~~

          |       yyerrok

    SyntaxiqueProjet.y: At top level:

    SyntaxiqueProjet.y:302:1: warning: return type defaults to 'int' [-Wimplicit-int]

      302 | main ()

          | ^~~~

    SyntaxiqueProjet.y: In function 'main':

    SyntaxiqueProjet.y:304:4: warning: implicit declaration of function 'initialisation' [-Wimplicit-function-declaration]

      304 |    initialisation();

          |    ^~~~~~~~~~~~~~

    SyntaxiqueProjet.y:308:4: warning: implicit declaration of function 'afficher' [-Wimplicit-function-declaration]

      308 |    afficher();

          |    ^~~~~~~~

    SyntaxiqueProjet.y: At top level:

    SyntaxiqueProjet.y:310:2: warning: return type defaults to 'int' [-Wimplicit-int]

      310 |  yywrap ()

          |  ^~~~~~

    C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lfl

    C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ly

    collect2.exe: error: ld returned 1 exit status

    Voici mes codes: 

    LexicalProjet.l

    %{
       #include "SyntaxiqueProjet.tab.h"
       #include "TableDesSymboles.h"
       #include <stdio.h>
       extern nb_ligne;
       extern Col;
       extern YYSTYPE yylval; 
    %}
     
    lettreM [A-Z]
    lettre [a-zA-Z]
    chiffre [0-9]   
    IDF [A-Z]({lettre}|{chiffre}|[_])*                                 
    cst_int [-+]?{chiffre}+
    cst_char ({lettre}|{chiffre})
    cst_string \"[^\"]*\"
    cst_float [+-]?{chiffre}+\.{chiffre}+ 
    
    
    %%
    
    PROGRAM-ID  { rechercher(yytext,"Mot cle",0,0, 1);
                  printf("L entite lexicale reconnue est %s \n", yytext); 
                  Col= Col + strlen(yytext);
                  return mc_pgm; }
    
    INTEGER    { rechercher(yytext,"Mot cle",0,0, 1);
                 printf (" L entite lexicale reconnue est %s \n", yytext); 
                 Col= Col + strlen(yytext); 
                 return mc_entier; } 
    
    FLOAT      { rechercher(yytext,"Mot cle",0,0, 1);
                 printf (" L entite lexicale reconnue est %s \n", yytext);
                 Col= Col + strlen(yytext);  
                 return mc_float; }
    
    CHAR       { rechercher(yytext,"Mot cle",0,0, 1); 
                 printf (" L entite lexicale reconnue est %s \n", yytext);
                 Col= Col + strlen(yytext);
                 return mc_char; } 
    
    STR        { rechercher(yytext,"Mot cle",0,0, 1); 
                 printf (" L entite lexicale reconnue est %s \n", yytext);
                 Col= Col + strlen(yytext);
                 return mc_string; }
    
    CONST      { rechercher(yytext,"Mot cle",0,0, 1); 
                 rechercher(yytext,"Mot cle",0,0, 1);
                 Col= Col + strlen(yytext);
                 return mc_const; }
    
    STOP   { printf("L'entite lexicale reconnue est %s \n", yytext); 
    				  rechercher(yytext,"Mot cle",0,0, 1);
    				  Col= Col + strlen(yytext); 
    				  return mc_stop;}
    
    ACCEPT 	{ printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_accept;}
    				
    DISPLAY 		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_display;}
    
    IF 			{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_if;}
    
    ELSE		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_else;}
    
    MOVE 		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_move;}
    
    TO 		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_to;}
    
    END 		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_end;}
    
    AND 		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_and;}
    
    OR 		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_or;}
    
    NOT 		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_not;}
    				
    L 		   {   printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_inf;}
    				
    G  		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_sup;}
    				
    EQ 			{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_egal;}
    				
    LE     		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_infe;}
    				
    GE     		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_supe;}
    				
    DI    		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				rechercher(yytext,"Mot cle",0,0, 1);
    				Col= Col + strlen(yytext); 
    				return mc_diff;}             
    
    {IDF}  		{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				yylval.string=strdup(yytext);
    				rechercher(yytext,"IDF"," ",0,0); 
    				Col= Col + strlen(yytext); 
    				if (yyleng>10) printf ("\n Erreur Lexicale: IDF trop longue a la ligne %d a la colonne %d \n\n ",nb_ligne, Col);
    				return idf;}
    						
    {cst_int} {	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				yylval.entier=atoi(yytext);
    				rechercher(yytext,"CONSTANT","INTEGER",atof(yytext),0);
    				Col= Col + strlen(yytext); 
    				return cstInt;}
    				
    {cst_char} { printf("L'entite lexicale reconnue est %s \n", yytext);
                 yylval.character=yytext[0]; 
                 rechercher(yytext,"CONSTANT","CHAR",atof(yytext),0);
                  Col= Col + strlen(yytext); return cstChar;}
    				 
    {cst_float}	{	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				yylval.real=atof(yytext);
    				rechercher(yytext,"CONSTANT","FLOAT",atof(yytext),0);
    				Col= Col + strlen(yytext); 
    				return cstFloat;}
    				
    {cst_string} {	printf("L'entite lexicale reconnue est %s \n", yytext); 
    				   yylval.string=strdup(yytext);
    				   rechercher(yytext,"CONSTANT","STR",atof(yytext),0);
    			   	Col= Col + strlen(yytext); 
    				   return cstString;}
    
    "#" 		{Col= Col + strlen(yytext); 
    			rechercher(yytext,"Separateur",0,0,2);
    				return htag;}
    
    "(" 		{Col= Col + strlen(yytext); 
    				rechercher(yytext,"Separateur",0,0,2);
    				return parentheseo;}
    
    ")" 		{Col= Col + strlen(yytext); 
    				rechercher(yytext,"Separateur",0,0,2);
    				return parenthesef;}
    
    "+" 		{Col= Col + strlen(yytext); 
    				rechercher(yytext,"Separateur",0,0,2);
    				return addition;}
    
    "-" 		{Col= Col + strlen(yytext); 
    				rechercher(yytext,"Separateur",0,0,2);
    				return soustraction;}
    
    "="      	{Col= Col + strlen(yytext); 
    				rechercher(yytext,"Separateur",0,0,2);
    				return egal;}
    
    "*" 		{Col= Col + strlen(yytext); 
    				rechercher(yytext,"Separateur",0,0,2);
    				return multiplication;}
    
    "/"         {Col= Col + strlen(yytext); 
    				rechercher(yytext,"Separateur",0,0,2);
    				return division;}
    
    "|" 		{Col= Col + strlen(yytext); 
    				rechercher(yytext,"Separateur",0,0,2);
    				return barre;}
    
    "@" 		{Col= Col + strlen(yytext); 
    				rechercher(yytext,"Separateur",0,0,2);
    				return arobase;}
    
    ":"		{Col= Col + strlen(yytext); 
    				rechercher(yytext,"Separateur",0,0,2);
    				return deuxpts;}
    
    "." 		{Col= Col + strlen(yytext); 
    				rechercher(yytext,"Separateur",0,0,2);
    				return point;}
    
    
    [ \t]     Col= Col + strlen(yytext);  
    \n     {Col= 1; nb_ligne++;}
    . {printf ("Entité lexicale non reconnue a ligne %d a la colonne %d \n", nb_ligne, Col);}
    
    %%
    SyntaxiqueProjet.y
    %{
        int nb_ligne=1, Col=1;
        char sauvType [20];
      	char sauvOpr[20];
      	int sauvConstInt=-1;
      	float sauvConstReal=-1;
        int yylex();
      	int NbrIdf =0;
    	#include <stdio.h>
    	#include <stdlib.h>
    	#include <string.h>
    	
    
      	typedef struct
    	{
    		char signFromatage;
    		char idf[20]; 
     
    	} compatibilite;
    
    	compatibilite tableau [20];
    
    %}
    
    %union {   
             int    entier;
             float  real;
             char*  string;
             char 	character;
             
           }
    %left                   addition              soustraction       
    %left                   multiplication        division       
    %left                   mc_and       mc_or      mc_not
    
    
    %token mc_pgm mc_stop mc_entier mc_char mc_float mc_string mc_const mc_accept mc_display mc_not mc_and mc_or mc_if mc_else mc_move mc_to mc_end mc_inf mc_sup mc_infe mc_supe mc_egal mc_diff <string>idf <entier>cstInt <real>cstFloat <character>cstChar <string>cstString egal division addition soustraction multiplication  parentheseo parenthesef  deuxpts point  arobase htag barre 
    
    %start S
    %%
    S: mc_pgm idf DEC LIST_INST  mc_stop 
       {printf("Le programme est correcte syntaxiquement"); YYACCEPT;}
    ;
    
    DEC: DEC_VAR {strcpy(sauvType," ");}
      |  DEC_CST
    ;                                
    
    DEC_VAR:  LIST_IDF TYPE point
           |
    ;
    
    TYPE:  mc_entier  {strcpy(sauvType,"INTEGER");}
         | mc_float   {strcpy(sauvType,"FLOAT");}
         | mc_char    {strcpy(sauvType,"CHAR");}
         | mc_string  {strcpy(sauvType,"STR");}
    ;
    
    
    LIST_IDF: idf barre LIST_IDF
    		  {
    			if (rechercheNonDeclare($1)==0) {insererType($1,sauvType);}
    			else {printf("Erreur semantique 'double declaration' a la ligne %d,la variable %s est deja declaree \n", nb_ligne, $1);}
    	  	}
        | idf
    		{
    			if (rechercheNonDeclare($1)==0) {insererType($1,sauvType);}
    			else {printf("Erreur semantique 'double declaration' a la ligne %d, la variable %s est deja declaree \n", nb_ligne, $1);}
    		}
    ;
    
    DEC_CST: mc_const idf TYPE point
            | mc_const idf egal cstInt point
             {
    					CodeCst($2);
    					if (rechercheNonDeclare($2)==0) {insererType($2,sauvType);}
    					else {printf("Erreur semantique 'double declaration' a la ligne	%d, la variable %s est deja declaree \n", nb_ligne, $2);}
    					if (CompType($2,"INTEGER")==0) {printf("Erreur semantique a la ligne %d : ICOMPATIBILITE DE TYPE de la variable %s \n", nb_ligne, $2);}
    			  	}
            | mc_const idf egal cstFloat point
             {
    					CodeCst($2);
    					if (rechercheNonDeclare($2)==0) {insererType($2,sauvType);}
    					else {printf("Erreur semantique 'double declaration' a la ligne %d, la variable %s est deja declaree \n", nb_ligne, $2);}
    					if (CompType($2,"FLOAT")==0) {printf("Erreur semantique a la ligne %d : ICOMPATIBILITE DE TYPE de la variable %s \n", nb_ligne, $2);}
    			  	}
            | mc_const idf egal cstChar point
             {
    					CodeCst($2);
    					if (rechercheNonDeclare($2)==0) {insererType($2,sauvType);}
    					else {printf("Erreur semantique 'double declaration' a la ligne %d, la variable %s est deja declaree \n", nb_ligne, $2);}
    					if (CompType($2,"CHAR")==0) {printf("Erreur semantique a la ligne %d : ICOMPATIBILITE DE TYPE de la variable %s \n", nb_ligne, $2);}
    			  	}
            | mc_const idf egal cstString point
             {
    					CodeCst($2);
    					if (rechercheNonDeclare($2)==0) {insererType($2,sauvType);}
    					else {printf("Erreur semantique 'double declaration' a la ligne %d, la variable %s est deja declaree \n", nb_ligne, $2);}
    					if (CompType($2,"STR")==0) {printf("Erreur semantique a la ligne %d : ICOMPATIBILITE DE TYPE de la variable %s \n", nb_ligne, $2);}
    			  	}
    ;
    LIST_INST:INST LIST_INST                  
             |                                
    ;		 
    INST:  INST_AFF
          |INST_IF
          |INST_MOVE
          |INST_ENTREE
          |INST_SORTIE
    ;
    INST_AFF: idf egal cstChar point
    			{
    				if (CompType($1,"CHAR")==0) {printf("Erreur semantique a la ligne %d : ICOMPATIBILITE DE TYPE de la variable %s \n", nb_ligne, $1);}
    				if (VerifIDFConst($1)==1){printf("Erreur semantique a la ligne  %d : la variable %s est une constante, affectation impossible\n",nb_ligne,$1);}
    				if (rechercheNonDeclare($1)==0){printf("Erreur semantique a la ligne  %d : la variable %s n'est pas declaree !!\n",nb_ligne,$1);}
    			}
    		| idf egal cstString point
    			{
    				if (CompType($1,"STRING")==0) {printf("Erreur semantique a la ligne %d : ICOMPATIBILITE DE TYPE de la variable %s \n", nb_ligne, $1);}
    				if (VerifIDFConst($1)==1) {printf("Erreur semantique a la ligne  %d : la variable %s est une constante, affectation impossible\n",nb_ligne,$1);}
    				if (rechercheNonDeclare($1)==0 ) {printf("Erreur semantique a la ligne  %d : la variable %s n'est pas declaree !!\n",nb_ligne,$1);}
    			}
    		| idf egal EXPRESSION_ARTHMTQ point
    			{
    				if ((CompType($1,"INTEGER")==0) && (CompType($1,"FLOAT")==0)) 
    				{printf("Erreur semantique a la ligne %d : ICOMPATIBILITE DE TYPE de la variable %s \n", nb_ligne, $1);}
    				if (VerifIDFConst($1)==1){printf("Erreur semantique a la ligne  %d : la variable %s est une constante, affectation impossible\n",nb_ligne,$1);}
    				if (rechercheNonDeclare($1)==0 ){printf("Erreur semantique a la ligne  %d : la variable %s n'est pas declaree !!\n",nb_ligne,$1);}
    			}
    ;
    EXPRESSION_ARTHMTQ: OPERANDE OPERATEUR OPERANDE 
                  	{
    	               	if((strcmp(sauvOpr,"/")==0)&& sauvConstInt==0)
                      {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne);
    		              sauvConstInt=-1;}
    	              	else if ((strcmp(sauvOpr,"/")==0)&& sauvConstReal==0) {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstReal=-1.0;}
                  	}
    					|OPERANDE
    					|parentheseo OPERANDE parenthesef OPERATEUR OPERANDE
              	{
              		if((strcmp(sauvOpr,"/")==0)&& sauvConstInt==0)
                  {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); 
    		          sauvConstInt=-1;}
    	          	else if ((strcmp(sauvOpr,"/")==0)&& sauvConstReal==0) {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstReal=-1.0;}
    	          }
    					|OPERANDE OPERATEUR parentheseo OPERANDE parenthesef
    	          {
    	          	if((strcmp(sauvOpr,"/")==0)&& sauvConstInt==0)
                  {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstInt=-1;}
    		          else if ((strcmp(sauvOpr,"/")==0)&& sauvConstReal==0) {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstReal=-1.0;}
    	          }
    					|parentheseo OPERANDE parenthesef OPERATEUR parentheseo OPERANDE parenthesef
    	         {
    		         if((strcmp(sauvOpr,"/")==0)&& sauvConstInt==0)
                 {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstInt=-1;}
    	           else if ((strcmp(sauvOpr,"/")==0)&& sauvConstReal==0) {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstReal=-1.0;}
               } 
    					|OPERANDE OPERATEUR OPERANDE OPERATEUR EXPRESSION_ARTHMTQ
              	{
    	          	if((strcmp(sauvOpr,"/")==0)&& sauvConstInt==0)
                  {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstInt=-1;}
    	           	else if ((strcmp(sauvOpr,"/")==0)&& sauvConstReal==0) {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstReal=-1.0;}
                }
    					|parentheseo OPERANDE parenthesef			
    					|parentheseo OPERANDE parenthesef OPERATEUR OPERANDE OPERATEUR EXPRESSION_ARTHMTQ
              	{
    		          if((strcmp(sauvOpr,"/")==0)&& sauvConstInt==0)
                  {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstInt=-1;}
    		          else if ((strcmp(sauvOpr,"/")==0)&& sauvConstReal==0) {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstReal=-1.0;}
    	          }
    					|OPERANDE OPERATEUR parentheseo OPERANDE parenthesef OPERATEUR EXPRESSION_ARTHMTQ
              	{
    		          if((strcmp(sauvOpr,"/")==0)&& sauvConstInt==0)
                  {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstInt=-1;}
    		          else if ((strcmp(sauvOpr,"/")==0)&& sauvConstReal==0) {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstReal=-1.0;}
                }
    					|parentheseo OPERANDE parenthesef OPERATEUR parentheseo OPERANDE parenthesef OPERATEUR EXPRESSION_ARTHMTQ
              	{
    	          	if((strcmp(sauvOpr,"/")==0)&& sauvConstInt==0)
                  {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstInt=-1;}
    	          	else if ((strcmp(sauvOpr,"/")==0)&& sauvConstReal==0) {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstReal=-1.0;}
              	}	
    					|parentheseo OPERANDE OPERATEUR OPERANDE parenthesef
              	{
    	          	if((strcmp(sauvOpr,"/")==0)&& sauvConstInt==0)
                  {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstInt=-1;}
    	          	else if ((strcmp(sauvOpr,"/")==0)&& sauvConstReal==0) {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstReal=-1.0;}
    	          }	
    					|parentheseo OPERANDE OPERATEUR OPERANDE parenthesef OPERATEUR EXPRESSION_ARTHMTQ
              	{
    	          	if((strcmp(sauvOpr,"/")==0)&& sauvConstInt==0)
                  {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstInt=-1;}
    	          	else if ((strcmp(sauvOpr,"/")==0)&& sauvConstReal==0) {printf(" Erreur semantique 'division par zero' a la ligne %d \n",nb_ligne); sauvConstReal=-1.0;}
              	}						
    ;
    OPERATEUR: OPERATEUR_LOGIQUE
             | OPERATEUR_ARITHM
             | OPERATEUR_COMP
    ;         
    OPERATEUR_ARITHM: addition
    	              	{
    			              strcpy(sauvOpr,"+");
    	              	}
    	            	| soustraction
    	              	{
    		              	strcpy(sauvOpr,"-");
    	              	}
    	            	| division
    	              	{
    		              	strcpy(sauvOpr,"/");
    		              }
    	            	| multiplication
    	               	{
    		              	strcpy(sauvOpr,"*");
    	              	}
    ;
    OPERATEUR_LOGIQUE: mc_and
                     | mc_not
                     | mc_or
    ;
    OPERATEUR_COMP: mc_egal
    			      	| mc_inf
    			      	| mc_sup
    			      	| mc_infe
    			      	| mc_supe
    			      	| mc_diff
    ;
    OPERANDE: idf
    		    	{
    		       	if (rechercheNonDeclare($1)==0 ){printf("Erreur semantique a la ligne  %d : la variable %s n'est pas declaree !!\n",nb_ligne,$1);}
    			    }
    	    	| cstInt 
    	      	{    
    		      	sauvConstInt=$1;           
    	      	}  
    	    	| cstFloat
    	      	{    
    		      	sauvConstReal=$1;           
    	      	}  
    ;
    INST_ENTREE: mc_accept parentheseo cstString deuxpts arobase IDF_ENTREE parenthesef point
    			{
    				if (NbrIdf != 1 || NbrSgnFormat($3)!=1)
    		  	{ printf("Erreur semantique a la ligne %d : Le nombre de signes de formatages et de variables doit etre egal a 1\n", nb_ligne);}
    			  else {
    			   	insererSignFormat($3,tableau);
    			  	if (verifierCompatibilite(tableau,NbrIdf)!=0)
    					{printf("Erreur semantique a la ligne %d : INCOMPATIBILIE de	type de la variabe numero %d dans l instruction ACCEPT \n",nb_ligne,verifierCompatibilite(tableau,NbrIdf));}
    			  	initialiseTableau(tableau);
    		      	}
    				NbrIdf = 0;
    	
    			}
    ;                                    
    IDF_ENTREE: idf
    			{
    				strcpy(tableau[NbrIdf].idf,$1);
    				NbrIdf++;
    				if(rechercheNonDeclare($1)==0){printf("Erreur semantique a la ligne  %d : la variable %s n'est pas declaree !!\n",nb_ligne,$1);}
    			}
    ;
    INST_SORTIE: mc_display parentheseo cstString deuxpts IDF_SORTIE  parenthesef point
    		{
    			if (NbrIdf != NbrSgnFormat($3))
    			{ printf("Erreur semantique a la ligne %d : Le nombre de signes de formatages n'est pas egal au nombre de variables \n", nb_ligne);}
    			else {
    				insererSignFormat($3,tableau);
    				if (verifierCompatibilite(tableau,NbrIdf)!=0)
    				{ printf("Erreur semantique a la ligne %d : INCOMPATIBILIE de type de la variabe numero %d dans l'instruction DISPLAY \n",nb_ligne,verifierCompatibilite(tableau,NbrIdf));}
    				
    				initialiseTableau(tableau);
    			}
    			NbrIdf=0;
    		}
    ;
    IDF_SORTIE: idf 
    			{
    				strcpy(tableau[NbrIdf].idf,$1);
    				NbrIdf++;
    				if (rechercheNonDeclare($1)==0 ){printf("Erreur semantique a la ligne  %d : la variable %s n'est pas declaree !!\n",nb_ligne,$1);}
    			}
    ;
    INST_IF:  mc_if parentheseo COND parenthesef INST mc_else deuxpts INST mc_end
    ;
    COND: EXPRESSION_ARTHMTQ 
        | idf point idf point idf
        | mc_not EXPRESSION_ARTHMTQ
    ;
    
    
    INST_MOVE: mc_move idf mc_to idf INST mc_end
            |  mc_move idf mc_to cstInt INST mc_end
            |  mc_move idf mc_to cstFloat INST mc_end
            |  mc_move cstInt mc_to cstInt mc_end
            |  mc_move cstFloat mc_to cstFloat mc_end
            |  mc_move cstInt mc_to cstFloat mc_end
            |  mc_move cstFloat mc_to cstInt mc_end
    ;
    
    
     %%
    main ()
    {
       initialisation();
       initialiseTableau(tableau);
       yyparse(); 
       printf("\n");
       afficher();
     }
     yywrap ()
     {}
     int yyerror ( char*  msg ) 
    {
        printf ("Erreur Syntaxique a la ligne %d a la colonne %d \n", nb_ligne,Col);
    } 
    
    TableDesSymboles.h
    /****************CREATION DE LA TABLE DES SYMBOLES ******************/
    /***Step 1: Definition des structures de données ***/
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    typedef struct
    {
       int state;
       char name[20];
       char code[20];
       char type[20];
       float val;
     } element;
    
    typedef struct
    { 
       int state; 
       char name[20];
       char code[20];
       char type[20];
    } elt;
    	typedef struct
    	{
    		char signFromatage;
    		char idf[20]; 
     
    	} compatibilite;
    
    element tab[1000];
    elt tabs[40],tabm[40];
    
    
    /***Step 2: initialisation de l'état des cases des tables des symbloles***/
    /*0: la case est libre    1: la case est occupée*/
    
    void initialisation()
    {
      int i;
      for (i=0;i<1000;i++)                            
      tab[i].state=0;
      
      
    
      for (i=0;i<40;i++)
        {tabs[i].state=0;
        tabm[i].state=0;}
    
    }
    
    
    /***Step 3: insertion des entititées lexicales dans les tables des symboles ***/
    
    void inserer (char entite[], char code[],char type[],float val,int i, int y)
    {
      switch (y)
     { 
       case 0:/*insertion dans la table des IDF et CONST*/
           tab[i].state=1;
           strcpy(tab[i].name,entite);
           strcpy(tab[i].code,code);
    	   strcpy(tab[i].type,type);
    	   tab[i].val=val;
    	   break;
    
       case 1:/*insertion dans la table des mots clés*/
           tabm[i].state=1;
           strcpy(tabm[i].name,entite);
           strcpy(tabm[i].code,code);
    	     strcpy(tabm[i].type,type);
           break; 
        
       case 2:/*insertion dans la table des séparateurs*/
          tabs[i].state=1;
          strcpy(tabs[i].name,entite);
          strcpy(tabs[i].code,code);
          break;
     }
    
    }
    
    /***Step 4: La fonction Rechercher permet de verifier  si l'entité existe dèja dans la table des symboles */
    void rechercher (char entite[], char code[],char type[],float val,int y)	
    {
    
    int j,i;
    
    switch(y) 
      {
       case 0:/*verifier si la case dans la tables des IDF et CONST est libre*/
            for (i=0;((i<1000)&&(tab[i].state==1))&&(strcmp(entite,tab[i].name)!=0);i++); 
            if(tab[i].state==0)
            { 
    	        
    			inserer(entite,code,type,val,i,0); 
    	      
             }
    		 
            else if (strcmp(entite,tab[i].name)==0){
              printf("entite (%s) existe deja\n",entite);
    		}
    		else if (i>=1000)
    		{ printf("La table des symboles des idfs est pleine");}
            break;
    
       case 1:/*verifier si la case dans la tables des mots clés est libre*/
           
           for (i=0;((i<40)&&(tabm[i].state==1))&&(strcmp(entite,tabm[i].name)!=0);i++); 
            if(tabm[i].state==0){
    		inserer(entite,code,type,val,i,1);}
            else if (strcmp(entite,tabm[i].name)==0){
    		printf("entite (%s) existe deja\n",entite);}
    		else if (i>=40){
    		printf ("La table des mots cles est pleine");}
            break; 
        
       case 2:/*verifier si la case dans la tables des séparateurs est libre*/
             for (i=0;((i<40)&&(tabs[i].state==1))&&(strcmp(entite,tabs[i].name)!=0);i++); 
            if(i<40)
             inserer(entite,code,type,val,i,2);
            else
       	       printf("entite (%s) existe deja\n",entite);
            break;
    
      }
    
    }
    
    
    /***Step 5 L'affichage du contenue de la table des symboles ***/
    
    void afficher() {
        int i;
        printf("/***************Table des symboles IDF*************/\n");
        printf("____________________________________________________________________\n");
        printf("\t| Nom_Entite |  Code_Entite | Type_Entite | Val_Entite\n");
        printf("____________________________________________________________________\n");
        
        for(i=0;i<50;i++) {	
            if(tab[i].state==1)
            { 
                printf("\t|%10s |%15s | %12s | %12f\n",tab[i].name,tab[i].code,tab[i].type,tab[i].val);    
            }
        }
    
     
        printf("\n/***************Table des symboles mots cles*************/\n");
    
        printf("___________________________________________________\n");
        printf("\t| Nom_Entite |  Code_Entite | Type_Entite |\n");
        printf("___________________________________________________\n");
        
        for(i=0;i<40;i++){
            if(tabm[i].state==1){ 
                printf("\t|%10s |%12s | |%12s | \n",tabm[i].name, tabm[i].code, tabm[i].type);       
            }
        }
    
        printf("\n/***************Table des symboles separateurs*************/\n");
    
        printf("_____________________________________\n");
        printf("\t| NomEntite |  CodeEntite | \n");
        printf("_____________________________________\n");
        
        for(i=0;i<40;i++){
            if(tabs[i].state==1) { 
                printf("\t|%10s |%12s | \n",tabs[i].name,tabs[i].code );   
            }
        } 
    }
    
    /***Step 6 : la fonction qui retourne la position d'un IDF  ***/
    
    int rechercherIDF(char entite[]){
      int i=0;
      for (i; i<1000; i++){
        if (strcmp(entite,tab[i].name)==0){return i;}//retourne la position de l'IDF
      }
      return -1;//si l'IDF n'existe pas
    }
    
    
    
    
    /***Step 7 : la fonction qui permet de vérifier si une variable (IDF) est déclarée ***/
    
    int rechercheNonDeclare(char entite[]) {
      int position;
      position=rechercherIDF(entite);
           if (position != -1 && strcmp(tab[position].type," ")==0){ return 0;} // la variable n'est pas declaree.
           else {return 1;} // la variable est declaree.
    }
    
    /***Step 8 : definir une focntion qui detecte la double declaration ***/
      /* int doubleDeclaration(char entite[])
    	{
    	int pos;
    	pos=recherche(entite);
    	if(strcmp(ts[pos].TypeEntite,"")==0) return 0;
    	   else return -1;
    	   
    	}*/ 
    	
    
    
    
    /***Step 9 : la fonction qui permet d'inserer un type à une variable (IDF) ***/
     
    void insererType(char entite[], char type[])
    	{
       int position;
       position =rechercherIDF(entite);
    	 if(position !=-1)
    	  {
    	    strcpy(tab[position].type,type); 
    	  }
      }
    
    
    
    
    /***Step 10 : la fonction qui modifie le code des idfs constants ***/
    
    void CodeCst (char entite [])
    {
    	int position;
    	position =rechercherIDF(entite);
    	if (position != -1) 
    	{
    		strcpy(tab[position].code,"IDF CONSTANT");
    	}
    }
    
    
    /***Step 11 : la fonction qui sauvegarde la valeur des variables ***/ 
    
    void SaveValue(char entite[], float val)
    {
    	int position;
    	position =rechercherIDF(entite);
    	if (position != -1) 
    	{
    		tab[position].val=val;
    	}
    }
    
    
    /***Step 12 : la fonction qui verifie si l'idf est une constante ***/
    
    int VerifIDFConst(char entite[])
    {
    	int position;
    	position =rechercherIDF(entite);
    	if (position != -1) 
    	{
    		if (strcmp(tab[position].code,"IDF CONSTANT")==0){return 1;}//l'idf est un IDF CONSTANT
    		else {return 0;}// l'idf n'est pas un IDF CONSTANT
    	}
    }
    
    
    /***Step 13 : la fonction qui retourne le nombre de signe de formatage ***/
    
    int NbrSgnFormat (char chaine [])
    {
    	int i =0;
    	int taille = strlen(chaine);
    	int compteur=0;
    	for (i=0; i<taille; i++)
    	{
    		if ((chaine[i]==';') || (chaine[i]=='%') || (chaine[i]=='&') || (chaine[i]=='?'))
    		{
    			compteur++;
    		}
    	}
    	return compteur;
    }
    
    
    /***Step 14 : la fonction qui retourne verifie la compatibilité des types  ***/
    
    int CompType (char entite [], char type [])
    {
    	int position;
    	position =rechercherIDF(entite);
    	if (position != -1) 
    	{
    		if (strcmp(tab[position].type,type)==0){return 1;}//le type est compatible
    		else {return 0;}//le type n'est pas compatible
    	}
    }
    
    /***Step 15 : la fonction qui insere les signes de formatage d une instruction dans un tableau  ***/
    
     void insererSignFormat (char chaine[],compatibilite tableau[]){
      int i = 0;
      int j= 0;
    	int taille = strlen(chaine);
      	for (i=0; i<taille; i++)
    	{
    		switch (chaine[i])
        {
        case  ';'/* constant-expression */:
          tableau[j].signFromatage =';';/* code */
          j++;
          break;
        case  '?'/* constant-expression */:
          tableau[j].signFromatage ='?';/* code */
          j++;
          break;
        case  '&'/* constant-expression */:
          tableau[j].signFromatage ='&';/* code */
          j++;
          break;      
        case  '%'/* constant-expression */:
          tableau[j].signFromatage ='%';/* code */
          j++;
          break;    
        default:
          break;
        }
      }
    
    
     }
    /***Step 16 : la fonction qui retourne le type de l iDF passe  a la fonction  ***/
    
    char* retournType(char entite[]){
      int position=0;
      position = rechercherIDF(entite);
      if (position!=-1){
        return tab[position].type;
      }
    }
    
    
    /***Step 17 : la fonction qui verifier la compatibilite entre  le signe de formatage et la variable dans un tableau  ***/
    
    int verifierCompatibilite(compatibilite tableau[],int nbr){
      int i = 0;
      for (i; i<nbr; i++){
        switch (tableau[i].signFromatage)
        {
        case ';'/* constant-expression */:
          /* code */
          if (strcmp(retournType(tableau[i].idf),"INTEGER")!=0){return i+1;} // incompatibilie de type dans la case i / la variable numero i+1
          break;
        case '%'/* constant-expression */:
          /* code */
          if (strcmp(retournType(tableau[i].idf),"REAL")!=0){return i+1;}
          break;
        case '?'/* constant-expression */:
          /* code */
          if (strcmp(retournType(tableau[i].idf),"STRING")!=0){return i+1;}
          break;
        case '&'/* constant-expression */:
          /* code */
          if (strcmp(retournType(tableau[i].idf),"CHAR")!=0){return i+1;}
          break;    
        default:
          break;
        }
      }
      return 0 ; // tous les types sont  compatible
    
    }
    
    /***Step 18 : la fonction qui initialise  les variabes du tableau compatibilite a zero  a   ***/
    void initialiseTableau(compatibilite tableau[]){
      int i = 0; 
      int taille = sizeof(tableau);
      for (i; i<taille; i++){
        tableau[i].signFromatage=' ';
        strcpy(tableau[i].idf," ");
      }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
     

    • Partager sur Facebook
    • Partager sur Twitter
      3 janvier 2022 à 17:06:37

      Bonjour,

      premier point :

      $ bison -Wall -d t.y
      t.y:50.9: warning: empty rule without %empty [-Wempty-rule]
         50 |        |
            |         ^
            |         %empty
      t.y:103.11: warning: empty rule without %empty [-Wempty-rule]
        103 |          |                               
            |           ^
            |           %empty
      t.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
      t.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
      t.y:34.1-5: warning: useless precedence and associativity for mc_not [-Wprecedence]
         34 | %left                   mc_and       mc_or      mc_not
            | ^~~~~
      t.y:34.1-5: warning: useless precedence and associativity for mc_and [-Wprecedence]
         34 | %left                   mc_and       mc_or      mc_not
            | ^~~~~
      t.y:34.1-5: warning: useless precedence and associativity for mc_or [-Wprecedence]
         34 | %left                   mc_and       mc_or      mc_not
            | ^~~~~
      t.y:33.1-5: warning: useless precedence and associativity for division [-Wprecedence]
         33 | %left                   multiplication        division      
            | ^~~~~
      t.y:32.1-5: warning: useless precedence and associativity for addition [-Wprecedence]
         32 | %left                   addition              soustraction      
            | ^~~~~
      t.y:32.1-5: warning: useless precedence and associativity for soustraction [-Wprecedence]
         32 | %left                   addition              soustraction      
            | ^~~~~
      t.y:33.1-5: warning: useless precedence and associativity for multiplication [-Wprecedence]
         33 | %left                   multiplication        division      
            | ^~~~~
      t.y: warning: fix-its can be applied.  Rerun with option '--update'. [-Wother]
      

      que l'on peut compléter par :

      $ bison -Wcounterexamples -d t.y
      t.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
      t.y: warning: shift/reduce conflict on token idf [-Wcounterexamples]
        First example: mc_pgm idf • idf barre LIST_IDF TYPE point LIST_INST mc_stop
        Shift derivation
          S
          ↳ 1: mc_pgm idf DEC                                             LIST_INST mc_stop
                          ↳ 2: DEC_VAR
                               ↳ 4: LIST_IDF                   TYPE point
                                    ↳ 10: • idf barre LIST_IDF
        Second example: mc_pgm idf • idf egal cstChar point LIST_INST mc_stop $end
        Reduce derivation
          $accept
          ↳ 0: S                                                                                        $end
               ↳ 1: mc_pgm idf DEC           LIST_INST                                          mc_stop
                               ↳ 2: DEC_VAR  ↳ 17: INST                               LIST_INST
                                    ↳ 5: ε •       ↳ 19: INST_AFF
                                                         ↳ 24: idf egal cstChar point
      t.y: warning: shift/reduce conflict on token idf [-Wcounterexamples]
        First example: mc_pgm idf • idf TYPE point LIST_INST mc_stop
        Shift derivation
          S
          ↳ 1: mc_pgm idf DEC                              LIST_INST mc_stop
                          ↳ 2: DEC_VAR
                               ↳ 4: LIST_IDF    TYPE point
                                    ↳ 11: • idf
        Second example: mc_pgm idf • idf egal cstChar point LIST_INST mc_stop $end
        Reduce derivation
          $accept
          ↳ 0: S                                                                                        $end
               ↳ 1: mc_pgm idf DEC           LIST_INST                                          mc_stop
                               ↳ 2: DEC_VAR  ↳ 17: INST                               LIST_INST
                                    ↳ 5: ε •       ↳ 19: INST_AFF
                                                         ↳ 24: idf egal cstChar point
      

      Sinon je suppose que tu comprends tes erreurs typiquement C ? ou bien doit-on te les expliquer ?


      • Partager sur Facebook
      • Partager sur Twitter
        3 janvier 2022 à 17:25:00

        Oui merci beaucoup j'ai compris sauf pour les erreurs de [-Wimplicit-function-declaration]

        • Partager sur Facebook
        • Partager sur Twitter
          3 janvier 2022 à 17:28:43

          Il faut toujours déclarer les fonctions avant de les utiliser, sans doute un header que tu auras oublié d'inclure … (je n'ai pas lu ton code).
          • Partager sur Facebook
          • Partager sur Twitter
            4 janvier 2022 à 11:24:53

            Bonjour dans le meme programme avec des petites modifications quand j'exécute j'aurai ces problèmes 

            C:\Users\sg info\OneDrive - Ecole Nationale Supérieure des Travaux Publics\Bureau\Documents\COMPIL>gcc SyntaxiqueProjet.tab.c -o ryane -lfl
            In file included from SyntaxiqueProjet.y:5:
            ts.h: In function 'initialiseTableau':
            ts.h:372:22: warning: 'sizeof' on array function parameter 'tableau' will return size of 'compatibilite *' [-Wsizeof-array-argument]
              372 |   int taille = sizeof(tableau);
                  |                      ^
            ts.h:370:38: note: declared here
              370 | void initialiseTableau(compatibilite tableau[]){
                  |                        ~~~~~~~~~~~~~~^~~~~~~~~
            SyntaxiqueProjet.tab.c: In function 'yyparse':
            SyntaxiqueProjet.tab.c:1935:7: warning: implicit declaration of function 'yyerror'; did you mean 'yyerrok'? [-Wimplicit-function-declaration]
             1935 |       yyerror (YY_("syntax error"));
                  |       ^~~~~~~
                  |       yyerrok
            C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lfl
            collect2.exe: error: ld returned 1 exit status

            la fonction qui me donne cette erreur est la suivante 

            /***Step 18 : la fonction qui initialise  les variabes du tableau compatibilite a zero  a   ***/
            void initialiseTableau(compatibilite tableau[]){
              int i = 0; 
              int taille = sizeof(tableau);
              for (i; i<taille; i++){
                tableau[i].signFromatage=' ';
                strcpy(tableau[i].idf," ");
              }
            }

            Pour l'erreur de yyerror j'ai meme pas compris la raison et la meme chose pour

            C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lfl
            collect2.exe: error: ld returned 1 exit status




            • Partager sur Facebook
            • Partager sur Twitter
              4 janvier 2022 à 11:36:54

              Pour le premier point :

              Un paramètre de type tableau sera toujours transformé en pointeur sur le premier élément. sizeof ne donnera donc jamais la taille du tableau mais la taille d'un pointeur. Si tu as besoin du nombre d'éléments dans un tableau il faut le fournir en paramètre supplémentaire :

              void initialiseTableau(size_t taille, compatibilite tableau[]){
                 ...
              }


              Le second point t'indique que l'éditeur de liens ne trouve pas la bibliothèque libflex … il faut lui en donner le chemin ou l'installer si elle ne l'est pas …

              • Partager sur Facebook
              • Partager sur Twitter
                4 janvier 2022 à 11:55:16

                Si vous pouvez me répondre juste pour yyerror 

                SyntaxiqueProjet.tab.c: In function 'yyparse':
                SyntaxiqueProjet.tab.c:1935:7: warning: implicit declaration of function 'yyerror'; did you mean 'yyerrok'? [-Wimplicit-function-declaration]
                 1935 |       yyerror (YY_("syntax error"));
                      |       ^~~~~~~
                      |       yyerrok


                et ce probleme

                C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lfl
                collect2.exe: error: ld returned 1 exit status



                • Partager sur Facebook
                • Partager sur Twitter
                  4 janvier 2022 à 12:05:52

                  Ryane a écrit:

                  Si vous pouvez me répondre juste pour yyerror 

                  SyntaxiqueProjet.tab.c: In function 'yyparse':
                  SyntaxiqueProjet.tab.c:1935:7: warning: implicit declaration of function 'yyerror'; did you mean 'yyerrok'? [-Wimplicit-function-declaration]
                   1935 |       yyerror (YY_("syntax error"));
                        |       ^~~~~~~
                        |       yyerrok

                  White Crow a écrit:

                  Il faut toujours déclarer les fonctions avant de les utiliser, sans doute un header que tu auras oublié d'inclure … (je n'ai pas lu ton code).


                  et c'est quoi ce yyerrok ??? un typo ???

                  Ryane a écrit:

                  [...]

                  et ce probleme

                  C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lfl
                  collect2.exe: error: ld returned 1 exit status

                  White Crow a écrit:

                  [...]

                  Le second point t'indique que l'éditeur de liens ne trouve pas la bibliothèque libflex … il faut lui en donner le chemin ou l'installer si elle ne l'est pas …



                  • Partager sur Facebook
                  • Partager sur Twitter

                  Flex Bison

                  × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
                  × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
                  • Editeur
                  • Markdown