[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: string token
From: |
Xinan Tang |
Subject: |
RE: string token |
Date: |
Tue, 2 Dec 2003 11:30:02 -0800 |
Hi
Please remember that yytext is overwritten for each yylex() call. If
you need STR1, you have to copy it using strcpy(); otherwise STR2 will
overwrite yytext (yylval).
For example,
example : STR1 { printrf(STR1) } STR2 { printf(STR1);};
will work. Please try to understand the difference.
Xinan Tang
Senior MTS
Xambala Inc
-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
Nosnos
Sent: Tuesday, December 02, 2003 4:02 AM
To: address@hidden
Subject: string token
Hi,
I have a newbies problem, but could not find the solution.
My bison file has something like that :
%token <string> STR1
%token <string> STR2
example : STR1 STR2 { printf(STR1); printf(STR2);}
;
my flex has something like that :
[...]
"toto" ncpy(yylval.string, yytext, yyleng); return STR1;
"tata" ncpy(yylval.string, yytext, yyleng); return STR2;
[...]
Even the contains of STR1 and STR2 are different, my printf return me
the same string for STR1 and STR2.....
What's wrong ?
thx
_______________________________________________
address@hidden http://mail.gnu.org/mailman/listinfo/help-bison