I have a simple config file as shown below
[main]
e_type=0x1b
In my lex file (test.l) when I encounter token e_type I call the following function and retunr T_E_TYPE token.
void tag () {
yylval.str = malloc(strlen(yytext)+1);
strcpy (yylval.str, yytext);
}
In the parser file (test.y) I have declared the union as follows.
%union {
char *str;
unsigned int n;
}
I am able to recognize [main] and e_type but If I try to print yylval.str from test.y file I get a segmentation fault.
How can I access the values I passed from lexer in the test.y file.