From 8800efe95320e237fb91a1e0b7021dc978dd0e87 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 8 Jul 2010 20:31:41 -0400 Subject: [PATCH] Internals: Rename incLineno to match Verilog-Perl, no functional change. --- src/V3Error.h | 7 ++++++- src/V3ParseImp.h | 2 +- src/V3PreLex.h | 8 ++++++-- src/V3PreLex.l | 6 +++--- src/V3PreProc.cpp | 34 +++++++++++++++++----------------- src/verilog.l | 2 +- 6 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/V3Error.h b/src/V3Error.h index 8599ebbb7..f63c5a8ad 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -234,21 +234,26 @@ protected: // We are storing pointers, so we CAN'T change them after initial reading. friend class V3ParseImp; friend class V3PreLex; + friend class V3PreProcImp; void lineno(int num) { m_lineno = num; } void filename(const string& name) { m_filename = name; } void lineDirective(const char* textp, int& enterExitRef); - void incLineno() { m_lineno++; } + void linenoInc() { m_lineno++; } + void linenoIncInPlace() { m_lineno++; } FileLine* copyOrSameFileLine(); public: FileLine (const string& filename, int lineno) { m_lineno=lineno; m_filename = filename; m_warnOn=s_defaultFileLine.m_warnOn; } FileLine (FileLine* fromp) { m_lineno=fromp->lineno(); m_filename = fromp->filename(); m_warnOn=fromp->m_warnOn; } FileLine (EmptySecret); ~FileLine() { } + FileLine* create(const string& filename, int lineno) { return new FileLine(filename,lineno); } + FileLine* create(int lineno) { return create(filename(), lineno); } static void deleteAllRemaining(); #ifdef VL_LEAK_CHECKS static void* operator new(size_t size); static void operator delete(void* obj, size_t size); #endif + int lineno () const { return m_lineno; } string ascii() const; const string filename () const { return m_filename; } diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index c78f3cd7b..a864ce757 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -249,7 +249,7 @@ public: static bool optFuture(const string& flag) { return v3Global.opt.isFuture(flag); } void ppline (const char* text); - void incLineno() { fileline()->incLineno(); } + void linenoInc() { fileline()->linenoInc(); } void verilatorCmtLint(const char* text, bool on); void verilatorCmtLintSave(); void verilatorCmtLintRestore(); diff --git a/src/V3PreLex.h b/src/V3PreLex.h index 9656666ec..3276a64e7 100644 --- a/src/V3PreLex.h +++ b/src/V3PreLex.h @@ -32,8 +32,12 @@ #include "V3Error.h" +//====================================================================== + +class V3PreProcImp; + // Token codes -// If changing, see V3Pre.cpp's V3PreImp::tokenName() +// If changing, see V3PreProc.cpp's V3PreProcImp::tokenName() #define VP_EOF 0 #define VP_INCLUDE 256 @@ -160,7 +164,7 @@ class V3PreLex { void curFilelinep(FileLine* fl) { m_curFilelinep = fl; } void appendDefValue(const char* text, size_t len); void lineDirective(const char* textp); - void incLineno() { curFilelinep()->incLineno(); } + void linenoInc() { curFilelinep()->linenoInc(); } // Called by V3PreProc.cpp to inform lexer void pushStateDefArg(int level); void pushStateDefForm(); diff --git a/src/V3PreLex.l b/src/V3PreLex.l index 209fa04b6..b29924975 100644 --- a/src/V3PreLex.l +++ b/src/V3PreLex.l @@ -41,7 +41,7 @@ size_t yyourleng() { return yyleng; } void yyourtext(const char* textp, size_t size) { yytext=(char*)textp; yyleng=size; } // Prevent conflicts from perl version -static void linenoInc() {LEXP->incLineno();} +static void linenoInc() {LEXP->linenoInc();} static bool optPsl() { return V3PreProc::optPsl(); } static bool pedantic() { return LEXP->m_pedantic; } static void yyerror(char* msg) { LEXP->curFilelinep()->v3error(msg); } @@ -145,7 +145,7 @@ psl [p]sl <> { yy_pop_state(); return VP_DEFFORM; } /* empty formals */ . { yy_pop_state(); unput(yytext[yyleng-1]); yyleng=0; return VP_DEFFORM; } /* empty formals */ - /* Reading definition formals */ + /* Reading definition formals (declaration of a define) */ [(] { appendDefValue(yytext,yyleng); yyleng=0; ++LEXP->m_formalLevel; } [)] { appendDefValue(yytext,yyleng); yyleng=0; if ((--LEXP->m_formalLevel)==0) { yy_pop_state(); return VP_DEFFORM; } } "/*" { yy_push_state(CMTMODE); yymore(); } @@ -161,7 +161,7 @@ psl [p]sl [\\][^\n\r] | . { appendDefValue(yytext,yyleng); } - /* Reading definition value */ + /* Reading definition value (declaration of a define's text) */ "/*" { LEXP->m_defCmtSlash=false; yy_push_state(DEFCMT); yymore(); } /* Special comment parser */ "//"[^\n\r]*[\\]{crnl} { linenoInc(); appendDefValue((char*)"\n",1); } /* Spec says // not part of define value */ "//"[^\n\r]* { return (VP_COMMENT);} diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index 81b2c5c3c..06b2a72ed 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -391,28 +391,28 @@ void V3PreProcImp::comment(const string& text) { const char* V3PreProcImp::tokenName(int tok) { switch (tok) { - case VP_EOF : return("EOF"); - case VP_INCLUDE : return("INCLUDE"); - case VP_IFDEF : return("IFDEF"); - case VP_IFNDEF : return("IFNDEF"); - case VP_ENDIF : return("ENDIF"); - case VP_UNDEF : return("UNDEF"); + case VP_COMMENT : return("COMMENT"); + case VP_DEFARG : return("DEFARG"); + case VP_DEFFORM : return("DEFFORM"); case VP_DEFINE : return("DEFINE"); + case VP_DEFREF : return("DEFREF"); + case VP_DEFVALUE : return("DEFVALUE"); case VP_ELSE : return("ELSE"); case VP_ELSIF : return("ELSIF"); - case VP_LINE : return("LINE"); - case VP_SYMBOL : return("SYMBOL"); - case VP_STRING : return("STRING"); - case VP_DEFFORM : return("DEFFORM"); - case VP_DEFVALUE : return("DEFVALUE"); - case VP_COMMENT : return("COMMENT"); - case VP_TEXT : return("TEXT"); - case VP_WHITE : return("WHITE"); - case VP_DEFREF : return("DEFREF"); - case VP_DEFARG : return("DEFARG"); + case VP_ENDIF : return("ENDIF"); + case VP_EOF : return("EOF"); case VP_ERROR : return("ERROR"); - case VP_UNDEFINEALL : return("UNDEFINEALL"); + case VP_IFDEF : return("IFDEF"); + case VP_IFNDEF : return("IFNDEF"); + case VP_INCLUDE : return("INCLUDE"); + case VP_LINE : return("LINE"); case VP_PSL : return("PSL"); + case VP_STRING : return("STRING"); + case VP_SYMBOL : return("SYMBOL"); + case VP_TEXT : return("TEXT"); + case VP_UNDEF : return("UNDEF"); + case VP_UNDEFINEALL : return("UNDEFINEALL"); + case VP_WHITE : return("WHITE"); default: return("?"); } } diff --git a/src/verilog.l b/src/verilog.l index 71b3aaec4..dd714e0c2 100644 --- a/src/verilog.l +++ b/src/verilog.l @@ -42,7 +42,7 @@ extern void yyerrorf(const char* format, ...); //====================================================================== -#define NEXTLINE() {PARSEP->incLineno();} +#define NEXTLINE() {PARSEP->linenoInc();} #define CRELINE() (PARSEP->copyOrSameFileLine()) #define FL { yylval.fl = CRELINE(); }