mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
Cleanup flex compiles again - remove yyleng from preproc.cpp
This commit is contained in:
+20
-20
@@ -683,7 +683,7 @@ int V3PreProcImp::getRawToken() {
|
||||
if (m_lineAdd) {
|
||||
m_lineAdd--;
|
||||
m_rawAtBol = true;
|
||||
yytext=(char*)"\n"; yyleng=1;
|
||||
yyourtext("\n",1);
|
||||
if (debug()) debugToken(VP_WHITE, "LNA");
|
||||
return (VP_WHITE);
|
||||
}
|
||||
@@ -695,11 +695,11 @@ int V3PreProcImp::getRawToken() {
|
||||
if (!m_rawAtBol) rtncmt = "\n"+rtncmt;
|
||||
m_lineCmtNl = false;
|
||||
}
|
||||
yytext=(char*)rtncmt.c_str(); yyleng=rtncmt.length();
|
||||
yyourtext(rtncmt.c_str(), rtncmt.length());
|
||||
m_lineCmt = "";
|
||||
if (yyleng) m_rawAtBol = (yytext[yyleng-1]=='\n');
|
||||
if (yyourleng()) m_rawAtBol = (yyourtext()[yyourleng()-1]=='\n');
|
||||
if (m_state==ps_DEFVALUE) {
|
||||
V3PreLex::s_currentLexp->appendDefValue(yytext,yyleng);
|
||||
V3PreLex::s_currentLexp->appendDefValue(yyourtext(),yyourleng());
|
||||
goto next_tok;
|
||||
} else {
|
||||
if (debug()) debugToken(VP_TEXT, "LCM");
|
||||
@@ -721,14 +721,14 @@ int V3PreProcImp::getRawToken() {
|
||||
goto next_tok; // Parse parent, or find the EOF.
|
||||
}
|
||||
|
||||
if (yyleng) m_rawAtBol = (yytext[yyleng-1]=='\n');
|
||||
if (yyourleng()) m_rawAtBol = (yyourtext()[yyourleng()-1]=='\n');
|
||||
return tok;
|
||||
}
|
||||
}
|
||||
|
||||
void V3PreProcImp::debugToken(int tok, const char* cmtp) {
|
||||
if (debug()>4) {
|
||||
string buf = string (yytext, yyleng);
|
||||
string buf = string (yyourtext(), yyourleng());
|
||||
string::size_type pos;
|
||||
while ((pos=buf.find("\n")) != string::npos) { buf.replace(pos, 1, "\\n"); }
|
||||
while ((pos=buf.find("\r")) != string::npos) { buf.replace(pos, 1, "\\r"); }
|
||||
@@ -753,7 +753,7 @@ int V3PreProcImp::getToken() {
|
||||
if (tok==VP_COMMENT) {
|
||||
if (!m_off) {
|
||||
if (m_lexp->m_keepComments == KEEPCMT_SUB) {
|
||||
string rtn; rtn.assign(yytext,yyleng);
|
||||
string rtn; rtn.assign(yyourtext(),yyourleng());
|
||||
comment(rtn);
|
||||
} else {
|
||||
return (tok);
|
||||
@@ -762,7 +762,7 @@ int V3PreProcImp::getToken() {
|
||||
// We're off or processed the comment specially. If there are newlines
|
||||
// in it, we also return the newlines as TEXT so that the linenumber
|
||||
// count is maintained for downstream tools
|
||||
for (int len=0; len<yyleng; len++) { if (yytext[len]=='\n') m_lineAdd++; }
|
||||
for (int len=0; len<yyourleng(); len++) { if (yyourtext()[len]=='\n') m_lineAdd++; }
|
||||
goto next_tok;
|
||||
}
|
||||
if (tok==VP_LINE) {
|
||||
@@ -777,7 +777,7 @@ int V3PreProcImp::getToken() {
|
||||
case ps_DEFNAME: {
|
||||
if (tok==VP_SYMBOL) {
|
||||
m_state = ps_TOP;
|
||||
m_lastSym.assign(yytext,yyleng);
|
||||
m_lastSym.assign(yyourtext(),yyourleng());
|
||||
if (m_stateFor==VP_IFDEF
|
||||
|| m_stateFor==VP_IFNDEF) {
|
||||
bool enable = defExists(m_lastSym);
|
||||
@@ -879,11 +879,11 @@ int V3PreProcImp::getToken() {
|
||||
m_state = ps_TOP;
|
||||
// DEFVALUE is terminated by a return, but lex can't return both tokens.
|
||||
// Thus, we emit a return here.
|
||||
yytext=(char*)(newlines.c_str()); yyleng=newlines.length();
|
||||
yyourtext(newlines.c_str(), newlines.length());
|
||||
return(VP_WHITE);
|
||||
}
|
||||
case ps_DEFPAREN: {
|
||||
if (tok==VP_TEXT && yyleng==1 && yytext[0]=='(') {
|
||||
if (tok==VP_TEXT && yyourleng()==1 && yyourtext()[0]=='(') {
|
||||
m_state = ps_DEFARG;
|
||||
goto next_tok;
|
||||
} else {
|
||||
@@ -899,13 +899,13 @@ int V3PreProcImp::getToken() {
|
||||
V3DefineRef* refp = &(m_defRefs.top());
|
||||
refp->nextarg(refp->nextarg()+m_lexp->m_defValue); m_lexp->m_defValue="";
|
||||
UINFO(4,"defarg++ "<<refp->nextarg()<<endl);
|
||||
if (tok==VP_DEFARG && yyleng==1 && yytext[0]==',') {
|
||||
if (tok==VP_DEFARG && yyourleng()==1 && yyourtext()[0]==',') {
|
||||
refp->args().push_back(refp->nextarg());
|
||||
m_state = ps_DEFARG;
|
||||
m_lexp->pushStateDefArg(1);
|
||||
refp->nextarg("");
|
||||
goto next_tok;
|
||||
} else if (tok==VP_DEFARG && yyleng==1 && yytext[0]==')') {
|
||||
} else if (tok==VP_DEFARG && yyourleng()==1 && yyourtext()[0]==')') {
|
||||
refp->args().push_back(refp->nextarg());
|
||||
string out = defineSubst(refp);
|
||||
// Substitute in and prepare for next action
|
||||
@@ -932,7 +932,7 @@ int V3PreProcImp::getToken() {
|
||||
// we'll append it when we push the argument.
|
||||
break;
|
||||
} else if (tok==VP_SYMBOL || tok==VP_STRING || VP_TEXT || VP_WHITE || VP_PSL) {
|
||||
string rtn; rtn.assign(yytext,yyleng);
|
||||
string rtn; rtn.assign(yyourtext(),yyourleng());
|
||||
refp->nextarg(refp->nextarg()+rtn);
|
||||
goto next_tok;
|
||||
} else {
|
||||
@@ -944,7 +944,7 @@ int V3PreProcImp::getToken() {
|
||||
case ps_INCNAME: {
|
||||
if (tok==VP_STRING) {
|
||||
m_state = ps_TOP;
|
||||
m_lastSym.assign(yytext,yyleng);
|
||||
m_lastSym.assign(yyourtext(),yyourleng());
|
||||
UINFO(4,"Include "<<m_lastSym<<endl);
|
||||
// Drop leading and trailing quotes.
|
||||
m_lastSym.erase(0,1);
|
||||
@@ -952,7 +952,7 @@ int V3PreProcImp::getToken() {
|
||||
include(m_lastSym);
|
||||
goto next_tok;
|
||||
}
|
||||
else if (tok==VP_TEXT && yyleng==1 && yytext[0]=='<') {
|
||||
else if (tok==VP_TEXT && yyourleng()==1 && yyourtext()[0]=='<') {
|
||||
// include <filename>
|
||||
m_state = ps_INCNAME; // Still
|
||||
m_lexp->pushStateIncFilename();
|
||||
@@ -972,7 +972,7 @@ int V3PreProcImp::getToken() {
|
||||
if (tok==VP_STRING) {
|
||||
m_state = ps_TOP;
|
||||
if (!m_off) {
|
||||
m_lastSym.assign(yytext,yyleng);
|
||||
m_lastSym.assign(yyourtext(),yyourleng());
|
||||
fileline()->v3error(m_lastSym);
|
||||
}
|
||||
goto next_tok;
|
||||
@@ -1025,7 +1025,7 @@ int V3PreProcImp::getToken() {
|
||||
|
||||
case VP_DEFREF: {
|
||||
if (!m_off) {
|
||||
string name; name.append(yytext+1,yyleng-1);
|
||||
string name; name.append(yyourtext()+1,yyourleng()-1);
|
||||
UINFO(4,"DefRef "<<name<<endl);
|
||||
if (m_defDepth++ > V3PreProc::DEFINE_RECURSION_LEVEL_MAX) {
|
||||
fileline()->v3error("Recursive `define substitution: `"+name);
|
||||
@@ -1112,7 +1112,7 @@ string V3PreProcImp::getline() {
|
||||
while (NULL==(rtnp=strchr(m_lineChars.c_str(),'\n')) && !gotEof) {
|
||||
int tok = getToken();
|
||||
if (debug()>4) {
|
||||
string buf = string (yytext, yyleng);
|
||||
string buf = string (yyourtext(), yyourleng());
|
||||
string::size_type pos;
|
||||
while ((pos=buf.find("\n")) != string::npos) { buf.replace(pos, 1, "\\n"); }
|
||||
while ((pos=buf.find("\r")) != string::npos) { buf.replace(pos, 1, "\\r"); }
|
||||
@@ -1131,7 +1131,7 @@ string V3PreProcImp::getline() {
|
||||
m_lineChars.append(" psl ");
|
||||
}
|
||||
else {
|
||||
m_lineChars.append(yytext,0,yyleng);
|
||||
m_lineChars.append(yyourtext(),0,yyourleng());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user