PDA

View Full Version : not able to execute yacc


himagiri19
June 8th, 2009, 11:34 AM
hi everyone,
i am not able to execute yacc program even after installing bison and flex
could please help

if i execute it is coming like this

himagiri@ubuntu:~$ cc lex.yy.c y.tab.c -ll

.y.tab.c:282: error: expected specifier-qualifier-list before ‘YYSTYPE’
y.tab.c:982: error: expected declaration specifiers or ‘...’ before ‘YYSTYPE’
y.tab.c: In function ‘yydestruct’:
y.tab.c:991: error: ‘yyvaluep’ undeclared (first use in this function)
y.tab.c:991: error: (Each undeclared identifier is reported only once
y.tab.c:991: error: for each function it appears in.)
y.tab.c: At top level:
y.tab.c:1028: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘yylval’
y.tab.c: In function ‘yyparse’:
y.tab.c:1090: error: ‘YYSTYPE’ undeclared (first use in this function)
y.tab.c:1090: error: expected ‘;’ before ‘yyvsa’
y.tab.c:1091: error: ‘yyvs’ undeclared (first use in this function)
y.tab.c:1091: error: ‘yyvsa’ undeclared (first use in this function)
y.tab.c:1092: error: ‘yyvsp’ undeclared (first use in this function)
y.tab.c:1102: error: expected ‘;’ before ‘yyval’
y.tab.c:1182: error: ‘union yyalloc’ has no member named ‘yyvs’
y.tab.c:1182: error: ‘union yyalloc’ has no member named ‘yyvs’
y.tab.c:1269: error: ‘yylval’ undeclared (first use in this function)
y.tab.c:1299: error: ‘yyval’ undeclared (first use in this function)
prog4a.y:14: warning: incompatible implicit declaration of built-in function ‘printf’
prog4a.y:14: warning: incompatible implicit declaration of built-in function ‘exit’
y.tab.c:1400: error: too many arguments to function ‘yydestruct’
y.tab.c:1456: error: too many arguments to function ‘yydestruct’
y.tab.c:1502: error: too many arguments to function ‘yydestruct’
y.tab.c:1510: error: too many arguments to function ‘yydestruct’
prog4a.y: In function ‘main’:
prog4a.y:38: warning: incompatible implicit declaration of built-in function ‘printf’
prog4a.y: In function ‘yyerror’:
prog4a.y:48: warning: incompatible implicit declaration of built-in function ‘printf’
prog4a.y:50: warning: incompatible implicit declaration of built-in function ‘exit’

himagiri19
June 8th, 2009, 11:40 AM
how to execute yacc programs after installing bison and flex

fr4nko
June 8th, 2009, 04:02 PM
Hi,

it seems that you are a little bit lost. I guess that you didn't include the header file generated by yacc/bison. In order to generate the include file you should invoke bison like that:

bison -d -o descr.c descr.y

where the -d switch instruct bison to generate the header file "descr.h". Also you should include the header file in the .y file like that:

%{

... some includes here ...
#include "descr.h"

%}
this is because YYSTYPE get defined in descr.h which in turn in generated by bison.

I hope that this is helpful but it seems to me that you should study the info page of bison:

info bison

and understand how it works.

Francesco