clang-format verilog.l. No functional change.
This commit is contained in:
parent
8f58b58853
commit
3cb3b6c400
102
src/verilog.l
102
src/verilog.l
|
|
@ -32,8 +32,7 @@ extern void yyerrorf(const char* format, ...);
|
||||||
#define PARSEP V3ParseImp::parsep()
|
#define PARSEP V3ParseImp::parsep()
|
||||||
#define SYMP PARSEP->symp()
|
#define SYMP PARSEP->symp()
|
||||||
|
|
||||||
#define YY_INPUT(buf,result,max_size) \
|
#define YY_INPUT(buf, result, max_size) result = PARSEP->flexPpInputToLex(buf, max_size);
|
||||||
result = PARSEP->flexPpInputToLex(buf, max_size);
|
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
|
||||||
|
|
@ -1051,6 +1050,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
|
||||||
/* Catch all - absolutely last */
|
/* Catch all - absolutely last */
|
||||||
<*>.|\n { FL_FWD; yyerrorf("Missing verilog.l rule: Default rule invoked in state %d: %s", YY_START, yytext); FL_BRK; }
|
<*>.|\n { FL_FWD; yyerrorf("Missing verilog.l rule: Default rule invoked in state %d: %s", YY_START, yytext); FL_BRK; }
|
||||||
%%
|
%%
|
||||||
|
|
||||||
int V3ParseImp::stateVerilogRecent() { return STATE_VERILOG_RECENT; }
|
int V3ParseImp::stateVerilogRecent() { return STATE_VERILOG_RECENT; }
|
||||||
|
|
||||||
void V3ParseImp::lexToken() {
|
void V3ParseImp::lexToken() {
|
||||||
|
|
@ -1068,15 +1068,17 @@ void V3ParseImp::lexToken() {
|
||||||
// yylval // Set by yylexReadTok()
|
// yylval // Set by yylexReadTok()
|
||||||
}
|
}
|
||||||
// If a paren, read another
|
// If a paren, read another
|
||||||
if (token == '('
|
if (token == '(' //
|
||||||
|| token == yCONST__LEX
|
|| token == yCONST__LEX //
|
||||||
|| token == yGLOBAL__LEX
|
|| token == yGLOBAL__LEX //
|
||||||
|| token == yLOCAL__LEX
|
|| token == yLOCAL__LEX //
|
||||||
|| token == yNEW__LEX
|
|| token == yNEW__LEX //
|
||||||
|| token == yVIRTUAL__LEX
|
|| token == yVIRTUAL__LEX
|
||||||
// Never put yID_* here; below symbol table resolution would break
|
// Never put yID_* here; below symbol table resolution would break
|
||||||
) {
|
) {
|
||||||
if (debugFlex()>=6) { cout<<" lexToken: reading ahead to find possible strength"<<endl; }
|
if (debugFlex() >= 6) {
|
||||||
|
cout << " lexToken: reading ahead to find possible strength" << endl;
|
||||||
|
}
|
||||||
V3ParseBisonYYSType curValue = yylval; // Remember value, as about to read ahead
|
V3ParseBisonYYSType curValue = yylval; // Remember value, as about to read ahead
|
||||||
int nexttok = yylexReadTok();
|
int nexttok = yylexReadTok();
|
||||||
m_ahead = true;
|
m_ahead = true;
|
||||||
|
|
@ -1084,36 +1086,50 @@ void V3ParseImp::lexToken() {
|
||||||
m_aheadVal.token = nexttok;
|
m_aheadVal.token = nexttok;
|
||||||
yylval = curValue;
|
yylval = curValue;
|
||||||
// Now potentially munge the current token
|
// Now potentially munge the current token
|
||||||
if (token == '(' && (nexttok == ygenSTRENGTH
|
if (token == '('
|
||||||
|| nexttok == ySUPPLY0
|
&& (nexttok == ygenSTRENGTH || nexttok == ySUPPLY0 || nexttok == ySUPPLY1)) {
|
||||||
|| nexttok == ySUPPLY1)) {
|
|
||||||
token = yP_PAR__STRENGTH;
|
token = yP_PAR__STRENGTH;
|
||||||
|
} else if (token == yCONST__LEX) {
|
||||||
|
if (nexttok == yREF) {
|
||||||
|
token = yCONST__REF;
|
||||||
|
} else {
|
||||||
|
token = yCONST__ETC;
|
||||||
}
|
}
|
||||||
else if (token == yCONST__LEX) {
|
} else if (token == yGLOBAL__LEX) {
|
||||||
if (nexttok == yREF) token = yCONST__REF;
|
if (nexttok == yCLOCKING) {
|
||||||
else token = yCONST__ETC;
|
token = yGLOBAL__CLOCKING;
|
||||||
|
} else if (v3Global.opt.pedantic()) {
|
||||||
|
token = yGLOBAL__ETC;
|
||||||
}
|
}
|
||||||
else if (token == yGLOBAL__LEX) {
|
|
||||||
if (nexttok == yCLOCKING) token = yGLOBAL__CLOCKING;
|
|
||||||
else if (v3Global.opt.pedantic()) token = yGLOBAL__ETC;
|
|
||||||
// Avoid 2009 "global" conflicting with old code when we can
|
// Avoid 2009 "global" conflicting with old code when we can
|
||||||
else { token = yaID__LEX; yylval.strp = PARSEP->newString("global"); }
|
else {
|
||||||
|
token = yaID__LEX;
|
||||||
|
yylval.strp = PARSEP->newString("global");
|
||||||
}
|
}
|
||||||
else if (token == yLOCAL__LEX) {
|
} else if (token == yLOCAL__LEX) {
|
||||||
if (nexttok == yP_COLONCOLON) token = yLOCAL__COLONCOLON;
|
if (nexttok == yP_COLONCOLON) {
|
||||||
else token = yLOCAL__ETC;
|
token = yLOCAL__COLONCOLON;
|
||||||
|
} else {
|
||||||
|
token = yLOCAL__ETC;
|
||||||
}
|
}
|
||||||
else if (token == yNEW__LEX) {
|
} else if (token == yNEW__LEX) {
|
||||||
if (nexttok == '(') token = yNEW__PAREN;
|
if (nexttok == '(') {
|
||||||
else token = yNEW__ETC;
|
token = yNEW__PAREN;
|
||||||
|
} else {
|
||||||
|
token = yNEW__ETC;
|
||||||
}
|
}
|
||||||
else if (token == yVIRTUAL__LEX) {
|
} else if (token == yVIRTUAL__LEX) {
|
||||||
if (nexttok == yCLASS) token = yVIRTUAL__CLASS;
|
if (nexttok == yCLASS) {
|
||||||
else if (nexttok == yINTERFACE) token = yVIRTUAL__INTERFACE;
|
token = yVIRTUAL__CLASS;
|
||||||
else if (nexttok == yaID__ETC || nexttok == yaID__LEX)
|
} else if (nexttok == yINTERFACE) {
|
||||||
|
token = yVIRTUAL__INTERFACE;
|
||||||
|
} else if (nexttok == yaID__ETC //
|
||||||
|
|| nexttok == yaID__LEX) {
|
||||||
// || nexttok == yaID__aINTERFACE // but we may not know interfaces yet.
|
// || nexttok == yaID__aINTERFACE // but we may not know interfaces yet.
|
||||||
token = yVIRTUAL__anyID;
|
token = yVIRTUAL__anyID;
|
||||||
else token = yVIRTUAL__ETC;
|
} else {
|
||||||
|
token = yVIRTUAL__ETC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// If add to above "else if", also add to "if (token" further above
|
// If add to above "else if", also add to "if (token" further above
|
||||||
}
|
}
|
||||||
|
|
@ -1127,8 +1143,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()
|
UINFO(7, " lexToken: find upward " << SYMP->symCurrentp() << " for '"
|
||||||
<<" for '"<<*(yylval.strp)<<"'"<<endl);
|
<< *(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));
|
||||||
}
|
}
|
||||||
|
|
@ -1136,14 +1152,22 @@ void V3ParseImp::lexToken() {
|
||||||
AstNode* scp = foundp->nodep();
|
AstNode* scp = foundp->nodep();
|
||||||
yylval.scp = scp;
|
yylval.scp = scp;
|
||||||
UINFO(7, " lexToken: Found " << scp << endl);
|
UINFO(7, " lexToken: Found " << scp << endl);
|
||||||
if (VN_IS(scp, Typedef)) token = yaID__aTYPE;
|
if (VN_IS(scp, Typedef)) {
|
||||||
else if (VN_IS(scp, TypedefFwd)) token = yaID__aTYPE;
|
token = yaID__aTYPE;
|
||||||
else if (VN_IS(scp, Class)) token = yaID__aTYPE;
|
} else if (VN_IS(scp, TypedefFwd)) {
|
||||||
// Packages we could alternatively determine by looking for
|
token = yaID__aTYPE;
|
||||||
// an yaID__LEX followed by yP_COLONCOLON (but we can't lookahead
|
} else if (VN_IS(scp, Class)) {
|
||||||
// after an yaID__LEX as described above.)
|
token = yaID__aTYPE;
|
||||||
else if (VN_IS(scp, Package)) token = yaID__aPACKAGE;
|
}
|
||||||
else token = yaID__ETC;
|
// Packages (and class static references) we could
|
||||||
|
// alternatively determine by looking for an yaID__LEX followed
|
||||||
|
// by yP_COLONCOLON (but we can't lookahead after an yaID__LEX
|
||||||
|
// as described above.)
|
||||||
|
else if (VN_IS(scp, Package)) {
|
||||||
|
token = yaID__aPACKAGE;
|
||||||
|
} else {
|
||||||
|
token = yaID__ETC;
|
||||||
|
}
|
||||||
} else { // Not found
|
} else { // Not found
|
||||||
yylval.scp = NULL;
|
yylval.scp = NULL;
|
||||||
token = yaID__ETC;
|
token = yaID__ETC;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue