For this particular use case I think it's reasonable to make statTable
a global variable (declare outside of main function, and initialize it before calling the yylex()
function:
%{
#include "mapstat.h"
extern mapStat* statTable;
// ...
}%
mapStat* statTable = NULL;
int main(int argc, char *argv[]) {
statTable=new mapStat;
// ...
}
You should consider having a singleton class to enable more encapsulation of semantics and access of the statisics functionality (that's one of the rare valid use cases).