I'm working on a bison c++ parser.
Most examples has error method with parameter location&
in .y file, but I'm not sure how to get the location_type to call this method.
typedef location location_type;
void
yy::c_parser::error (const location_type& l,
const std::string& m)
{
driver.error (l, m);
}
This is an example excerpt from http://panthema.net/2007/flex-bison-cpp-example/,
if (!driver.calc.existsVariable(*$1)) {
error(yyloc, std::string("Unknown variable \"") + *$1 + "\"");
However, I got an error that parser.yy:109: error: ‘yyloc’ was not declared in this scope
when compiling it.