14 #include <qfileinfo.h>
15 #include <qstringlist.h>
31 #include "VhdlParserIF.h"
33 using namespace vhdl::parser;
55 Entry* VhdlParser::currentCompound=0;
56 Entry* VhdlParser::tempEntry=0;
57 Entry* VhdlParser::lastEntity=0 ;
58 Entry* VhdlParser::lastCompound=0 ;
59 Entry* VhdlParser::current=0;
60 Entry* VhdlParser::current_root = 0;
61 QCString VhdlParser::compSpec;
62 QCString VhdlParser::currName;
63 QCString VhdlParser::confName;
64 QCString VhdlParser::genLabels;
65 QCString VhdlParser::lab;
66 QCString VhdlParser::forL;
68 int VhdlParser::param_sec = 0;
69 int VhdlParser::parse_sec=0;
70 int VhdlParser::currP=0;
71 int VhdlParser::levelCounter;
97 if (VhdlParser::lastEntity)
return VhdlParser::lastEntity;
98 if (VhdlParser::lastCompound)
return VhdlParser::lastCompound;
148 VhdlParser::current_root->addSubEntry(temp);
157 return fileName.right(ext.length())==ext;
170 if (strlen(fileName)==0)
192 libUse.setAutoDelete(
true);
194 VhdlParser::current_root=root;
195 VhdlParser::lastCompound=0;
196 VhdlParser::lastEntity=0;
197 VhdlParser::currentCompound=0;
198 VhdlParser::lastEntity=0;
199 VhdlParser::current=
new Entry();
200 VhdlParser::initEntry(VhdlParser::current);
203 VhdlParserIF::parseVhdlfile(fileBuf,inLine);
205 delete VhdlParser::current;
206 VhdlParser::current=0;
209 VhdlParser::mapLibPackage(root);
217 void VhdlParser::lineCount()
222 void VhdlParser::lineCount(
const char* text)
224 for (
const char* c=text ; *c ; ++c )
241 void VhdlParser::initEntry(
Entry *e)
249 void VhdlParser::newEntry()
256 current_root->addSubEntry(current);
262 lastCompound->addSubEntry(current);
268 lastEntity->addSubEntry(current);
272 current_root->addSubEntry(current);
277 current =
new Entry ;
283 int index=doc.find(
"\\code");
295 void VhdlParser::handleFlowComment(
const char*
doc)
302 qcs=qcs.stripWhiteSpace();
303 qcs.stripPrefix(
"--#");
309 void VhdlParser::handleCommentBlock(
const char* doc1,
bool brief)
316 if (doc.isEmpty())
return;
325 bool isEndCode=doc.contains(
"\\endcode");
342 bool needsEntry=FALSE;
367 int j=doc.find(
"[plant]");
390 if (needsEntry) newEntry();
413 void VhdlParser::addCompInst(
const char *n,
const char* instName,
const char* comp,
int iLine)
417 current->startLine=iLine;
418 current->bodyLine=iLine;
419 current->type=instName;
420 current->exception=genLabels.lower();
424 current->args=lastCompound->name;
426 current->includeName=comp;
427 int u=genLabels.find(
"|",1);
430 current->write=genLabels.right(genLabels.length()-u);
431 current->read=genLabels.left(u);
437 current->args=lastCompound->name;
454 void VhdlParser::addVhdlType(
const char *n,
int startLine,
int section,
455 uint64 spec,
const char* args,
const char* type,
Protection prot)
467 for (uint u=0;u<ql.count();u++)
469 current->name=ql[u].utf8();
470 current->startLine=startLine;
471 current->bodyLine=startLine;
472 current->section=section;
475 if (current->args.isEmpty())
480 current->protection=prot;
491 void VhdlParser::createFunction(
const char *imp,uint64 spec,
const char *fn)
493 QCString impure(imp);
498 if (impure==
"impure" || impure==
"pure")
500 current->exception=impure;
511 current->name=impure;
512 current->exception=
"";
522 current->name=impure;
524 if (!fname.isEmpty())
527 for (uint ii=0;ii<q1.count();ii++)
530 arg->
name=q1[ii].utf8();
531 current->argList->append(arg);
539 bool VhdlParser::isFuncProcProced()
551 void VhdlParser::pushLabel( QCString &label,QCString & val)
557 QCString VhdlParser::popLabel(QCString & q)
559 int i=q.findRev(
"|");
565 void VhdlParser::addConfigureNode(
const char* a,
const char*b,
bool,
bool isLeaf,
bool inlineConf)
585 else if (level<levelCounter)
592 else if (level>levelCounter)
604 confName=lastCompound->name;
608 co=
new VhdlConfNode(a,b,confName.lower().data(),forL.lower().data(),isLeaf);
619 void VhdlParser::addProto(
const char *s1,
const char *s2,
const char *s3,
620 const char *s4,
const char *s5,
const char *s6)
626 for (uint u=0;u<ql.count();u++)
629 arg->
name=ql[u].utf8();
640 if (parse_sec==
GEN_SEC && param_sec==0)
653 current->argList->append(arg);
671 void VhdlParser::mapLibPackage(
Entry* root)
676 for (;(rt=eli.current());++eli)
678 if (addLibUseClause(rt->
name))
683 for (eLib.toFirst();(current=eLib.current());++eLib)
703 bool VhdlParser::addLibUseClause(
const QCString &type)
709 if (type.lower().stripPrefix(
"ieee"))
return FALSE;
710 if (type.lower().stripPrefix(
"std"))
return FALSE;
715 int VhdlParser::getLine()
720 void VhdlParser::setLineParsed(
int tok)
725 int VhdlParser::getLine(
int tok)
734 void VhdlParser::createFlow()
756 q=
":process( "+tempEntry->args;
783 void VhdlParser::setMultCommentLine()
788 void VhdlParser::oneLineComment(QCString qcs)
790 bool isEndCode=qcs.contains(
"\\endcode");
792 int index = qcs.find(
"\\code");
806 if (!isEndCode && index==-1)
808 int j=qcs.find(
"--!");
809 qcs=qcs.right(qcs.length()-3-j);
812 handleCommentBlock(qcs,TRUE);
820 QList<Entry> *pTemp=
getEntryAtLine(VhdlParser::current_root,line);
822 if (pTemp->isEmpty())
return false;
825 while (!pTemp->isEmpty())
831 pTemp->removeFirst();
841 for (;(rt=eli.current());++eli)
843 if (rt->bodyLine==line)