I've been trying for a while, to implement a parser for a grammar by using bison and lex.
I have a problem with the type redeclaration of yylval, I explain myself.
I have 4 files: lexico.l, parser.y, funcionesTabla.c, funcionesTabla.h
The first, contains the specification for lex The second, specification for bison/yacc The last two, are a bunch of methods for dealing with a symbol table.
I have in funcionesTabla.h:
typedef enum {
entero,
real,
caracter,
arrayEntero,
arrayReal,
arrayCaracter,
matrizEntero,
matrizReal,
matrizCaracter,
desconocido,
no_asignado
} dtipo ;
typedef struct{
int atrib ;
char *lexema ;
dtipo tipo ;
} atributos;
#define YYSTYPE atributos
I've tried the next:
From parser.y, within a rule, tried to access to yylval.tipo, no problem.
From lexico.l, within a token rule, tried to access to yylval.lexema (or whichever attribute), and gcc says me:
lexico.l: In function ‘yylex’:
lexico.l:93: error: request for member ‘lexema’ in something not a structure or union
make: *** [lex.yy.o] Error 1
Any suggestion?
Thanks a lot in advance, and sorry for my english.