I've been pouring over this issue trying to figure out what is causing these errors, but so far I've come up with nothing. I have this function:
struct token scanToken(struct matrix refTable){
struct token send;
int counter = 0;
int currState = refTable.start;
while (1) {
printf("%d ", currState);
char c = getchar();
send.buffer[counter] = c;
int class = classifyChar(c);
char result = refTable.grid[class][currState].action;
currState = refTable.grid[class][currState].nextState;
if (currState = 99){
findEnd();
send.recrej = 'd';
return send;
}
else if (currState = refTable.accept){
if (c == EOF){
send.isEnd = 't';
}
else{
send.isEnd = 'f';
send.recrej = 'a';
}
}
++counter;
}
return send;
}
It is matched with the following header file:
struct token {
char buffer[512];
char recrej;
char isEnd;
};
void findEnd(void);
struct token scanToken(struct matrix refTable);
int classifyChar(char c);
This code is currently used in this snippet in my main function:
struct matrix table;
table = buildMatrix(argv[1]);
char c;
int class;
struct token found;
found = scanToken(table);
while(found.isEnd != 't'){
if (found.recrej == 'a'){
printf("recognized '%s'\n", found.buffer);
}
else {
printf("rejected\n");
}
found = scanToken(table);
}
the matrix struct is prototyped in another header file, which is included in the scanner.c file (pictured first), and the tokenize.c file (pictured last). However, this produces the following warnings and errors.
In file included from scanner.c:10:0:
scanner.h:16:31: warning: 'struct matrix' declared inside parameter list [enabled by default]
struct token scanToken(struct matrix refTable);
^
scanner.h:16:31: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
scanner.c:60:14: error: conflicting types for 'scanToken'
struct token scanToken(struct matrix refTable){
^
In file included from scanner.c:10:0:
scanner.h:16:14: note: previous declaration of 'scanToken' was here
struct token scanToken(struct matrix refTable);
I've been searching for quite some time, and have tried rewriting things a number of ways, with the same result all around. Any help would be greatly appreciated. Thank you.