diff --git a/src/V3ParseImp.cpp b/src/V3ParseImp.cpp index ddede422c..42504226c 100644 --- a/src/V3ParseImp.cpp +++ b/src/V3ParseImp.cpp @@ -359,7 +359,8 @@ void V3ParseImp::lexToken() { || token == ySTATIC__LEX // || token == yVIRTUAL__LEX // || token == yWITH__LEX // - // Never put yID_* here; below symbol table resolution would break + // Never put yID_* here; below symbol table resolution would break; + // parser will change symbol table affecting how next ID maybe interpreted ) { if (debugFlex() >= 6) { cout << " lexToken: reading ahead to find possible strength" << endl; @@ -488,18 +489,26 @@ int V3ParseImp::lexToBison() { // yylval.scp = NULL; // Symbol table not yet needed - no packages if (debugFlex() >= 6 || debugBison() >= 6) { // --debugi-flex and --debugi-bison - cout << " {" << yylval.fl->filenameLetters() << yylval.fl->asciiLineCol() - << "} lexToBison TOKEN=" << yylval.token << " " << tokenName(yylval.token); - if (yylval.token == yaID__ETC // - || yylval.token == yaID__LEX // - || yylval.token == yaID__aPACKAGE || yylval.token == yaID__aTYPE) { - cout << " strp='" << *(yylval.strp) << "'"; - } - cout << endl; + cout << "lexToBison " << yylval << endl; } return yylval.token; } +//====================================================================== +// V3ParseBisonYYSType functions + +std::ostream& operator<<(std::ostream& os, const V3ParseBisonYYSType& rhs) { + os << "TOKEN=" << rhs.token << " " << V3ParseImp::tokenName(rhs.token); + os << " {" << rhs.fl->filenameLetters() << rhs.fl->asciiLineCol() << "}"; + if (rhs.token == yaID__ETC // + || rhs.token == yaID__LEX // + || rhs.token == yaID__aPACKAGE // + || rhs.token == yaID__aTYPE) { + os << " strp='" << *(rhs.strp) << "'"; + } + return os; +} + //====================================================================== // V3Parse functions diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index d84787162..9447dc8b4 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -92,6 +92,7 @@ struct V3ParseBisonYYSType { AstVarRef* varrefp; }; }; +std::ostream& operator<<(std::ostream& os, const V3ParseBisonYYSType& rhs); #define YYSTYPE V3ParseBisonYYSType @@ -189,6 +190,7 @@ public: // TODO: Many of these functions are the old interface; they'd be better as non-static // and called as READP->newString(...) etc. + // These can be called by either parser or lexer, as not lex/parser-position aware string* newString(const string& text) { // Allocate a string, remembering it so we can reclaim storage at lex end string* strp = new string(text);