When I call yyparse in main, I keep getting an identifier not found error and I can't seem to figure out why. Does anyone know what's wrong? The yyparse function is declared in the CalcLex.h and defined in CalcInterp.cpp
//CalcInterp.cpp
#include "CalcLex.h" //implementation file includes header file
//NonTerminal prototypes
int program();
int stmt_list();
int stmt();
int expr();
int term_tail(int inval);
int term();
int factor_tail(int inval);
int factor();
//Current lexical token
int tok;
int yyparse()
{
tok = yylex();
program(); //recursive calls
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
//CalcInterpMain.cpp
#include "CalcLex.h" //implementation file includes header file
int main(int argc, char *argv[])
{
//Pick up commandline input filename, if any
if (argc > 1 && (!yylexopen(argv[1])))
{
cout << "Error: Cannot open input file " << argv[1] << endl;
exit(1);
}
yyparse();
return 0;
}
In all your program shown, I can not find the function 'yylex()' that gets called in 'yyparse()'. Might that be the problem, or did you just not show it? Same with the function ' program()'. That's not shown either.
The function yylex() and program() are just not shown and I don't think it's part of the problem. I commented those function calls in yyparse() and yyparse() still gets the error C3861 identifier not found.