IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Générateurs de compilateur Discussion :

Multiple declarations of yy..


Sujet :

Générateurs de compilateur

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mai 2008
    Messages
    80
    Détails du profil
    Informations personnelles :
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2008
    Messages : 80
    Par défaut Multiple declarations of yy..
    Bonsoir à toutes et à tous,
    je compile mon analyseur de langage qui utilise est codé en C/C++ et lors de la génération de l'executable final j'obtiens de très nombreuses erreurs :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    _wk/parse_bis.o: In function `yy_flush_buffer(yy_buffer_state*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1448: multiple definition of `yy_flush_buffer(yy_buffer_state*)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1448: first defined here
    _wk/parse_bis.o: In function `yy_flush_buffer(yy_buffer_state*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1452: multiple definition of `yytext'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1452: first defined here
    _wk/parse_bis.o: In function `yy_flush_buffer(yy_buffer_state*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1448: multiple definition of `yyin'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1448: first defined here
    _wk/parse_bis.o: In function `yyget_lineno()':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1687: multiple definition of `yyget_lineno()'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1687: first defined here
    _wk/parse_bis.o:(.data+0x0): multiple definition of `yylineno'
    _wk/test1_flex.o:(.data+0x0): first defined here
    _wk/parse_bis.o: In function `yyget_in()':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1696: multiple definition of `yyget_in()'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1696: first defined here
    _wk/parse_bis.o: In function `yyget_out()':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1704: multiple definition of `yyget_out()'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1704: first defined here
    _wk/parse_bis.o: In function `yy_flush_buffer(yy_buffer_state*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1449: multiple definition of `yyout'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1449: first defined here
    _wk/parse_bis.o: In function `yyget_leng()':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1712: multiple definition of `yyget_leng()'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1712: first defined here
    _wk/parse_bis.o: In function `yy_flush_buffer(yy_buffer_state*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1448: multiple definition of `yyleng'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1448: first defined here
    _wk/parse_bis.o: In function `yyget_text()':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1721: multiple definition of `yyget_text()'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1721: first defined here
    _wk/parse_bis.o: In function `yyset_lineno(int)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1730: multiple definition of `yyset_lineno(int)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1730: first defined here
    _wk/parse_bis.o: In function `yyset_in(_IO_FILE*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1742: multiple definition of `yyset_in(_IO_FILE*)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1742: first defined here
    _wk/parse_bis.o: In function `yyset_out(_IO_FILE*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1747: multiple definition of `yyset_out(_IO_FILE*)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1747: first defined here
    _wk/parse_bis.o: In function `yyget_debug()':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1752: multiple definition of `yyget_debug()'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1752: first defined here
    _wk/parse_bis.o: In function `yy_flush_buffer(yy_buffer_state*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1458: multiple definition of `yy_flex_debug'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1458: first defined here
    _wk/parse_bis.o: In function `yyset_debug(int)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1757: multiple definition of `yyset_debug(int)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1757: first defined here
    _wk/parse_bis.o: In function `yyfree':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1853: multiple definition of `yyfree(void*)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1853: first defined here
    _wk/parse_bis.o: In function `yy_delete_buffer(yy_buffer_state*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1397: multiple definition of `yy_delete_buffer(yy_buffer_state*)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1397: first defined here
    _wk/parse_bis.o: In function `yypop_buffer_state()':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1507: multiple definition of `yypop_buffer_state()'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1507: first defined here
    _wk/parse_bis.o: In function `yylex_destroy()':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1791: multiple definition of `yylex_destroy()'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1791: first defined here
    _wk/parse_bis.o: In function `yyrealloc':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1841: multiple definition of `yyrealloc(void*, unsigned int)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1841: first defined here
    _wk/parse_bis.o: In function `yyalloc':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1836: multiple definition of `yyalloc(unsigned int)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1836: first defined here
    _wk/parse_bis.o: In function `yypush_buffer_state(yy_buffer_state*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1477: multiple definition of `yypush_buffer_state(yy_buffer_state*)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1477: first defined here
    _wk/parse_bis.o: In function `yy_switch_to_buffer(yy_buffer_state*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1324: multiple definition of `yy_switch_to_buffer(yy_buffer_state*)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1324: first defined here
    _wk/parse_bis.o: In function `yy_scan_buffer(char*, unsigned int)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1575: multiple definition of `yy_scan_buffer(char*, unsigned int)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1575: first defined here
    _wk/parse_bis.o: In function `yy_scan_bytes(char const*, int)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1625: multiple definition of `yy_scan_bytes(char const*, int)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1625: first defined here
    _wk/parse_bis.o: In function `yy_scan_string(char const*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1612: multiple definition of `yy_scan_string(char const*)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1612: first defined here
    _wk/parse_bis.o: In function `yy_create_buffer(_IO_FILE*, int)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1369: multiple definition of `yy_create_buffer(_IO_FILE*, int)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1369: first defined here
    _wk/parse_bis.o: In function `yyrestart(_IO_FILE*)':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:1307: multiple definition of `yyrestart(_IO_FILE*)'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:1307: first defined here
    _wk/parse_bis.o: In function `yylex()':
    /home/liszto/Documents/TEsting/_wk/test1_flex.c:685: multiple definition of `yylex()'
    _wk/test1_flex.o:/home/liszto/Documents/TEsting/_wk/test1_flex.c:685: first defined here
    collect2: ld returned 1 exit status
    Est-ce que quelqu'un pourrait me dire d'ou cela provient ?

    Sachant que le fichier responsable de ces erreur est généré automatiquement par flex et donc je ne peux pas le modifier à la main mais par contre je peux agir sur le fichier .l (flex)

    Est-ce que mes includes dans mes divers fichiers .cpp / .h / .l (flex) / .y (bison) peuvent y etre pour quelque chose ?
    Est-ce que mon makefile peut y etre pour quelque chose également ?

    Est-ce que quelqu'un pourrait me tirer de ce mauvais pas que je n'arrive pas à résoudre depuis 2 jours maintenant :/

    Si besoin de plus de chose pour me répondre me le dire, je fournirais n'importe quelle chose nécessaire pour pouvoir tirer cela au clair...

  2. #2
    Membre Expert
    Homme Profil pro
    Chercheur
    Inscrit en
    Mars 2010
    Messages
    1 218
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Chercheur

    Informations forums :
    Inscription : Mars 2010
    Messages : 1 218
    Par défaut
    Bonsoir,

    ça peut venir de pas mal de choses.
    Est-ce que dans tes fichiers d'en-tête tu utilises des commandes préprocessorales de ce type?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    #ifndef MON_FICHIER_EN_TETE_H
    #define MON_FICHIER_EN_TETE_H
     
    // contenu de mon_fichier_en_tete.h
     
    #endif
    Si ce n'est pas le cas, c'est sûrement la cause de ton problème.
    Sinon, poste le code dans test1_flex.c et le fichier d'en-tête où tu déclares tes fonctions (test1_flex.h?).

  3. #3
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mai 2008
    Messages
    80
    Détails du profil
    Informations personnelles :
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2008
    Messages : 80
    Par défaut
    Oui pour être sur j'en ai mis de partout et j'ai toujours le problème...

    C'est pour cela que je trouve cela bizarre !

  4. #4
    Membre Expert
    Homme Profil pro
    Chercheur
    Inscrit en
    Mars 2010
    Messages
    1 218
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Chercheur

    Informations forums :
    Inscription : Mars 2010
    Messages : 1 218
    Par défaut
    Bonjour,

    le mieux serait de poster tes sources...
    Vérifie aussi que tu ne définis pas de fonctions templates dans tes .c

  5. #5
    Membre confirmé
    Profil pro
    Étudiant
    Inscrit en
    Mai 2008
    Messages
    80
    Détails du profil
    Informations personnelles :
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2008
    Messages : 80
    Par défaut
    Bon ce matin je me suis mis en tete de supprimer correctement tout ce qui était généré par mon makefile pour faire une reconstruction complete du projet bilan :
    ca ne compile meme plus le flex ou le bison car :
    SI je commence par compiler le flex (test.l) il me renvoie cette erreur à la compilation :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    flex -o_wk/test1_flex.c lang/test1.l
    g++ -Wall -g -O2 -I. -c _wk/test1_flex.c -o _wk/test1_flex.o
    lang/test1.l:4:26: error: ../src/parse.h: Aucun fichier ou dossier de ce type
    lang/test1.l: In function ‘int yylex()’:
    lang/test1.l:9: error: ‘KW_PROGRAM’ was not declared in this scope
    lang/test1.l:10: error: ‘KW_VAR’ was not declared in this scope
    lang/test1.l:11: error: ‘KW_BEGIN’ was not declared in this scope
    lang/test1.l:12: error: ‘KW_END’ was not declared in this scope
    lang/test1.l:13: error: ‘KW_INTEGER’ was not declared in this scope
    lang/test1.l:14: error: ‘KW_REAL’ was not declared in this scope
    lang/test1.l:15: error: ‘KW_BOOLEAN’ was not declared in this scope
    lang/test1.l:16: error: ‘KW_CHAR’ was not declared in this scope
    lang/test1.l:17: error: ‘KW_STRING’ was not declared in this scope
    lang/test1.l:19: error: ‘SEP_DOTS’ was not declared in this scope
    lang/test1.l:20: error: ‘SEP_COMMA’ was not declared in this scope
    lang/test1.l:21: error: ‘SEP_SCOL’ was not declared in this scope
    lang/test1.l:22: error: ‘SEP_DOT’ was not declared in this scope
    lang/test1.l:24: error: ‘TOK_IDENT’ was not declared in this scope
    _wk/test1_flex.c: At global scope:
    _wk/test1_flex.c:1190: warning: ‘void yyunput(int, char*)’ defined but not used
    make: *** [test1_flex.c] Erreur 1
    Donc il lui manque un lien vers le parse.h qui doit etre généré par bison et si la compilation commence par bison et donc doit créer le parse.c + parse.h il me renvoie cette erreur à la compilation :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    if [ -d _wk ] ; then rm -rf _wk ; fi
    mkdir _wk
    Building BISON file : lang/parse.y
    bison -d -o _wk/parse_bis.c lang/parse.y
    lang/parse.y:71 parser name defined to default :"parse"
    g++ -Wall -g -O2 -I. -c _wk/parse_bis.c -o _wk/parse_bis.o
    /usr/share/bison++/bison.cc: In function ‘int yyparse()’:
    /usr/share/bison++/bison.cc:667: warning: deprecated conversion from string constant to ‘char*’
    /usr/share/bison++/bison.cc:730: error: ‘yylex’ was not declared in this scope
    /usr/share/bison++/bison.cc:939: warning: deprecated conversion from string constant to ‘char*’
    make: *** [parse_bis.c] Erreur 1
    Donc en gros il lui manque une liaison vers flex, la j'avoue avoir l'impression de tourner en rond -_-
    Pourtant je suis bien l'ordre de compilation pour une association flex/bison c'est à dire d'abord compilation de flex puis de bison mais cela proviendrait peut-être du fait que je tente de générer mes .o dans chaque alors qu'il faudrait d'abord générer le bison et son parse.c/parse.h puis du flex avec son flex.h

    Une fois ces 2 choses faites, généré le parse.o et le flex.o je pense ?


    EDIT :
    Je ne faisais déjà pas le bon include dans mon test1.l car je lui donnais comme source : ../src/parse.h
    or la source était :
    ../_wk/parse_bis.h

    Une fois cela réglé, j'ai tenté de compiler à la main pour etre sur que tout ce passait bien c'est à dire :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    liszto@liszto-laptop:~/Documents/TEsting$ flex -o_wk/test1.c lang/test1.l
    liszto@liszto-laptop:~/Documents/TEsting$ bison -d -o _wk/parse_bis.c lang/parse.y
    lang/parse.y:71 parser name defined to default :"parse"
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -Wall -g -O2 -I. -c _wk/test1.c -o _wk/test1.o
    _wk/test1.c:1190: warning: ‘void yyunput(int, char*)’ defined but not used
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -Wall -g -O2 -I. -c _wk/parse_bis.c -o _wk/parse_bis.o
    /usr/share/bison++/bison.cc: In function ‘int yyparse()’:
    /usr/share/bison++/bison.cc:667: warning: deprecated conversion from string constant to ‘char*’
    /usr/share/bison++/bison.cc:730: error: ‘yylex’ was not declared in this scope
    /usr/share/bison++/bison.cc:939: warning: deprecated conversion from string constant to ‘char*’

    Je suis donc revenu à une seule erreur (même si ma compilation n'est pas encore terminé après ça, il reste déjà plus que ce problème entre flex et bison sachant que c'est la partie de la compilation qui génére le plus souvent les erreurs.

    Serait-ce encore un problème d'include ?


    EDIT 2 :
    Nouvelle évolution j'ai inclus ceci dans mon parse.y (fichier bison) car étant donné que je compile avec g++ il ne connait visiblement pas les type en rapport avec flex qui sont pour le C de base donc voici ce que j'ai rajouté :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     extern "C"
    {
         int yyparse(void);
         int yylex(void);  
         int yywrap()
         {
              return 1;
            }
     
    }

    J'ai par la suite tout recompilé ce qui me donne ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    liszto@liszto-laptop:~/Documents/TEsting$ flex -o_wk/test1.c lang/test1.l
    liszto@liszto-laptop:~/Documents/TEsting$ bison -d -o _wk/parse_bis.c lang/parse.y
    lang/parse.y:81 parser name defined to default :"parse"
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -Wall -g -O2 -I. -c _wk/test1.c -o _wk/test1.o
    _wk/test1.c:1190: warning: ‘void yyunput(int, char*)’ defined but not used
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -Wall -g -O2 -I. -c _wk/parse_bis.c -o _wk/parse_bis.o
    /usr/share/bison++/bison.cc: In function ‘int yyparse()’:
    /usr/share/bison++/bison.cc:667: warning: deprecated conversion from string constant to ‘char*’
    /usr/share/bison++/bison.cc:939: warning: deprecated conversion from string constant to ‘char*’
    /usr/share/bison++/bison.cc:559: warning: ‘yystate’ may be used uninitialized in this function
    /usr/share/bison++/bison.cc:560: warning: ‘yyn’ may be used uninitialized in this function
    /usr/share/bison++/bison.cc:561: warning: ‘yyssp’ may be used uninitialized in this function
    /usr/share/bison++/bison.cc:562: warning: ‘yyvsp’ may be used uninitialized in this function
    /usr/share/bison++/bison.cc:563: warning: ‘yyerrstatus’ may be used uninitialized in this function
    /usr/share/bison++/bison.cc:593: warning: ‘yyval’ may be used uninitialized in this function
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -Wall -g -O2 -I. -c src/TableDesIdentificateurs.cpp -o _wk/TableDesIdentificateurs.o
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -Wall -g -O2 -I. -c src/TableDesSymboles.cpp -o _wk/TableDesSymboles.o
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -Wall -g -O2 -I. -c src/Type.cpp -o _wk/Type.o
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -o bin/test _wk/TableDesIdentificateurs.o _wk/TableDesSymboles.o _wk/Type.o _wk/test1.o _wk/parse_bis.o -lfl
    _wk/parse_bis.o: In function `yyparse':
    /usr/share/bison++/bison.cc:730: undefined reference to `yylex'
    collect2: ld returned 1 exit status

    Plus que cette erreur et il n'y aura plus de problème mais la je ne vois pas trop pourquoi elle est là, il ne devrait pas me la signaler lors de la génération de mon parse_bis.o plutot que lors de le génération de mon executable final ?


    EDIT 3 :
    Après recherche de nombreux warning étaient dus à mon package de bison++, je l'ai désinstallé et laissé installé uniquement : bison et bisonc++ ainsi que flex et là il ne reste presque par de warning mais toujours mon erreur :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    liszto@liszto-laptop:~/Documents/TEsting$ flex -o_wk/test1.c lang/test1.l
    liszto@liszto-laptop:~/Documents/TEsting$ bison -d -o _wk/parse_bis.c lang/parse.y
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -Wall -g -O2 -I. -c _wk/test1.c -o _wk/test1.o
    ^[[A_wk/test1.c:1190: warning: ‘void yyunput(int, char*)’ defined but not used
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -Wall -g -O2 -I. -c _wk/parse_bis.c -o _wk/parse_bis.o
    _wk/parse_bis.c: In function ‘int yyparse()’:
    _wk/parse_bis.c:1391: warning: deprecated conversion from string constant to ‘char*’
    _wk/parse_bis.c:1534: warning: deprecated conversion from string constant to ‘char*’
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -Wall -g -O2 -I. -c src/TableDesIdentificateurs.cpp -o _wk/TableDesIdentificateurs.o
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -Wall -g -O2 -I. -c src/TableDesSymboles.cpp -o _wk/TableDesSymboles.o
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -Wall -g -O2 -I. -c src/Type.cpp -o _wk/Type.o
    liszto@liszto-laptop:~/Documents/TEsting$ g++ -o bin/test _wk/TableDesIdentificateurs.o _wk/TableDesSymboles.o _wk/Type.o _wk/test1.o _wk/parse_bis.o -lfl
    _wk/parse_bis.o: In function `yyparse':
    /home/liszto/Documents/TEsting/_wk/parse_bis.c:1277: undefined reference to `yylex'
    collect2: ld returned 1 exit status
    EDIT 4:
    Bon après compilation sur compilation débeugage sur débeugage, voilà la solution !
    L'erreur venait de ce bloc de code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     extern "C"
    {
         int yyparse(void);
         int yylex(void);  
         int yywrap()
         {
              return 1;
            }
     }
    Il ne fallait pas inclure ces fonctions dans un bloc C mais les déclarer comme tel dans le fichier de base pour qu'elle soit prise en compte en temps que C++ et non pas C.
    Mon fichier ressemble donc à ceci avant la déclaration des tokens (parse.y):


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     
    %{
    #ifndef _PARSE
    #define _PARSE
    #include "../src/TableDesIdentificateurs.h"
    #include "../src/TableDesSymboles.h"
    #include <stdio.h>
    #include <ctype.h>
    using namespace std;
     
    int yylex(void);
    int yyparse(void);
    int yyerror(char *);
    extern FILE *yyin;
    TableDesIdentificateurs v;
    %}
    Concernant le fichier flex (lexer.l) il faut bien penser à inclure dans ces include celui-ci :
    #include "parse.h"
    qui est le fichier généré par bison en même temps que son parse.c

    Voilà, je pense avoir fait le tour.

  6. #6
    Membre régulier
    Inscrit en
    Août 2009
    Messages
    9
    Détails du profil
    Informations forums :
    Inscription : Août 2009
    Messages : 9
    Par défaut
    The problem was that C++ needed a FlexLexer object, and then execute the yylex() function through it.

    Like this:
    Expand|Select|Wrap|Line Numbers

    1. int main() {
    2. FlexLexer* lexer = new yyFlexLexer();
    3. while (lexer->yylex() != 0)
    4. ;
    5. return 0;
    6. }


    http://bytes.com/topic/c/answers/622131-flex-c

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. declarer un select multiple
    Par jmtrivia dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 30/04/2010, 10h26
  2. Réponses: 2
    Dernier message: 01/08/2007, 12h47
  3. Réponses: 5
    Dernier message: 19/06/2006, 15h34
  4. Multiple declaration of "objet_geo"
    Par n00bi dans le forum C++
    Réponses: 4
    Dernier message: 17/11/2005, 21h14
  5. Réponses: 6
    Dernier message: 25/03/2002, 21h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo