From 406e1499c35570e6d4333962ccd420a1ab217f7c Mon Sep 17 00:00:00 2001 From: hake Date: Wed, 3 Jun 2020 19:32:11 +0200 Subject: missing instance-rework --- src/vhdljjparser.cpp | 173 ++++++++++++++++++++++++++++++++++++----------- src/vhdljjparser.h | 1 + vhdlparser/vhdlparser.jj | 2 +- 3 files changed, 136 insertions(+), 40 deletions(-) diff --git a/src/vhdljjparser.cpp b/src/vhdljjparser.cpp index ea60dd6..38aa641 100644 --- a/src/vhdljjparser.cpp +++ b/src/vhdljjparser.cpp @@ -81,6 +81,7 @@ struct VHDLOutlineParser::Private VHDLDocInfo str_doc; VhdlParser::SharedState shared; QCString forL; + int code = 0; }; @@ -264,34 +265,128 @@ void VHDLOutlineParser::handleFlowComment(const char* doc) } } +int VHDLOutlineParser::checkInlineCode(QCString &doc) +{ + QRegExp cs("[\\\\@]code"); + QRegExp cend("[\\s ]*[\\\\@]endcode"); + QRegExp cbrief("[\\\\@]brief"); + int index = doc.find(cs); + + if (doc.contains(cend) > 0) + return 1; + + if (index < 0) + return index; + + VhdlParser::SharedState *s = &p->shared; + p->strComment += doc; + p->code = p->inputString.find(cs, p->code + 1); + int com = p->inputString.find(p->strComment.data()); + int ref = p->inputString.find(cend, p->code + 1); + int len = p->strComment.size(); + + int ll = com + len; + int diff = ref - ll - 3; + QCString code = p->inputString.mid(ll, diff); + int iLine = 0; + code = stripLeadingAndTrailingEmptyLines(code, iLine); + int val = code.contains('\n'); + VhdlDocGen::prepareComment(p->strComment); + QCStringList ql = QCStringList::split('\n', p->strComment); + + QCString co; + QCString na; + for (QCString qcs : ql) + { + qcs = qcs.simplifyWhiteSpace(); + if (qcs.contains(cs)) + { + int i = qcs.find('{'); + int j = qcs.find('}'); + if (i > 0 && j > 0 && j > i) + { + na = qcs.mid(i + 1, (j - i - 1)); + } + continue; + } + qcs = qcs.replace(cbrief, ""); + co += qcs; + co += '\n'; + } + + VhdlDocGen::prepareComment(co); + + Entry gBlock; + if (!na.isEmpty()) + gBlock.name = na; + else + gBlock.name = "misc" + VhdlDocGen::getRecordNumber(); + gBlock.startLine = p->yyLineNr+iLine-1; + gBlock.bodyLine = p->yyLineNr+iLine-1 ; + gBlock.doc = code; + gBlock.inbodyDocs = code; + gBlock.brief = co; + gBlock.section = Entry::VARIABLE_SEC; + gBlock.spec = VhdlDocGen::MISCELLANEOUS; + gBlock.fileName = p->yyFileName; + gBlock.endBodyLine = p->yyLineNr + val +iLine; + gBlock.lang = SrcLangExt_VHDL; + std::shared_ptr compound; + + if (s->lastEntity) + compound = s->lastEntity; + else if (s->lastCompound) + compound = s->lastCompound; + else + compound = 0; + + if (compound) + { + compound->copyToSubEntry(&gBlock); + } + else + { + gBlock.type = "misc"; // global code like library ieee... + s->current_root->copyToSubEntry(&gBlock); + } + p->strComment.resize(0); + return 1; +} -void VHDLOutlineParser::handleCommentBlock(const char* doc1,bool brief) +void VHDLOutlineParser::handleCommentBlock(const char *doc1, bool brief) { + int position = 0; + bool needsEntry = FALSE; VhdlParser::SharedState *s = &p->shared; QCString doc = doc1; - if (doc.isEmpty()) return; - if (checkMultiComment(doc,p->yyLineNr)) + if (doc.isEmpty()) + return; + + if (checkMultiComment(doc, p->yyLineNr)) { p->strComment.resize(0); return; } - VhdlDocGen::prepareComment(doc); + if (checkInlineCode(doc) > 0) + { + return; + } - Protection protection=Public; + Protection protection = Public; + VhdlDocGen::prepareComment(doc); - if (p->oldEntry==s->current.get()) + if (p->oldEntry == s->current.get()) { - //printf("\n find pending message < %s > at line: %d \n ",doc.data(),iDocLine); - p->str_doc.doc=doc; - p->str_doc.iDocLine=p->iDocLine; - p->str_doc.brief=brief; - p->str_doc.pending=TRUE; + p->str_doc.doc = doc; + p->str_doc.iDocLine = p->iDocLine; + p->str_doc.brief = brief; + p->str_doc.pending = TRUE; return; } - p->oldEntry=s->current.get(); + p->oldEntry = s->current.get(); if (brief) { @@ -302,45 +397,45 @@ void VHDLOutlineParser::handleCommentBlock(const char* doc1,bool brief) s->current->docLine = p->yyLineNr; } - int j=doc.find("[plant]"); - if (j>=0) + int j = doc.find("[plant]"); + if (j >= 0) { - doc=doc.remove(j,7); - s->current->stat=true; + doc = doc.remove(j, 7); + s->current->stat = true; } - int position=0; - bool needsEntry=FALSE; - QCString processedDoc = processMarkdownForCommentBlock(doc,p->yyFileName,p->iDocLine); + //int position=0; + + QCString processedDoc = processMarkdownForCommentBlock(doc, p->yyFileName, p->iDocLine); + while (p->commentScanner.parseCommentBlock( - p->thisParser, - s->current.get(), - processedDoc, // text - p->yyFileName, // file - p->iDocLine, // line of block start - brief, - 0, - FALSE, - protection, - position, - needsEntry - ) - ) - { - if (needsEntry) newEntry(); + p->thisParser, + s->current.get(), + processedDoc, // text + p->yyFileName, // file + p->iDocLine, // line of block start + brief, + 0, + FALSE, + protection, + position, + needsEntry)) + { + if (needsEntry) + newEntry(); } if (needsEntry) { if (p->varr) { - p->varr=FALSE; - s->current->name=p->varName; - s->current->section=Entry::VARIABLEDOC_SEC; - p->varName=""; + p->varr = FALSE; + s->current->name = p->varName; + s->current->section = Entry::VARIABLEDOC_SEC; + p->varName = ""; } newEntry(); } - p->iDocLine=-1; + p->iDocLine = -1; p->strComment.resize(0); } diff --git a/src/vhdljjparser.h b/src/vhdljjparser.h index c4a55de..940631d 100755 --- a/src/vhdljjparser.h +++ b/src/vhdljjparser.h @@ -72,6 +72,7 @@ class VHDLOutlineParser : public OutlineParserInterface bool checkMultiComment(QCString& qcs,int line); void insertEntryAtLine(std::shared_ptr ce,int line); QString getNameID(); + int checkInlineCode(QCString & doc); private: struct Private; std::unique_ptr p; diff --git a/vhdlparser/vhdlparser.jj b/vhdlparser/vhdlparser.jj index 4287871..007bd5b 100755 --- a/vhdlparser/vhdlparser.jj +++ b/vhdlparser/vhdlparser.jj @@ -783,7 +783,7 @@ block_statement() LOOKAHEAD([identifier() ":"] [] ) process_statement() | -LOOKAHEAD(generate_statement()) +LOOKAHEAD(3) generate_statement() | case_scheme() -- cgit v0.12