hi im confusing about how to get a char* when i read a specific token... I look in various sites and they provide suggestions but not complete, i mean, for example yylval and yytext declaration is missing or how to transform the types, etc
What is need in .l file? What is need in .y file?
What I have
in the .l file:
{WORD} { yylval = strdup(yytext);return T_ValidWord;}
in the .y file:
%union{
char *str;
}
%token<str> T_ValidWord
%%
element:
T_OpenTag T_ValidWord ele1 {printf("%s", $2);}
;
The error:
xml.lex: In function ‘yylex’:
xml.lex:34: error: incompatible types when assigning to type ‘YYSTYPE’ from type ‘char *’
Other thing more that confused me: In some places i see
yylval->something = yytext
yylval.something = yytext
yylval = yytext
In the manual of bison tell that yylval is a macro, I understand that a macro is text replaced for other text, but in this situation i really don't get it.