Bear with me here, as I'm coming from a pure Java/Python background and have about a 10% knowledge in the basics of C++.
I'm defining a tokenising class for a Lexer, and have already run into a problem, with the Eclipse compiler throwing:
expected unqualified-id
Thats it. No information whatsoever. This same error pops up no matter what I name my function. I think it may have to do with the way I'm using vector<string> tokenise
but I have no idea...
I setup my h
and cpp
file like so:
lexer.h
#ifndef LEX_LEXER_H_
#define LEX_LEXER_H_
#include <string>
#include <vector>
using namespace std;
struct token;
vector<token> tokenise(vector<string> data);
#endif /* LEX_LEXER_H_ */
lexer.cpp
#include <iostream>
using namespace std;
enum token_type {
// Operations.
ADD, SUB, MUL, DIV, MOD,
// Bitwise operations.
BITL, BITR,
// Keywords.
DEFINE,
// Primitives.
INT, FLOAT, CHAR, STRING, BOOL
};
struct token {
token_type type;
string data;
};
vector<token> tokenise(vector<string> data) { // <<< throwing the error
vector<token> tokens;
for (string s : data) {
for (char& c : s) {
cout << c << endl;
}
}
return tokens;
}