-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey
I think i see the problem, try to split your grammar up more and make more use of the lexer.. read-on j...@garveydesign.com wrote: > Results from Google re Your search - gnu bison "$$ of `constant' > has no declared type" - did not match any documents. That message > (beginning "$$) is derived when processing the grammar file into > Bison. > > The screen message is.. parse.y:98.43-44: $$ of `constant' has no > declared type > > Line 98 in the grammar looks like... exp: MAX '(' exp ',' exp ')' > { $$ = (($3 > $5) ? $3 : $5 );} > > There are other complaints about line 98, which don't seem clear... > > let look at this MAX rule so i take it you want it to look something like MAX ( 5 , 3 ) and $$ = 5 But your grammar looks like exp : MAX ( exp, exp ) So your making more recursion in the end, your parameters to this rule are equal to its $$ but that sort of loops on itself. Like say you have the rule: addme : IDENTIFIER '=' INTEGER '+' INTEGER { $$ = $3 + $5; } You would %type<val> addme etc.. but this means the grammar only cares that an expression always looks like: bla = 3 + 2 or bla = 55 + 71 Your 'exp' goes in on itself it would accept if it compiled. MAX ( MIN ( OR ( ..... ))))))) As exp is a rule, although you have assigned %type<val> exp, which is and int but it doesn't work that way. As yacc doesn't treat those parameters to that rule as the current tokens in the %union. As the union can be very different though out the run. You should have something like in a LEX [0-9]+ { yylval.val = atoi(yytext); return INTEGER; } and your yacc token<val> INTEGER then exp : MAX '(' INTEGER ',' INTEGER ') { $$ = ( ($3 > $5) ? $3 : $5 ); } I think should work fine. Oh i just noticed you have %token<val> NUM try sticking that in place of the exp as the parameters to those functions. - --Phil -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkp2UUoACgkQAhcOgIaQQ2HfHQCfZYhBUOyGi19CuyV0sMD9vbcF T6gAn1GYWbTlUgfSlQUJdFimbCu0Cwpx =f4W2 -----END PGP SIGNATURE----- _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison