Skip to content

Commit

Permalink
missing instance-rework
Browse files Browse the repository at this point in the history
  • Loading branch information
maddox11 committed Jun 3, 2020
1 parent fd11115 commit 406e149
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 40 deletions.
173 changes: 134 additions & 39 deletions src/vhdljjparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct VHDLOutlineParser::Private
VHDLDocInfo str_doc;
VhdlParser::SharedState shared;
QCString forL;
int code = 0;

};

Expand Down Expand Up @@ -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<Entry> 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)
{
Expand All @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions src/vhdljjparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class VHDLOutlineParser : public OutlineParserInterface
bool checkMultiComment(QCString& qcs,int line);
void insertEntryAtLine(std::shared_ptr<Entry> ce,int line);
QString getNameID();
int checkInlineCode(QCString & doc);
private:
struct Private;
std::unique_ptr<Private> p;
Expand Down
2 changes: 1 addition & 1 deletion vhdlparser/vhdlparser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ block_statement()
LOOKAHEAD([identifier() ":"] [<POSTPONED_T>] <PROCESS_T>)
process_statement()
|
LOOKAHEAD(generate_statement())
LOOKAHEAD(3)
generate_statement()
|
case_scheme()
Expand Down

0 comments on commit 406e149

Please sign in to comment.