我正在研究bison C++分析器。 大多數示例都在.y文件中有參數location&
的錯誤方法,但我不知道如何讓location_type調用此方法。處理位置信息bison C++分析器錯誤
typedef location location_type;
void
yy::c_parser::error (const location_type& l,
const std::string& m)
{
driver.error (l, m);
}
這是http://panthema.net/2007/flex-bison-cpp-example/的示例摘錄,
if (!driver.calc.existsVariable(*$1)) {
error(yyloc, std::string("Unknown variable \"") + *$1 + "\"");
但是,我在編譯時,它得到了一個錯誤,parser.yy:109: error: ‘yyloc’ was not declared in this scope
。
可能與[SO/how-does-flex-support-bison-location-exactly]有關(http://stackoverflow.com/questions/656703/how-does-flex-support-bison-location-exactly ) – Jarod42