c++ - 1 IntelliSense: a value of type "StatementTable::StatementFunc" cannot be assigned to an entity of type "StatementTable::StatementState" -
statementstatefunction [ ] array of functions return statementstate , statearray [getinputtoken(t)] [currentstate] state table tells statementstatefunction [ ] function call, yet compiler says cannot assign statementfunc statementstate though methods called in statementstatefunction[] return statementstate
in statementtable.cpp
void statementtable::buildstatement (token & t) { statementstate currentstate (startstatement); { currentstate = statementstatefunction [ statearray[getinputtoken(t)][currentstate] ]; } while (currentstate != statementcomplete); } in statementtable.h
typedef statementstate (*statementfunc) (token &); static token::uchar statearray [numtokeinputs] [numberstates]; static statementfunc statementstatefunction [];
let's analyze expression:
currentstate = statementstatefunction [ statearray[getinputtoken(t)][currentstate] ]; you have 3 array indizes here, getinputtoken(t), currentstate, statearray[x][y]. array indizes have integral numbers (int, short, char, long etc.).
getinputtokenseems function. source cannot tell whether returns integral type or not.currentstateof typestatementstate. it's not clear type is, if not of integral type nor has implicit conversion such type, cannot used array index.statearray[x][y]of typetoken::uchar. thyt should ok,ucharlooks typedef integral type.
what remains of expression assignment. has form currentstate = statementstatefunction[x]. statementstatefunction[x] statementfunc, i.e. function pointer. currentstate of type statementstate. you cannot assign function pointer statementstate, @ least error message says.
i assume want call function, token given argument buildstatement. code, made bit more readable, this:
void statementtable::buildstatement (token & t) { statementstate currentstate = startstatement; { auto tokenindex = getinputtoken(t); auto funcindex = statearray[tokenindex][currentstate]; auto function = statementstatefunction[funcindex]; //this missing: function call currentstate = function(t); } while (currentstate != statementcomplete); }
Comments
Post a Comment