Structure invalide en lex et yacc

yagam_Wael Messages postés 15 Statut Membre -  
mamiemando Messages postés 33228 Date d'inscription   Statut Modérateur Dernière intervention   -
slt a tous,
je programme en lex et yacc

j ai eu un erreure lors de la compillation que je n ai pas pu comprendre (elle est en gras)

[wael@localhost projet]$ lex op.l
[wael@localhost projet]$ yacc -d op.y
[wael@localhost projet]$ cc lex.yy.c -ll -ly -o op
In file included from op.l:4:
op.y:15: error: field ‘expression’ has incomplete type
op.l: In function ‘yylex’:
op.l:22: warning: passing argument 1 of ‘strncpy’ makes pointer from integer without a cast
[wael@localhost projet]$

et voici le debut du fichier op.l
.....................................................
%{
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include¨structures.h¨
#include "y.tab.h"

struct var_cel *var_list=NULL;

%}

%union {
char chaine;
struct expr expression;
}
%token <chaine> VAR
......................................................

et voici le fichier structures.h

........................................................
typedef struct {
int type;
float val;
} expr;
typedef struct {
char id[20];
float val;
int type;/*egale a 0 si booleen et 1 si reel*/
var_cel *suivant;} var_cel;
.................................................

svp aidez moi
et merci d avance
Configuration: Linux Mandriva
Firefox 1.5.0.7

4 réponses

  1. yagam_Wael Messages postés 15 Statut Membre
     
    slt,
    merci mamiemando
    mais en effet ¨expression¨ n est pas une structure c est un type de token comme ¨chaine¨

    %union {
    char chaine;
    struct expr expression;
    }


    et ¨expr¨ est definie dans le fichier structures.h

    typedef struct {
    int type;
    float val;
    } expr;

    j ai pa compri c'est quoi le probleme
    merci d´avance d´aider un pauvre etudiant pour terminer son projet
    0
  2. yagam_Wael Messages postés 15 Statut Membre
     
    c est sa l erreur

    In file included from op.l:4:
    op.y:15: error: field ‘expression’ has incomplete type


    je n y comprend rien

    merci d avance
    0
  3. mamiemando Messages postés 33228 Date d'inscription   Statut Modérateur Dernière intervention   7 944
     
    Ben il faut simplement que struct expr ait été déclaré ! Exemple :
    struct expr{
      int x;
      char c;
    };

    Sinon "struct expr" est un type incomplet (un type qui n'existe pas car indéfini).

    Bonne chance
    0