Internals: Detab and fix spacing style issues. No functional change.

When diff, recommend using "git diff --ignore-all-space"
When merging, recommend using "git merge -Xignore-all-space"
This commit is contained in:
Wilson Snyder 2019-07-11 06:57:49 -04:00
parent 6c5cc885a6
commit 58dfe9d071
2 changed files with 1080 additions and 1072 deletions

View File

@ -84,27 +84,27 @@ bom [\357\273\277]
<INITIAL>{bom} { } <INITIAL>{bom} { }
<INITIAL,STRIFY>^{ws}*"`line"{ws}+.*{crnl} { LEXP->lineDirective(yytext); <INITIAL,STRIFY>^{ws}*"`line"{ws}+.*{crnl} { LEXP->lineDirective(yytext);
return(VP_LINE); } return VP_LINE; }
/* Special directives we recognize */ /* Special directives we recognize */
<INITIAL>"`define" { return(VP_DEFINE); } <INITIAL>"`define" { return VP_DEFINE; }
<INITIAL>"`else" { return(VP_ELSE); } <INITIAL>"`else" { return VP_ELSE; }
<INITIAL>"`elsif" { return(VP_ELSIF); } <INITIAL>"`elsif" { return VP_ELSIF; }
<INITIAL>"`endif" { return(VP_ENDIF); } <INITIAL>"`endif" { return VP_ENDIF; }
<INITIAL>"`ifdef" { return(VP_IFDEF); } <INITIAL>"`ifdef" { return VP_IFDEF; }
<INITIAL>"`ifndef" { return(VP_IFNDEF); } <INITIAL>"`ifndef" { return VP_IFNDEF; }
<INITIAL>"`include" { return(VP_INCLUDE); } <INITIAL>"`include" { return VP_INCLUDE; }
<INITIAL>"`undef" { return(VP_UNDEF); } <INITIAL>"`undef" { return VP_UNDEF; }
<INITIAL>"`undefineall" { return(VP_UNDEFINEALL); } <INITIAL>"`undefineall" { return VP_UNDEFINEALL; }
<INITIAL>"`error" { if (!pedantic()) return (VP_ERROR); else return(VP_DEFREF); } <INITIAL>"`error" { if (!pedantic()) return VP_ERROR; else return VP_DEFREF; }
<INITIAL,STRIFY>"`__FILE__" { static string rtnfile; <INITIAL,STRIFY>"`__FILE__" { static string rtnfile;
rtnfile = '"'; rtnfile += LEXP->curFilelinep()->filename(); rtnfile = '"'; rtnfile += LEXP->curFilelinep()->filename();
rtnfile += '"'; yytext = (char*)rtnfile.c_str(); yyleng = rtnfile.length(); rtnfile += '"'; yytext = (char*)rtnfile.c_str(); yyleng = rtnfile.length();
return (VP_STRING); } return VP_STRING; }
<INITIAL,STRIFY>"`__LINE__" { static char buf[10]; <INITIAL,STRIFY>"`__LINE__" { static char buf[10];
sprintf(buf, "%d", LEXP->curFilelinep()->lineno()); sprintf(buf, "%d", LEXP->curFilelinep()->lineno());
yytext = buf; yyleng = strlen(yytext); yytext = buf; yyleng = strlen(yytext);
return (VP_TEXT); } return VP_TEXT; }
/* Pass-through strings */ /* Pass-through strings */
<INITIAL>{quote} { yy_push_state(STRMODE); yymore(); } <INITIAL>{quote} { yy_push_state(STRMODE); yymore(); }
@ -118,7 +118,7 @@ bom [\357\273\277]
<STRMODE>{quote} { yy_pop_state(); <STRMODE>{quote} { yy_pop_state();
if (LEXP->m_parenLevel || LEXP->m_defQuote) { if (LEXP->m_parenLevel || LEXP->m_defQuote) {
LEXP->m_defQuote=false; appendDefValue(yytext, yyleng); yyleng=0; LEXP->m_defQuote=false; appendDefValue(yytext, yyleng); yyleng=0;
} else return (VP_STRING); } } else return VP_STRING; }
/* Stringification */ /* Stringification */
<INITIAL>{tickquote} { yy_push_state(STRIFY); return VP_STRIFY; } <INITIAL>{tickquote} { yy_push_state(STRIFY); return VP_STRIFY; }
@ -126,16 +126,16 @@ bom [\357\273\277]
<STRIFY>"`\\`\"" { return VP_BACKQUOTE; } <STRIFY>"`\\`\"" { return VP_BACKQUOTE; }
<STRIFY>{quote} { yy_push_state(STRMODE); yymore(); } <STRIFY>{quote} { yy_push_state(STRMODE); yymore(); }
<STRIFY>{tickquote} { yy_pop_state(); return VP_STRIFY; } <STRIFY>{tickquote} { yy_pop_state(); return VP_STRIFY; }
<STRIFY>{symbdef} { return (VP_SYMBOL); } <STRIFY>{symbdef} { return VP_SYMBOL; }
<STRIFY>{symbdef}`` { yyleng-=2; return (VP_SYMBOL_JOIN); } <STRIFY>{symbdef}`` { yyleng-=2; return VP_SYMBOL_JOIN; }
<STRIFY>"`"{symbdef} { return (VP_DEFREF); } <STRIFY>"`"{symbdef} { return VP_DEFREF; }
<STRIFY>"`"{symbdef}`` { yyleng-=2; return (VP_DEFREF_JOIN); } <STRIFY>"`"{symbdef}`` { yyleng-=2; return VP_DEFREF_JOIN; }
<STRIFY>`` { yyleng-=2; return (VP_JOIN); } <STRIFY>`` { yyleng-=2; return VP_JOIN; }
<STRIFY>{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return(VP_WHITE); } <STRIFY>{crnl} { linenoInc(); yytext = (char*)"\n"; yyleng = 1; return VP_WHITE; }
<STRIFY>{wsn}+ { return (VP_WHITE); } <STRIFY>{wsn}+ { return VP_WHITE; }
<STRIFY>{drop} { } <STRIFY>{drop} { }
<STRIFY>[\r] { } <STRIFY>[\r] { }
<STRIFY>. { return (VP_TEXT); } <STRIFY>. { return VP_TEXT; }
/* Protected blocks */ /* Protected blocks */
<INITIAL>"`protected" { yy_push_state(PRTMODE); yymore(); } <INITIAL>"`protected" { yy_push_state(PRTMODE); yymore(); }
@ -163,7 +163,7 @@ bom [\357\273\277]
<DEFFORM>[)] { appendDefValue(yytext, yyleng); yyleng=0; <DEFFORM>[)] { appendDefValue(yytext, yyleng); yyleng=0;
if ((--LEXP->m_formalLevel)==0) { yy_pop_state(); return VP_DEFFORM; } } if ((--LEXP->m_formalLevel)==0) { yy_pop_state(); return VP_DEFFORM; } }
<DEFFORM>"/*" { yy_push_state(CMTMODE); yymore(); } <DEFFORM>"/*" { yy_push_state(CMTMODE); yymore(); }
<DEFFORM>"//"[^\n\r]* { return (VP_COMMENT);} <DEFFORM>"//"[^\n\r]* { return VP_COMMENT;}
<DEFFORM>{drop} { } <DEFFORM>{drop} { }
<DEFFORM><<EOF>> { linenoInc(); yy_pop_state(); yyerrorf("Unterminated ( in define formal arguments."); yyleng=0; return VP_DEFFORM; } <DEFFORM><<EOF>> { linenoInc(); yy_pop_state(); yyerrorf("Unterminated ( in define formal arguments."); yyleng=0; return VP_DEFFORM; }
<DEFFORM>{crnl} { linenoInc(); appendDefValue((char*)"\n", 1); } /* Include return so can maintain output line count */ <DEFFORM>{crnl} { linenoInc(); appendDefValue((char*)"\n", 1); } /* Include return so can maintain output line count */
@ -181,10 +181,10 @@ bom [\357\273\277]
/* Reading definition value (declaration of a define's text) */ /* Reading definition value (declaration of a define's text) */
<DEFVAL>"/*" { LEXP->m_defCmtSlash=false; yy_push_state(DEFCMT); yymore(); } /* Special comment parser */ <DEFVAL>"/*" { LEXP->m_defCmtSlash=false; yy_push_state(DEFCMT); yymore(); } /* Special comment parser */
<DEFVAL>"//"[^\n\r]*[\\]{crnl} { linenoInc(); appendDefValue((char*)"\n", 1); } /* Spec says // not part of define value */ <DEFVAL>"//"[^\n\r]*[\\]{crnl} { linenoInc(); appendDefValue((char*)"\n", 1); } /* Spec says // not part of define value */
<DEFVAL>"//"[^\n\r]* { return (VP_COMMENT);} <DEFVAL>"//"[^\n\r]* { return VP_COMMENT;}
<DEFVAL>{drop} { } <DEFVAL>{drop} { }
<DEFVAL><<EOF>> { linenoInc(); yy_pop_state(); yytext=(char*)"\n"; yyleng=1; return (VP_DEFVALUE); } /* Technically illegal, but people complained */ <DEFVAL><<EOF>> { linenoInc(); yy_pop_state(); yytext=(char*)"\n"; yyleng=1; return VP_DEFVALUE; } /* Technically illegal, but people complained */
<DEFVAL>{crnl} { linenoInc(); yy_pop_state(); yytext=(char*)"\n"; yyleng=1; return (VP_DEFVALUE); } <DEFVAL>{crnl} { linenoInc(); yy_pop_state(); yytext=(char*)"\n"; yyleng=1; return VP_DEFVALUE; }
<DEFVAL>[\\]{wsn}+{crnl} { yyless(1); LEXP->curFilelinep()->v3warn(BSSPACE, "Backslash followed by whitespace, perhaps the whitespace is accidental?"); } <DEFVAL>[\\]{wsn}+{crnl} { yyless(1); LEXP->curFilelinep()->v3warn(BSSPACE, "Backslash followed by whitespace, perhaps the whitespace is accidental?"); }
<DEFVAL>[\\]{crnl} { linenoInc(); appendDefValue((char*)"\\\n", 2); } /* Return, AND \ is part of define value */ <DEFVAL>[\\]{crnl} { linenoInc(); appendDefValue((char*)"\\\n", 2); } /* Return, AND \ is part of define value */
<DEFVAL>{quote} { LEXP->m_defQuote = true; yy_push_state(STRMODE); yymore(); } <DEFVAL>{quote} { LEXP->m_defQuote = true; yy_push_state(STRMODE); yymore(); }
@ -207,13 +207,13 @@ bom [\357\273\277]
/* Define arguments (use of a define) */ /* Define arguments (use of a define) */
<ARGMODE>"/*" { yy_push_state(CMTMODE); yymore(); } <ARGMODE>"/*" { yy_push_state(CMTMODE); yymore(); }
<ARGMODE>"//"[^\n\r]* { return (VP_COMMENT);} <ARGMODE>"//"[^\n\r]* { return VP_COMMENT;}
<ARGMODE>{drop} { } <ARGMODE>{drop} { }
<ARGMODE><<EOF>> { yyerrorf("EOF in define argument list\n"); yyleng = 0; yyterminate(); } <ARGMODE><<EOF>> { yyerrorf("EOF in define argument list\n"); yyleng = 0; yyterminate(); }
<ARGMODE>{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return(VP_WHITE); } <ARGMODE>{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return VP_WHITE; }
<ARGMODE>{quote} { yy_push_state(STRMODE); yymore(); } <ARGMODE>{quote} { yy_push_state(STRMODE); yymore(); }
<ARGMODE>"`\\`\"" { appendDefValue(yytext, yyleng); } /* Literal text */ <ARGMODE>"`\\`\"" { appendDefValue(yytext, yyleng); } /* Literal text */
<ARGMODE>{tickquote} { yy_push_state(STRIFY); return(VP_STRIFY); } <ARGMODE>{tickquote} { yy_push_state(STRIFY); return VP_STRIFY; }
<ARGMODE>[{\[] { LEXP->m_parenLevel++; appendDefValue(yytext, yyleng); } <ARGMODE>[{\[] { LEXP->m_parenLevel++; appendDefValue(yytext, yyleng); }
<ARGMODE>[}\]] { LEXP->m_parenLevel--; appendDefValue(yytext, yyleng); } <ARGMODE>[}\]] { LEXP->m_parenLevel--; appendDefValue(yytext, yyleng); }
<ARGMODE>[(] { LEXP->m_parenLevel++; <ARGMODE>[(] { LEXP->m_parenLevel++;
@ -223,18 +223,18 @@ bom [\357\273\277]
if (LEXP->m_parenLevel>1) { if (LEXP->m_parenLevel>1) {
appendDefValue(yytext, yyleng); appendDefValue(yytext, yyleng);
} else { } else {
return (VP_TEXT); return VP_TEXT;
}} }}
<ARGMODE>[)] { LEXP->m_parenLevel--; <ARGMODE>[)] { LEXP->m_parenLevel--;
if (LEXP->m_parenLevel>0) { if (LEXP->m_parenLevel>0) {
appendDefValue(yytext, yyleng); appendDefValue(yytext, yyleng);
} else { } else {
yy_pop_state(); return (VP_DEFARG); yy_pop_state(); return VP_DEFARG;
}} }}
<ARGMODE>[,] { if (LEXP->m_parenLevel>1) { <ARGMODE>[,] { if (LEXP->m_parenLevel>1) {
appendDefValue(yytext, yyleng); appendDefValue(yytext, yyleng);
} else { } else {
yy_pop_state(); return (VP_DEFARG); yy_pop_state(); return VP_DEFARG;
}} }}
<ARGMODE>"`"{symbdef} { appendDefValue(yytext, yyleng); } /* defref in defref - outer macro expands first */ <ARGMODE>"`"{symbdef} { appendDefValue(yytext, yyleng); } /* defref in defref - outer macro expands first */
<ARGMODE>"`"{symbdef}`` { appendDefValue(yytext, yyleng); } /* defref in defref - outer macro expands first */ <ARGMODE>"`"{symbdef}`` { appendDefValue(yytext, yyleng); } /* defref in defref - outer macro expands first */
@ -243,16 +243,16 @@ bom [\357\273\277]
<ARGMODE>. { appendDefValue(yytext, yyleng); } <ARGMODE>. { appendDefValue(yytext, yyleng); }
/* One line comments. */ /* One line comments. */
<INITIAL>"//"{ws}*{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return (VP_WHITE); } <INITIAL>"//"{ws}*{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return VP_WHITE; }
<INITIAL>"//" { yy_push_state(CMTONEM); yymore(); } <INITIAL>"//" { yy_push_state(CMTONEM); yymore(); }
<CMTONEM>[^\n\r]* { yy_pop_state(); return (VP_COMMENT); } <CMTONEM>[^\n\r]* { yy_pop_state(); return VP_COMMENT; }
/* C-style comments. */ /* C-style comments. */
/**** See also DEFCMT */ /**** See also DEFCMT */
/* We distinguish between the start of a comment, and later, to look for prefix comments (deprecated) */ /* We distinguish between the start of a comment, and later, to look for prefix comments (deprecated) */
<INITIAL>"/*" { yy_push_state(CMTMODE); yymore(); } <INITIAL>"/*" { yy_push_state(CMTMODE); yymore(); }
<CMTBEGM>{ws}+ { yymore(); } <CMTBEGM>{ws}+ { yymore(); }
<CMTBEGM,CMTMODE>"*/" { yy_pop_state(); return(VP_COMMENT); } <CMTBEGM,CMTMODE>"*/" { yy_pop_state(); return VP_COMMENT; }
<CMTBEGM,CMTMODE>{crnl} { linenoInc(); yymore(); } <CMTBEGM,CMTMODE>{crnl} { linenoInc(); yymore(); }
<CMTBEGM,CMTMODE><<EOF>> { yyerrorf("EOF in '/* ... */' block comment\n"); yyleng=0; yyterminate(); } <CMTBEGM,CMTMODE><<EOF>> { yyerrorf("EOF in '/* ... */' block comment\n"); yyleng=0; yyterminate(); }
<CMTMODE>{word} { yymore(); } <CMTMODE>{word} { yymore(); }
@ -261,19 +261,19 @@ bom [\357\273\277]
/* Define calls */ /* Define calls */
/* symbdef prevents normal lex rules from making `\`"foo a symbol {`"foo} instead of a BACKQUOTE */ /* symbdef prevents normal lex rules from making `\`"foo a symbol {`"foo} instead of a BACKQUOTE */
<INITIAL>"`"{symbdef} { return (VP_DEFREF); } <INITIAL>"`"{symbdef} { return VP_DEFREF; }
<INITIAL>"`"{symbdef}`` { yyleng-=2; return (VP_DEFREF_JOIN); } <INITIAL>"`"{symbdef}`` { yyleng-=2; return VP_DEFREF_JOIN; }
/* Generics */ /* Generics */
<INITIAL>{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return(VP_WHITE); } <INITIAL>{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return VP_WHITE; }
<INITIAL><<EOF>> { yyterminate(); } /* A "normal" EOF */ <INITIAL><<EOF>> { yyterminate(); } /* A "normal" EOF */
<INITIAL>{symb} { return (VP_SYMBOL); } <INITIAL>{symb} { return VP_SYMBOL; }
<INITIAL>{symb}`` { yyleng-=2; return (VP_SYMBOL_JOIN); } <INITIAL>{symb}`` { yyleng-=2; return VP_SYMBOL_JOIN; }
<INITIAL>`` { yyleng-=2; return (VP_JOIN); } <INITIAL>`` { yyleng-=2; return VP_JOIN; }
<INITIAL>{wsn}+ { return (VP_WHITE); } <INITIAL>{wsn}+ { return VP_WHITE; }
<INITIAL>{drop} { } <INITIAL>{drop} { }
<INITIAL>[\r] { } <INITIAL>[\r] { }
<INITIAL>. { return (VP_TEXT); } <INITIAL>. { return VP_TEXT; }
%% %%
void V3PreLex::pushStateDefArg(int level) { void V3PreLex::pushStateDefArg(int level) {
@ -320,7 +320,10 @@ size_t V3PreLex::inputToLex(char* buf, size_t max_size) {
// become a stale invalid pointer. // become a stale invalid pointer.
// //
VPreStream* streamp = curStreamp(); VPreStream* streamp = curStreamp();
if (debug()>=10) { cout<<"- pp:inputToLex ITL s="<<max_size<<" bs="<<streamp->m_buffers.size()<<endl; dumpStack(); } if (debug()>=10) {
cout<<"- pp:inputToLex ITL s="<<max_size<<" bs="<<streamp->m_buffers.size()<<endl;
dumpStack();
}
// For testing, use really small chunks // For testing, use really small chunks
//if (max_size > 13) max_size=13; //if (max_size > 13) max_size=13;
again: again:
@ -365,7 +368,9 @@ size_t V3PreLex::inputToLex(char* buf, size_t max_size) {
string V3PreLex::endOfStream(bool& againr) { string V3PreLex::endOfStream(bool& againr) {
// Switch to file or next unputString // Switch to file or next unputString
againr = false; againr = false;
if (yy_flex_debug) cout<<"-EOS state="<<curStreamp()->m_termState<<" at "<<curFilelinep()<<endl; if (yy_flex_debug) {
cout<<"-EOS state="<<curStreamp()->m_termState<<" at "<<curFilelinep()<<endl;
}
if (curStreamp()->m_eof) return ""; // Don't delete the final "EOF" stream if (curStreamp()->m_eof) return ""; // Don't delete the final "EOF" stream
bool exited_file = curStreamp()->m_file; bool exited_file = curStreamp()->m_file;
if (!exited_file) { if (!exited_file) {

View File

@ -1022,7 +1022,8 @@ void V3ParseImp::lexToken() {
// "consume" it. Must set again if want another token under temp scope // "consume" it. Must set again if want another token under temp scope
SYMP->nextId(NULL); SYMP->nextId(NULL);
} else { } else {
UINFO(7," lexToken: find upward "<<SYMP->symCurrentp()<<" for '"<<*(yylval.strp)<<"'"<<endl); UINFO(7," lexToken: find upward "<<SYMP->symCurrentp()
<<" for '"<<*(yylval.strp)<<"'"<<endl);
//if (debug()>=9) SYMP->symCurrentp()->dump(cout," -findtree: ", true); //if (debug()>=9) SYMP->symCurrentp()->dump(cout," -findtree: ", true);
foundp = SYMP->symCurrentp()->findIdFallback(*(yylval.strp)); foundp = SYMP->symCurrentp()->findIdFallback(*(yylval.strp));
} }
@ -1055,7 +1056,9 @@ int V3ParseImp::lexToBison() {
if (debugFlex()>=6 || debugBison()>=6) { if (debugFlex()>=6 || debugBison()>=6) {
cout<<" {"<<yylval.fl->filenameLetters()<<yylval.fl->lineno() cout<<" {"<<yylval.fl->filenameLetters()<<yylval.fl->lineno()
<<"} lexToBison TOKEN="<<yylval.token<<" "<<tokenName(yylval.token); <<"} lexToBison TOKEN="<<yylval.token<<" "<<tokenName(yylval.token);
if (yylval.token == yaID__ETC || yylval.token == yaID__LEX || yylval.token == yaID__aTYPE) { if (yylval.token == yaID__ETC
|| yylval.token == yaID__LEX
|| yylval.token == yaID__aTYPE) {
cout<<" strp='"<<*(yylval.strp)<<"'"; cout<<" strp='"<<*(yylval.strp)<<"'";
} }
cout<<endl; cout<<endl;