When I compile and link the code for my interpreter's parser, the gcc compiler that came with codeblocks throws an error. I've narrowed it down to a function that uses templates. I've never used templates before (yes I know I have with vectors, but defining them is new) and I can't seem to fix it.
the code is from a few files:
load_program.cpp snippet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
if(!line.empty() and (line[0] != '_' or line[0] != '$')) // if this holds then token_value must be a command or an operator
{
if(contains<std::string>(token_value, commands)) // must be a command
{
program.push_back(token(token::command, token_value));
goto next_token;
}
elseif(contains<std::string>(token_value, operators)) // must be an operator
{
program.push_back(token(token::op, token_value));
goto next_token;
}
else
{
error_and_terminate("unrecognised token");
}
token_value and line are std::string commands and operators are std::vector<std::string> program is an std::vector<token> // I made the class token, but it is unrelated to the problem.
utility_functions.hpp snippet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#ifndef UTILITY_FUNCTIONS_HPP_INCLUDED
#define UTILITY_FUNCTIONS_HPP_INCLUDED
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
externvoid error_and_terminate(constchar *s);
externvoid usage();
template <class Tcontains>
externbool contains(Tcontains elem, std::vector<Tcontains> vect); // similar to java's vector's member function
#endif // UTILITY_FUNCTIONS_HPP_INCLUDED