Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1305 connectés 

  FORUM HardWare.fr
  Programmation
  C

  [Yacc/Bison] Probleme avec yylineno

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[Yacc/Bison] Probleme avec yylineno

n°1234072
cervantes
Posté le 29-10-2005 à 13:45:49  profilanswer
 

J'ai un programme C appelé y.tab.c créé à partir de Bison. Je l'ai compilé avec gcc 2.95, j'ai eu plusieurs warning mais j'ai réussi à obtenir mon .o
 
Mon probleme vient apres lorsque je souhaite linker y.tab.o avec d'autres programmes. PAr exemple pour ceci:
 

Code :
  1. gcc-2 -o analyse_ft analyse_ft.c outils_conversions.o y.tab.o
  2. y.tab.o(.text+0x1408):y.tab.c: undefined reference to `yylineno'
  3. y.tab.o(.text+0x142e):y.tab.c: undefined reference to `yylineno'
  4. y.tab.o(.text+0x1490):y.tab.c: undefined reference to `yylineno'
  5. y.tab.o(.text+0x14b6):y.tab.c: undefined reference to `yylineno'
  6. y.tab.o(.text+0x1514):y.tab.c: undefined reference to `yylineno'
  7. y.tab.o(.text+0x153a):y.tab.c: more undefined references to `yylineno' follow


 
 
Je comprends pas d'ou vient mon probleme, sachant que j'ai bien yylineno de définit dans mon programme y.tab.c.  
J'ai mis l'ensemble du code de mon fichier y.tab.c ici http://ubuntu.pastebin.com/409861
et l'ensemble de mon fichier yacc ici: http://ubuntu.pastebin.com/409865
 
Quelqu'un sait d'ou pourrait venir le probleme?
 
++


Message édité par cervantes le 29-10-2005 à 13:48:42
mood
Publicité
Posté le 29-10-2005 à 13:45:49  profilanswer
 

n°1234266
jesus_chri​st
votre nouveau dieu
Posté le 29-10-2005 à 21:01:37  profilanswer
 

%option yylineno
 
?

n°1234267
jesus_chri​st
votre nouveau dieu
Posté le 29-10-2005 à 21:03:04  profilanswer
 

j'ai matté tes liens : en flex/bison ne donne pas le code généré (y.tab.c) ça sert à rien, de toute façon tu ne peux pas le modifier, à chaque recompilation de ton yacc il serait écrasé.

n°1234281
cervantes
Posté le 29-10-2005 à 21:47:42  profilanswer
 

Ah ok, j'y connais presque rien en yacc, le code c'est pas moi qui l'est fait, j'essai juste de le recompiler sur windows pour ensuite l'utiliser avec d'autre programmes.
D'ailleurs, ou je peux le mettre %option yylineno dans le .yacc?  j'ai effectivement" extern int      yylineno;" mais je ne sais pas pourquoi il est en extern, j'ai regardé mon fichier .lex et je n'ai aucune référence à  yylineno. Au passage, en deux mots, ca sert à quoi yylineno?
 
Apparemment tu à l'air de t'y connaitre dans le domaine, jesus_christ. Peut etre pourras tu m'expliquer pourquoi j'ai ces warnings quand je compile mon fichier .yacc. LEs voici:
 

Code :
  1. scription_fichier_correspondance.yacc:275: warning: type mismatch with previous implicit declaration
  2. description_fichier_correspondance.yacc:102: warning: previous implicit declaration of `fichier_correspondance_error'
  3. description_fichier_correspondance.yacc:275: warning: `fichier_correspondance_error' was previously implicitly declared to return
  4. `int'
  5. description_fichier_correspondance.yacc:299: warning: type mismatch with previous implicit declaration
  6. y.tab.c:1287: warning: previous implicit declaration of `yyerror'
  7. description_fichier_correspondance.yacc:299: warning: `yyerror' was previously implicitly declared to return `int'
  8. description_fichier_correspondance.yacc:345: warning: type mismatch with previous implicit declaration
  9. description_fichier_correspondance.yacc:94: warning: previous implicit declaration of `tete_correspondance'
  10. description_fichier_correspondance.yacc:345: warning: `tete_correspondance' was previously implicitly declared to return `int'
  11. description_fichier_correspondance.yacc:380: warning: type mismatch with previous implicit declaration
  12. description_fichier_correspondance.yacc:100: warning: previous implicit declaration of `add_correspondance'
  13. description_fichier_correspondance.yacc:380: warning: `add_correspondance' was previously implicitly declared to return `int'
  14. description_fichier_correspondance.yacc:430: warning: type mismatch with previous implicit declaration
  15. description_fichier_correspondance.yacc:109: warning: previous implicit declaration of `cre_correspondance'
  16. description_fichier_correspondance.yacc:430: warning: `cre_correspondance' was previously implicitly declared to return `int'


 
Je te renvoie au lien de mon premier message pour le code du .yacc. Je te pose cet question car initialement j'utilisais mingw avec gcc 3.42 et les warnings cidessus étaient remplacés par des errors, par chance avec la versions 2.95 j'ai réussi à obtenir mon .o, mais j'ai toujours des problemes. Pour eviter ces erreurs/warnings, j'ai tant bien que mal essayer de "caster" les $1, $2.... de cre_correspondance( $1, $2, $3 , $4, $5, $6, $7 ), mais ca ne changea rien. La je ne vois pas pourquoi.
 
Thx, A+

n°1234287
jesus_chri​st
votre nouveau dieu
Posté le 29-10-2005 à 22:11:26  profilanswer
 

désolé mais à cette heure ci j'ai pas la force de tout lire :D
le "%option yylineno" se met dans le lexeur. D'ailleurs tu ne donnes pas ton lexeur ici (le truc en lex/flex) à moins que tu ne l'ai fait à la main (fonction yylex).

n°1234299
cervantes
Posté le 29-10-2005 à 23:27:03  profilanswer
 

Dans le lexeur je n'ai pas de yylineno. Voici le code:
 

Code :
  1. D [0-9]
  2.   /* mantisse */
  3. E [DEde][\+\-]?{D}+
  4.   /* exposant */
  5. H [0-9a-fA-F]
  6.   /* digit hexa */
  7. O [0-7]
  8.   /* digit octal */
  9. B [01]
  10.   /* digit binaire */
  11. %START CM
  12. %%
  13. "/*" {
  14. if (logfile != (FILE *)NULL)  
  15.  fprintf(logfile, "%s", yytext);
  16. BEGIN CM;
  17. }
  18. <CM>"*/" {
  19. if (logfile != (FILE *)NULL)
  20.  fprintf(logfile, "%s", yytext);
  21. BEGIN 0;
  22. }
  23. <CM>\*     |
  24. <CM>[a-zA-Z0-9_\-\.]*   |
  25. <CM>[\%\(\)\[\]\{\}\,\+\:\/ ]*  {
  26. if (logfile != (FILE *)NULL) fprintf(logfile, "%s", yytext);
  27. }
  28. [ \t\n] {
  29. if (logfile != (FILE *)NULL) fprintf(logfile, "%s", yytext);
  30. }
  31. [\(\)\[\]\{\}\,]  {
  32. if (logfile != (FILE *)NULL) fprintf(logfile, "%s", yytext);
  33. return *yytext;
  34. }
  35. \+?{D}+    {
  36. if (logfile != (FILE *)NULL) fprintf(logfile, "%s", yytext);
  37. yylval.ival = atol( yytext );
  38. return T_NONSIGNE;
  39. }
  40. \-{D}+    {
  41. if (logfile != (FILE *)NULL) fprintf(logfile, "%s", yytext);
  42. yylval.ival = atol( yytext );
  43. return T_ENTIER;
  44. }
  45. [\+\-]?{D}+"."{D}*({E})? |
  46. [\+\-]?{D}*"."{D}+({E})? |
  47. [\+\-]?{D}+{E}   {
  48. if (logfile != (FILE *)NULL) fprintf(logfile, "%s", yytext);
  49. yylval.dval = (double) atof( yytext );
  50. return T_DOUBLE;
  51. }
  52. \%[hH]{H}+   {
  53. if (logfile != (FILE *)NULL) fprintf(logfile, "%s", yytext);
  54. yylval.uval = (unsigned long) strtol(
  55.  yytext+2, (char **)NULL, 16);
  56. return T_NONSIGNE;
  57. }
  58. \%[bB]{B}+   {
  59. if (logfile != (FILE *)NULL) fprintf(logfile, "%s", yytext);
  60. yylval.uval = (unsigned long) strtol(
  61.  yytext+2, (char **)NULL, 2);
  62. return T_NONSIGNE;
  63. }
  64. \%[oO]{O}+   {
  65. if (logfile != (FILE *)NULL) fprintf(logfile, "%s", yytext);
  66. yylval.uval = (unsigned long) strtol(
  67.  yytext+2, (char **)NULL, 8);
  68. return T_NONSIGNE;
  69. }
  70. [a-zA-Z][a-zA-Z0-9_\-\.]*  {
  71. if (logfile != (FILE *)NULL) fprintf(logfile, "%s", yytext);
  72. yylval.sval = malloc( yyleng+1 );
  73. if ( yylval.sval == (char*)NULL )
  74. {
  75.            fprintf( stderr, "Memoire pleine\n" );
  76.            exit(-1);
  77. }
  78. strcpy( yylval.sval, yytext );
  79. return T_STR;
  80. }
  81. %%


 
Je suppose que le %option yylineno dont tu me parles, je le mets dans la partie déclaration.
Vi mon message etait un peu long,  :) , mais essai de jeter un oeil un peu plus tard, ca serait cool  :)  
 
++


Message édité par cervantes le 29-10-2005 à 23:27:41
n°1234385
jesus_chri​st
votre nouveau dieu
Posté le 30-10-2005 à 11:04:16  profilanswer
 

Code :
  1. D    [0-9]
  2.             /* mantisse    */
  3. E    [DEde][+-]?{D}+
  4.             /* exposant    */
  5. H    [0-9a-fA-F]
  6.             /* digit hexa    */
  7. O    [0-7]
  8.             /* digit octal    */
  9. B    [01]
  10.             /* digit binaire */
  11. %START CM
  12. %option yylineno
  13.        
  14. %%


je vais regarder le reste après ;)


Message édité par jesus_christ le 30-10-2005 à 11:04:49
n°1234396
jesus_chri​st
votre nouveau dieu
Posté le 30-10-2005 à 11:47:40  profilanswer
 

j'ai reconstruit ton projet, les lex et le yacc sont bons mais il me manque les entêtes :
#include "structure_correspondance.h"
#include "structure_format_thomson.h"
#include "leste.h"

n°1234448
cervantes
Posté le 30-10-2005 à 13:31:11  profilanswer
 

Slt,
 
Je t'ai mis le code source en message privé.
 
++

n°1234457
jesus_chri​st
votre nouveau dieu
Posté le 30-10-2005 à 13:49:38  profilanswer
 

tu as bien fait car ça m'a l'air de ne pas être open-source (propriété de thomson)

mood
Publicité
Posté le 30-10-2005 à 13:49:38  profilanswer
 

n°1234460
jesus_chri​st
votre nouveau dieu
Posté le 30-10-2005 à 14:05:22  profilanswer
 

chez moi ça compile après une correction : il manque une paranthèse ligne 94 environ du yacc :

Code :
  1. tete_correspondance( ( $1 );

n°1234488
cervantes
Posté le 30-10-2005 à 15:14:25  profilanswer
 

Ah j'ai du la virer sans faire attention car j'ai essayé de mettre des casts devant car j'avais des warnings.
 
Oui, c'est un truc propriétaire, mais si ca ne traine pas sur un forum ca ira  :)  
Ba tien je vais te donner le code de mon programme qui ne voulait pas compiler avec le y.tab.o (en privé)


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C

  [Yacc/Bison] Probleme avec yylineno

 

Sujets relatifs
Probleme en C++ de classeProblème de CSS
Probleme module et index VB6[Image]Probleme de rafraichissement
probleme avec les placeholderSQL loader probleme
Problème Requete / TimestampProblème de flash(réglé merci djok_fb)
Problème de cookie chez OVHProblème d'enregistrement des données dans une classe
Plus de sujets relatifs à : [Yacc/Bison] Probleme avec yylineno


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR