Identifier not found error

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//CalcLex.h
  #ifndef _CALCLEX_H
#define _CALCLEX_H

#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <iomanip>

#include <map>

using namespace std;

enum CalcGrammarTokens{
	EOFSY = 0, LPAREN, RPAREN, ADDOP, SUBOP, MULTOP, DIVOP, ASSIGNOP, ID, NUMCONST, READSY, WRITESY, UNKNOWNSY
};

#define YYTEXT_MAX 100
extern char yytext[YYTEXT_MAX];	//Global token text buffer 

bool yylexopen(const char filename[]);
void yytextclear();
void yytextappend();
int yylex();

bool followingCharsMatch(int c, string target);
string tokenType(int token);

int yyparse(); //for lab 2

void match(int expectedTok);


#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//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;
}
Are you linking all your object files to create the executable properly?
I believe I am. I have checked multiple times and don't know what's wrong.
@cang

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.
Try making a clean build.
Topic archived. No new replies allowed.