Internals: Cleanup preproc in prep for bug1225. No functional change.
This commit is contained in:
parent
264b888ef2
commit
d3d1f3ab60
|
|
@ -204,6 +204,7 @@ private:
|
|||
int getStateToken();
|
||||
int getFinalToken(string& buf);
|
||||
|
||||
ProcState state() const { return m_states.top(); }
|
||||
void statePush(ProcState state) {
|
||||
m_states.push(state);
|
||||
}
|
||||
|
|
@ -806,7 +807,7 @@ int V3PreProcImp::getRawToken() {
|
|||
yyourtext(rtncmt.c_str(), rtncmt.length());
|
||||
m_lineCmt = "";
|
||||
if (yyourleng()) m_rawAtBol = (yyourtext()[yyourleng()-1]=='\n');
|
||||
if (m_states.top()==ps_DEFVALUE) {
|
||||
if (state()==ps_DEFVALUE) {
|
||||
V3PreLex::s_currentLexp->appendDefValue(yyourtext(),yyourleng());
|
||||
goto next_tok;
|
||||
} else {
|
||||
|
|
@ -839,7 +840,7 @@ void V3PreProcImp::debugToken(int tok, const char* cmtp) {
|
|||
while ((pos=buf.find("\r")) != string::npos) { buf.replace(pos, 1, "\\r"); }
|
||||
fprintf (stderr, "%d: %s %s %s(%d) dr%d: <%d>%-10s: %s\n",
|
||||
m_lexp->m_tokFilelinep->lineno(), cmtp, m_off?"of":"on",
|
||||
procStateName(m_states.top()), (int)m_states.size(), (int)m_defRefs.size(),
|
||||
procStateName(state()), (int)m_states.size(), (int)m_defRefs.size(),
|
||||
m_lexp->currentStartState(), tokenName(tok), buf.c_str());
|
||||
}
|
||||
}
|
||||
|
|
@ -853,11 +854,10 @@ int V3PreProcImp::getStateToken() {
|
|||
next_tok:
|
||||
if (isEof()) return VP_EOF;
|
||||
int tok = getRawToken();
|
||||
ProcState state = m_states.top();
|
||||
|
||||
// Most states emit white space and comments between tokens. (Unless collecting a string)
|
||||
if (tok==VP_WHITE && state !=ps_STRIFY) return (tok);
|
||||
if (tok==VP_BACKQUOTE && state !=ps_STRIFY) { tok = VP_TEXT; }
|
||||
if (tok==VP_WHITE && state() !=ps_STRIFY) return (tok);
|
||||
if (tok==VP_BACKQUOTE && state() !=ps_STRIFY) { tok = VP_TEXT; }
|
||||
if (tok==VP_COMMENT) {
|
||||
if (!m_off) {
|
||||
if (m_lexp->m_keepComments == KEEPCMT_SUB) {
|
||||
|
|
@ -918,7 +918,7 @@ int V3PreProcImp::getStateToken() {
|
|||
}
|
||||
|
||||
// Deal with some special parser states
|
||||
switch (state) {
|
||||
switch (state()) {
|
||||
case ps_TOP: {
|
||||
break;
|
||||
}
|
||||
|
|
@ -929,17 +929,17 @@ int V3PreProcImp::getStateToken() {
|
|||
case ps_DEFNAME_ELSIF: {
|
||||
if (tok==VP_SYMBOL) {
|
||||
m_lastSym.assign(yyourtext(),yyourleng());
|
||||
if (state==ps_DEFNAME_IFDEF
|
||||
|| state==ps_DEFNAME_IFNDEF) {
|
||||
if (state()==ps_DEFNAME_IFDEF
|
||||
|| state()==ps_DEFNAME_IFNDEF) {
|
||||
bool enable = defExists(m_lastSym);
|
||||
UINFO(4,"Ifdef "<<m_lastSym<<(enable?" ON":" OFF")<<endl);
|
||||
if (state==ps_DEFNAME_IFNDEF) enable = !enable;
|
||||
if (state()==ps_DEFNAME_IFNDEF) enable = !enable;
|
||||
m_ifdefStack.push(VPreIfEntry(enable,false));
|
||||
if (!enable) parsingOff();
|
||||
statePop();
|
||||
goto next_tok;
|
||||
}
|
||||
else if (state==ps_DEFNAME_ELSIF) {
|
||||
else if (state()==ps_DEFNAME_ELSIF) {
|
||||
if (m_ifdefStack.empty()) {
|
||||
error("`elsif with no matching `if\n");
|
||||
} else {
|
||||
|
|
@ -955,7 +955,7 @@ int V3PreProcImp::getStateToken() {
|
|||
statePop();
|
||||
goto next_tok;
|
||||
}
|
||||
else if (state==ps_DEFNAME_UNDEF) {
|
||||
else if (state()==ps_DEFNAME_UNDEF) {
|
||||
if (!m_off) {
|
||||
UINFO(4,"Undef "<<m_lastSym<<endl);
|
||||
undef(m_lastSym);
|
||||
|
|
@ -963,7 +963,7 @@ int V3PreProcImp::getStateToken() {
|
|||
statePop();
|
||||
goto next_tok;
|
||||
}
|
||||
else if (state==ps_DEFNAME_DEFINE) {
|
||||
else if (state()==ps_DEFNAME_DEFINE) {
|
||||
// m_lastSym already set.
|
||||
stateChange(ps_DEFFORM);
|
||||
m_lexp->pushStateDefForm();
|
||||
|
|
@ -1214,7 +1214,7 @@ int V3PreProcImp::getStateToken() {
|
|||
case VP_INCLUDE:
|
||||
if (!m_off) {
|
||||
statePush(ps_INCNAME);
|
||||
}
|
||||
} // Else incname looks like normal text, that will be ignored
|
||||
goto next_tok;
|
||||
case VP_UNDEF:
|
||||
statePush(ps_DEFNAME_UNDEF);
|
||||
|
|
|
|||
Loading…
Reference in New Issue