Hey
As the resons i showed in (1) and (2), I indicate that bison treats
non-termimal as integers and it change NUMBER from double to int when it get
yylval from flex.
Is that right?
I know I can using %union to specify the type of non-terminals,can i fix
the problem without using the directive of %union?
Thank you very much.
So am i right in saying your having problems when you do something like:
$$ = X
And maybe it not being the right type etc? In your flex lexer you have
defined yystype this is ok but this means all types must be the same
then that means each rule that returns in bison like $$=... and each
lexical token that uses yylval is a double, which isn't great way of
doing it. The whole %union thing isn't as daunting as you might think!
in your bison do
%union{
int integer;
double dbl;
float flt;
}
Now get rid of the yystype and when you do yylval= bla
do yylval.integer= atoi() etc... and in your bison
%token<integer> INTEGER
... etc
And then for your rules if a rule returns a double:
%type<dbl> rulex
this should help alot more it makes things a little more tight :). I may
have missed your question proper though.. its late here so let me know
if this doesn't help!
--Phil
http://redbrain.co.uk
_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison