diff options
Diffstat (limited to 'src/vhdljjparser.cpp')
-rw-r--r-- | src/vhdljjparser.cpp | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/src/vhdljjparser.cpp b/src/vhdljjparser.cpp index 39981a0..5dfa9f6 100644 --- a/src/vhdljjparser.cpp +++ b/src/vhdljjparser.cpp @@ -29,11 +29,12 @@ #include "arguments.h" #include "types.h" #include "VhdlParserIF.h" +#include "growbuf.h" using namespace vhdl::parser; using namespace std; -static ParserInterface *g_thisParser; +static OutlineParserInterface *g_thisParser; static QCString yyFileName; static int yyLineNr = 1; @@ -48,16 +49,15 @@ static Entry* oldEntry; static bool varr=FALSE; static QCString varName; -static std::vector< std::unique_ptr<Entry> > instFiles; -static std::vector< std::unique_ptr<Entry> > libUse; +static std::vector< std::shared_ptr<Entry> > instFiles; +static std::vector< std::shared_ptr<Entry> > libUse; static std::vector<Entry*> lineEntry; -Entry* VhdlParser::currentCompound=0; Entry* VhdlParser::tempEntry=0; Entry* VhdlParser::lastEntity=0 ; Entry* VhdlParser::lastCompound=0 ; Entry* VhdlParser::current_root = 0; -std::unique_ptr<Entry> VhdlParser::current=0; +std::shared_ptr<Entry> VhdlParser::current=0; QCString VhdlParser::compSpec; QCString VhdlParser::currName; QCString VhdlParser::confName; @@ -90,7 +90,7 @@ static void insertEntryAtLine(const Entry* ce,int line); //------------------------------------- const QList<VhdlConfNode>& getVhdlConfiguration() { return configL; } -const std::vector<std::unique_ptr<Entry> > &getVhdlInstList() { return instFiles; } +const std::vector<std::shared_ptr<Entry> > &getVhdlInstList() { return instFiles; } Entry* getVhdlCompound() { @@ -105,8 +105,8 @@ bool isConstraintFile(const QCString &fileName,const QCString &ext) } -void VHDLLanguageScanner::parseInput(const char *fileName,const char *fileBuf, - const std::unique_ptr<Entry> &root, bool ,QStrList&) +void VHDLOutlineParser::parseInput(const char *fileName,const char *fileBuf, + const std::shared_ptr<Entry> &root, bool ,QStrList&) { g_thisParser=this; bool inLine=false; @@ -140,10 +140,9 @@ void VHDLLanguageScanner::parseInput(const char *fileName,const char *fileBuf, VhdlParser::current_root=root.get(); VhdlParser::lastCompound=0; VhdlParser::lastEntity=0; - VhdlParser::currentCompound=0; VhdlParser::lastEntity=0; oldEntry = 0; - VhdlParser::current=std::make_unique<Entry>(); + VhdlParser::current=std::make_shared<Entry>(); VhdlParser::initEntry(VhdlParser::current.get()); Doxygen::docGroup.enterFile(fileName,yyLineNr); vhdlFileName = fileName; @@ -171,7 +170,7 @@ void VhdlParser::lineCount(const char* text) { for (const char* c=text ; *c ; ++c ) { - yyLineNr += (*c == '\n') ; + if (*c == '\n') yyLineNr++; } } @@ -321,7 +320,7 @@ void VhdlParser::handleCommentBlock(const char* doc1,bool brief) strComment.resize(0); } -void VHDLLanguageScanner::parsePrototype(const char *text) +void VHDLOutlineParser::parsePrototype(const char *text) { varName=text; varr=TRUE; @@ -347,7 +346,7 @@ void VhdlParser::addCompInst(const char *n, const char* instName, const char* co current->write=genLabels.right(genLabels.length()-u); current->read=genLabels.left(u); } - //printf (" \n genlable: [%s] inst: [%s] name: [%s] %d\n",n,instName,comp,iLine); + //printf (" \n genlabel: [%s] inst: [%s] name: [%s] %d\n",n,instName,comp,iLine); if (lastCompound) { @@ -355,10 +354,10 @@ void VhdlParser::addCompInst(const char *n, const char* instName, const char* co if (true) // !findInstant(current->type)) { initEntry(current.get()); - instFiles.emplace_back(std::make_unique<Entry>(*current)); + instFiles.emplace_back(std::make_shared<Entry>(*current)); } - current=std::make_unique<Entry>(); + current=std::make_shared<Entry>(); } else { @@ -396,7 +395,7 @@ void VhdlParser::addVhdlType(const char *n,int startLine,int section, if (!lastCompound && (section==Entry::VARIABLE_SEC) && (spec == VhdlDocGen::USE || spec == VhdlDocGen::LIBRARY) ) { - libUse.emplace_back(std::make_unique<Entry>(*current)); + libUse.emplace_back(std::make_shared<Entry>(*current)); current->reset(); } newEntry(); @@ -746,3 +745,35 @@ const char *getVhdlFileName(void) { return vhdlFileName; } + +QCString filter2008VhdlComment(const char *s) +{ + GrowBuf growBuf; + const char *p=s+3; // skip /*! + char c='\0'; + while (*p == ' ' || *p == '\t') p++; + while ((c=*p++)) + { + growBuf.addChar(c); + if (c == '\n') + { + // special handling of space followed by * at beginning of line + while (*p == ' ' || *p == '\t') p++; + while (*p == '*') p++; + // special attention in case character at end is / + if (*p == '/') p++; + } + } + // special attention in case */ at end of last line + int len = growBuf.getPos(); + if (growBuf.at(len-1) == '/' && growBuf.at(len-2) == '*') + { + len -= 2; + while (growBuf.at(len-1) == '*') len--; + c = growBuf.at(len-1); + while ((c = growBuf.at(len-1)) == ' ' || c == '\t') len--; + growBuf.setPos(len); + } + growBuf.addChar(0); + return growBuf.get(); +} |