Call a function in a Yacc file from another c file
问题 I am new in Lex/Yacc programming. I have a question about how to call a function in Yacc file from another C file. Assume that I have following Lex/Yacc code: calc.l %{ #include "y.tab.h" extern int yylval; %} %% [0-9]+ { yylval=atoi(yytext); return NUMBER;} [ \t]; \n return 0; . return yytext[0]; %% calc.y %{ #include <stdio.h> %} %token NAME NUMBER %% statement: NAME '=' expression | expression {printf("= %d\n",$1); printf("yylval= %d",yylval);} ; expression: NUMBER '+' NUMBER {$$=$1+$3;} |