diff options
Diffstat (limited to 'src/vhdljjparser.cpp')
-rw-r--r-- | src/vhdljjparser.cpp | 91 |
1 files changed, 61 insertions, 30 deletions
diff --git a/src/vhdljjparser.cpp b/src/vhdljjparser.cpp index ae10f4d..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(); @@ -441,9 +440,9 @@ void VhdlParser::createFunction(const char *imp,uint64 spec,const char *fn) QCStringList q1=QCStringList::split(",",fname); for (uint ii=0;ii<q1.count();ii++) { - Argument *arg=new Argument; - arg->name=q1[ii]; - current->argList->append(arg); + Argument arg; + arg.name=q1[ii]; + current->argList.push_back(arg); } } return; @@ -532,7 +531,7 @@ void VhdlParser::addConfigureNode(const char* a,const char*b, bool,bool isLeaf,b void VhdlParser::addProto(const char *s1,const char *s2,const char *s3, - const char *s4,const char *s5,const char *s6) + const char *s4,const char *s5,const char *s6) { (void)s5; // avoid unused warning QCString name=s2; @@ -540,21 +539,21 @@ void VhdlParser::addProto(const char *s1,const char *s2,const char *s3, for (uint u=0;u<ql.count();u++) { - Argument *arg=new Argument; - arg->name=ql[u]; + Argument arg; + arg.name=ql[u]; if (s3) { - arg->type=s3; + arg.type=s3; } - arg->type+=" "; - arg->type+=s4; + arg.type+=" "; + arg.type+=s4; if (s6) { - arg->type+=s6; + arg.type+=s6; } if (parse_sec==GEN_SEC && param_sec==0) { - arg->defval="gen!"; + arg.defval="gen!"; } if (parse_sec==PARAM_SEC) @@ -562,10 +561,10 @@ void VhdlParser::addProto(const char *s1,const char *s2,const char *s3, // assert(false); } - arg->defval+=s1; - arg->attrib="";//s6; + arg.defval+=s1; + arg.attrib="";//s6; - current->argList->append(arg); + current->argList.push_back(arg); current->args+=s2; current->args+=","; } @@ -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(); +} |