Doxygen
Loading...
Searching...
No Matches
VHDLOutlineParser Class Referencefinal

VHDL parser using state-based lexical scanning. More...

#include <src/vhdljjparser.h>

Inheritance diagram for VHDLOutlineParser:
Collaboration diagram for VHDLOutlineParser:

Classes

struct  Private

Public Member Functions

 VHDLOutlineParser ()
 ~VHDLOutlineParser () override
void parseInput (const DString &fileName, const char *fileBuf, const std::shared_ptr< Entry > &root, ClangTUParser *clangParser) override
 Parses a single input file with the goal to build an Entry tree.
bool needsPreprocessing (const DString &) const override
 Returns true if the language identified by extension needs the C preprocessor to be run before feed the result to the input parser.
void parsePrototype (const DString &text) override
 Callback function called by the comment block scanner.
void setLineParsed (int tok)
int getLine (int tok)
int getLine ()
void lineCount (const DString &)
void lineCount ()
void addProto (const DString &s1, const DString &s2, const DString &s3, const DString &s4, const DString &s5, const DString &s6)
void createFunction (const DString &impure, VhdlSpecifier spec, const DString &fname)
void addVhdlType (const DString &n, int startLine, EntryType section, VhdlSpecifier spec, const DString &args, const DString &type, Protection prot)
void addCompInst (const DString &n, const DString &instName, const DString &comp, int iLine)
void handleCommentBlock (const DString &doc, bool brief)
void handleFlowComment (const DString &)
void initEntry (Entry *e)
void newEntry ()
bool isFuncProcProced ()
void pushLabel (DString &, DString &)
DString popLabel (DString &q)
bool addLibUseClause (const DString &type)
void mapLibPackage (Entry *root)
void createFlow ()
void error_skipto (int kind)
void oneLineComment (DString qcs)
void setMultCommentLine ()
bool checkMultiComment (DString &qcs, int line)
void insertEntryAtLine (std::shared_ptr< Entry > ce, int line)
DString getNameID ()
 returns a unique id for each record member.
size_t checkInlineCode (DString &doc)

Private Attributes

std::unique_ptr< Privatep

Detailed Description

VHDL parser using state-based lexical scanning.

This is the VHDL language parser for doxygen.

Definition at line 19 of file vhdljjparser.h.

Constructor & Destructor Documentation

◆ VHDLOutlineParser()

VHDLOutlineParser::VHDLOutlineParser ( )

Definition at line 128 of file vhdljjparser.cpp.

128 : p(std::make_unique<Private>())
129{
130}
std::unique_ptr< Private > p

References p.

◆ ~VHDLOutlineParser()

VHDLOutlineParser::~VHDLOutlineParser ( )
override

Definition at line 132 of file vhdljjparser.cpp.

133{
134}

Member Function Documentation

◆ addCompInst()

void VHDLOutlineParser::addCompInst ( const DString & n,
const DString & instName,
const DString & comp,
int iLine )

Definition at line 482 of file vhdljjparser.cpp.

483{
484 VhdlParser::SharedState *s = &p->shared;
486 s->current->section=EntryType::makeVariable();
487 s->current->startLine=iLine;
488 s->current->bodyLine=iLine;
489 s->current->type=instName; // foo:instname e.g proto or work. proto(ttt)
490 s->current->exception=s->genLabels.lower(); // |arch|label1:label2...
491 s->current->name=n; // foo
492 if (s->lastCompound)
493 {
494 s->current->args=s->lastCompound->name; // architecture name
495 }
496 s->current->includeName=comp; // component/entity/configuration
497 size_t u=s->genLabels.find('|',1);
498 if (u!=DString::npos && u>0)
499 {
500 s->current->write=s->genLabels.mid(u);
501 s->current->read=s->genLabels.left(u);
502 }
503 //printf (" \n genlabel: [%s] inst: [%s] name: [%s] %d\n",n,instName,comp,iLine);
504
505 if (s->lastCompound)
506 {
507 s->current->args=s->lastCompound->name;
508 if (true) // !findInstant(current->type))
509 {
510 initEntry(s->current.get());
511 // TODO: protect with mutex
512 g_instFiles.emplace_back(std::make_shared<Entry>(*s->current));
513 // TODO: end protect with mutex
514 }
515
516 s->current=std::make_shared<Entry>();
517 }
518 else
519 {
520 newEntry();
521 }
522}
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:318
DString lower() const
Definition dstring.h:326
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
Definition dstring.h:178
size_t find(char c, size_t pos=0) const
Definition dstring.h:239
DString left(size_t len) const
Definition dstring.h:306
void initEntry(Entry *e)
std::shared_ptr< Entry > lastCompound
std::shared_ptr< Entry > current
@ INSTANTIATION
Definition types.h:791
static EntryList g_instFiles

References vhdl::parser::VhdlParser::SharedState::current, DString::find(), g_instFiles, vhdl::parser::VhdlParser::SharedState::genLabels, initEntry(), INSTANTIATION, vhdl::parser::VhdlParser::SharedState::lastCompound, DString::left(), DString::lower(), DString::mid(), newEntry(), DString::npos, and p.

◆ addLibUseClause()

bool VHDLOutlineParser::addLibUseClause ( const DString & type)

Definition at line 714 of file vhdljjparser.cpp.

715{
716 bool showIEEESTD=Config_getBool(FORCE_LOCAL_INCLUDES);
717
718 if (showIEEESTD) // all standard packages and libraries will not be shown
719 {
720 if (type.lower().stripPrefix("ieee")) return false;
721 if (type.lower().stripPrefix("std")) return false;
722 }
723 return true;
724}
bool stripPrefix(const DString &prefix)
Definition dstring.h:290
#define Config_getBool(name)
Definition config.h:33

References Config_getBool, DString::lower(), and DString::stripPrefix().

Referenced by mapLibPackage().

◆ addProto()

void VHDLOutlineParser::addProto ( const DString & s1,
const DString & s2,
const DString & s3,
const DString & s4,
const DString & s5,
const DString & s6 )

Definition at line 636 of file vhdljjparser.cpp.

638{
639 VhdlParser::SharedState *s = &p->shared;
640 StringVector ql=split(s2.str(),",");
641
642 for (const auto &n : ql)
643 {
644 Argument arg;
645 arg.name=n;
646 if (!s3.empty())
647 {
648 arg.type=s3;
649 }
650 arg.type+=" ";
651 arg.type+=s4;
652 if (!s6.empty())
653 {
654 arg.type+=s6;
655 }
657 {
658 arg.defval="generic";
659 }
660
662 {
663 // ASSERT(false);
664 }
665
666 arg.defval+=s1;
667 arg.attrib="";//s6;
668
669 s->current->argList.push_back(arg);
670 s->current->args+=s2;
671 s->current->args+=",";
672 }
673}
DString attrib
Definition arguments.h:42
DString defval
Definition arguments.h:47
DString name
Definition arguments.h:45
DString type
Definition arguments.h:43
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
const std::string & str() const
Definition dstring.h:645
std::vector< std::string > StringVector
Definition containers.h:33
StringVector split(const std::string &s, const std::string &delimiter)
split input string s by string delimiter delimiter.
Definition stringutil.h:117

References Argument::attrib, vhdl::parser::VhdlParser::SharedState::current, Argument::defval, DString::empty(), GEN_SEC, Argument::name, p, PARAM_SEC, vhdl::parser::VhdlParser::SharedState::param_sec, vhdl::parser::VhdlParser::SharedState::parse_sec, split(), DString::str(), Argument::type, and UNKNOWN.

◆ addVhdlType()

void VHDLOutlineParser::addVhdlType ( const DString & n,
int startLine,
EntryType section,
VhdlSpecifier spec,
const DString & args,
const DString & type,
Protection prot )

Definition at line 524 of file vhdljjparser.cpp.

526{
527 VhdlParser::SharedState *s = &p->shared;
529
531 {
533 }
534
535 StringVector ql=split(n.str(),",");
536
537 for (size_t u=0;u<ql.size();u++)
538 {
539 s->current->name=ql[u];
540 s->current->startLine=startLine;
541 s->current->bodyLine=startLine;
542 s->current->section=section;
543 s->current->vhdlSpec=spec;
544 s->current->fileName=p->yyFileName;
545 if (s->current->args.empty())
546 {
547 s->current->args=args;
548 }
549 s->current->type=type;
550 s->current->protection=prot;
551
552 if (!s->lastCompound && section.isVariable() && (spec == VhdlSpecifier::USE || spec == VhdlSpecifier::LIBRARY) )
553 {
554 p->libUse.emplace_back(std::make_shared<Entry>(*s->current));
555 s->current->reset();
556 }
557 newEntry();
558 }
559}
static const MemberDef * getFlowMember()

References vhdl::parser::VhdlParser::SharedState::current, GEN_SEC, GENERIC, VhdlDocGen::getFlowMember(), isFuncProcProced(), vhdl::parser::VhdlParser::SharedState::lastCompound, LIBRARY, newEntry(), p, vhdl::parser::VhdlParser::SharedState::parse_sec, split(), DString::str(), and USE.

◆ checkInlineCode()

size_t VHDLOutlineParser::checkInlineCode ( DString & doc)

Definition at line 281 of file vhdljjparser.cpp.

282{
283 static const reg::Ex csRe(R"([\\@]code)");
284 static const reg::Ex cendRe(R"(\s*[\\@]endcode)");
285 static const reg::Ex cbriefRe(R"([\\@]brief)");
286
287 // helper to simulate behavior of QString.find(const QRegExp &re,int pos)
288 auto findRe = [](const DString &str,const reg::Ex &re,size_t pos=0) -> size_t
289 {
290 if (str.length()<pos) return DString::npos;
291 reg::Match match;
292 if (reg::search(str.str(),match,re,pos)) // match found
293 {
294 return match.position();
295 }
296 else // not found
297 {
298 return DString::npos;
299 }
300 };
301 auto replaceRe = [](const DString &str,const reg::Ex &re,const DString &replacement) -> DString
302 {
303 return reg::replace(str.str(), re, replacement.str());
304 };
305
306 size_t index = findRe(doc,csRe);
307
308 if (findRe(doc,cendRe)!=DString::npos)
309 return 1;
310
311 if (index==DString::npos)
312 return index;
313
314 VhdlParser::SharedState *s = &p->shared;
315 p->strComment += doc;
316 p->code = findRe(p->inputString,csRe, p->code + 1);
317 size_t com = p->inputString.find(p->strComment);
318 size_t ref = findRe(p->inputString,cendRe, p->code + 1);
319 size_t len = p->strComment.size();
320
321 size_t ll = com + len;
322 int diff = static_cast<int>(ref) - static_cast<int>(ll) - 3;
323 DString code = p->inputString.mid(ll, diff);
324 int iLine = 0;
325 code = stripLeadingAndTrailingEmptyLines(code, iLine);
326 int val = code.contains('\n');
327 VhdlDocGen::prepareComment(p->strComment);
328 StringVector ql = split(p->strComment.str(),"\n");
329
330 DString co;
331 DString na;
332 for (const auto &qcs_ : ql)
333 {
334 DString qcs(qcs_);
335 qcs = qcs.simplifyWhiteSpace();
336 if (findRe(qcs,csRe)!=DString::npos)
337 {
338 size_t i = qcs.find('{');
339 size_t j = qcs.find('}');
340 if (i!=DString::npos && j!=DString::npos && i>0 && j > i)
341 {
342 na = qcs.mid(i+1, j-i-1);
343 }
344 continue;
345 }
346 qcs = replaceRe(qcs,cbriefRe, "");
347 co += qcs;
348 co += '\n';
349 }
350
352
353 Entry gBlock;
354 if (!na.empty())
355 gBlock.name = na;
356 else
357 gBlock.name = "misc" + VhdlDocGen::getRecordNumber();
358 gBlock.startLine = p->yyLineNr+iLine-1;
359 gBlock.bodyLine = p->yyLineNr+iLine-1 ;
360 gBlock.doc = code;
361 gBlock.inbodyDocs = code;
362 gBlock.brief = co;
363 gBlock.section = EntryType::makeVariable();
365 gBlock.fileName = p->yyFileName;
366 gBlock.endBodyLine = p->yyLineNr + val +iLine;
367 gBlock.lang = SrcLangExt::VHDL;
368 std::shared_ptr<Entry> compound;
369
370 if (s->lastEntity)
371 compound = s->lastEntity;
372 else if (s->lastCompound)
373 compound = s->lastCompound;
374 else
375 compound = nullptr;
376
377 if (compound)
378 {
379 compound->copyToSubEntry(&gBlock);
380 }
381 else
382 {
383 gBlock.type = "misc"; // global code like library ieee...
384 s->current_root->copyToSubEntry(&gBlock);
385 }
386 p->strComment.clear();
387 return 1;
388}
int contains(char c, bool cs=true) const
Definition dstring.cpp:85
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:151
VhdlSpecifier vhdlSpec
VHDL specifiers.
Definition entry.h:182
int endBodyLine
line number where the definition ends
Definition entry.h:218
DString fileName
file this entry was extracted from
Definition entry.h:223
SrcLangExt lang
programming language in which this entry was found
Definition entry.h:228
DString doc
documentation block (partly parsed)
Definition entry.h:200
DString brief
brief description (doc block)
Definition entry.h:203
int startLine
start line of entry in the source
Definition entry.h:224
DString type
member type
Definition entry.h:172
EntryType section
entry type (see Sections);
Definition entry.h:171
int bodyLine
line number of the body in the source
Definition entry.h:216
DString name
member name
Definition entry.h:173
DString inbodyDocs
documentation inside the body of a function
Definition entry.h:206
static void prepareComment(DString &)
static DString getRecordNumber()
bool search(std::string_view str, Match &match, const Ex &re, size_t pos)
Search in a given string str starting at position pos for a match against regular expression re.
Definition regex.cpp:850
std::string replace(std::string_view str, const Ex &re, std::string_view replacement)
Searching in a given input string for parts that match regular expression re and replaces those parts...
Definition regex.cpp:872
bool match(std::string_view str, Match &match, const Ex &re)
Matches a given string str for a match against regular expression re.
Definition regex.cpp:861
std::shared_ptr< Entry > lastEntity
std::shared_ptr< Entry > current_root
@ MISCELLANEOUS
Definition types.h:797
DString stripLeadingAndTrailingEmptyLines(const DString &s, int &docLine)
Special version of DString::stripWhiteSpace() that only strips completely blank lines.
Definition util.cpp:3987

References Entry::bodyLine, Entry::brief, DString::contains(), vhdl::parser::VhdlParser::SharedState::current_root, Entry::doc, DString::empty(), Entry::endBodyLine, Entry::fileName, DString::find(), VhdlDocGen::getRecordNumber(), Entry::inbodyDocs, Entry::lang, vhdl::parser::VhdlParser::SharedState::lastCompound, vhdl::parser::VhdlParser::SharedState::lastEntity, DString::length(), DString::mid(), MISCELLANEOUS, Entry::name, DString::npos, p, VhdlDocGen::prepareComment(), reg::replace(), reg::search(), Entry::section, DString::simplifyWhiteSpace(), split(), Entry::startLine, DString::str(), stripLeadingAndTrailingEmptyLines(), Entry::type, and Entry::vhdlSpec.

Referenced by handleCommentBlock().

◆ checkMultiComment()

bool VHDLOutlineParser::checkMultiComment ( DString & qcs,
int line )

Definition at line 811 of file vhdljjparser.cpp.

812{
813 VhdlParser::SharedState *s = &p->shared;
815
816 if (p->lineEntry.empty()) return false;
817
819 while (!p->lineEntry.empty())
820 {
821 std::shared_ptr<Entry> e=p->lineEntry.back();
822 e->briefLine=line;
823 e->brief+=qcs;
824
825 p->lineEntry.pop_back();
826 }
827 return true;
828}
void insertEntryAtLine(std::shared_ptr< Entry > ce, int line)

References vhdl::parser::VhdlParser::SharedState::current_root, insertEntryAtLine(), p, and VhdlDocGen::prepareComment().

Referenced by handleCommentBlock(), and oneLineComment().

◆ createFlow()

void VHDLOutlineParser::createFlow ( )

Definition at line 746 of file vhdljjparser.cpp.

747{
748 VhdlParser::SharedState *s = &p->shared;
750 {
751 return;
752 }
753 DString q,ret;
754
756 {
757 q=":function( ";
758 FlowChart::alignFuncProc(q,s->tempEntry->argList,true);
759 q+=")";
760 }
761 else if (s->currP==VhdlSpecifier::PROCEDURE)
762 {
763 q=":procedure (";
764 FlowChart::alignFuncProc(q,s->tempEntry->argList,false);
765 q+=")";
766 }
767 else
768 {
769 q=":process( "+s->tempEntry->args;
770 q+=")";
771 }
772
774
776
778 {
779 ret="end function ";
780 }
781 else if (s->currP==VhdlSpecifier::PROCEDURE)
782 {
783 ret="end procedure";
784 }
785 else
786 {
787 ret="end process ";
788 }
789
791 // FlowChart::printFlowList();
794}
DString & prepend(const char *s)
Definition dstring.h:515
static void addFlowChart(int type, const DString &text, const DString &exp, const DString &label=DString())
static void writeFlowChart()
static void alignFuncProc(DString &q, const ArgumentList &al, bool isFunc)
std::shared_ptr< Entry > tempEntry

References FlowChart::addFlowChart(), FlowChart::alignFuncProc(), vhdl::parser::VhdlParser::SharedState::currP, FlowChart::END_NO, FUNCTION, VhdlDocGen::getFlowMember(), p, DString::prepend(), PROCEDURE, FlowChart::START_NO, vhdl::parser::VhdlParser::SharedState::tempEntry, UNKNOWN, and FlowChart::writeFlowChart().

◆ createFunction()

void VHDLOutlineParser::createFunction ( const DString & impure,
VhdlSpecifier spec,
const DString & fname )

Definition at line 561 of file vhdljjparser.cpp.

562{
563 VhdlParser::SharedState *s = &p->shared;
564 s->current->vhdlSpec=spec;
565 s->current->section=EntryType::makeFunction();
566
567 if (impure=="impure" || impure=="pure")
568 {
569 s->current->exception=impure;
570 }
571
573 {
574 s->current->vhdlSpec=VhdlSpecifier::GENERIC;
575 s->current->section=EntryType::makeFunction();
576 }
577
579 {
580 s->current->name=impure;
581 s->current->exception="";
582 }
583 else
584 {
585 s->current->name=fname;
586 }
587
588 if (spec==VhdlSpecifier::PROCESS)
589 {
590 s->current->args=fname;
591 s->current->name=impure;
593 if (!fname.empty())
594 {
595 StringVector q1=split(fname.str(),",");
596 for (const auto &name : q1)
597 {
598 Argument arg;
599 arg.name=name;
600 s->current->argList.push_back(arg);
601 }
602 }
603 }
604}
static void deleteAllChars(DString &s, char c)

References vhdl::parser::VhdlParser::SharedState::current, vhdl::parser::VhdlParser::SharedState::currP, VhdlDocGen::deleteAllChars(), DString::empty(), GEN_SEC, GENERIC, Argument::name, p, vhdl::parser::VhdlParser::SharedState::parse_sec, PROCEDURE, PROCESS, split(), and DString::str().

◆ error_skipto()

void VHDLOutlineParser::error_skipto ( int kind)

Definition at line 849 of file vhdljjparser.cpp.

850{
851 Token *op;
852 do
853 {
854 p->vhdlParser->getNextToken(); // step to next token
855 op=p->vhdlParser->getToken(1); // get first token
856 if (op==nullptr) break;
857 //fprintf(stderr,"\n %s",qPrint(t->image));
858 } while (op->kind != kind);
859 p->vhdlParser->clearError();
860 // The above loop consumes tokens all the way up to a token of
861 // "kind". We use a do-while loop rather than a while because the
862 // current token is the one immediately before the erroneous token
863 // (in our case the token immediately before what should have been
864 // "if"/"while".
865}

References vhdl::parser::Token::kind, and p.

◆ getLine() [1/2]

int VHDLOutlineParser::getLine ( )

Definition at line 726 of file vhdljjparser.cpp.

727{
728 return p->yyLineNr;
729}

References p.

◆ getLine() [2/2]

int VHDLOutlineParser::getLine ( int tok)

Definition at line 737 of file vhdljjparser.cpp.

738{
739 int val=p->lineParse[tok];
740 if (val<0) val=0;
741 //ASSERT(val>=0 && val<=yyLineNr);
742 return val;
743}

References p.

◆ getNameID()

DString VHDLOutlineParser::getNameID ( )

returns a unique id for each record member.

type first_rec is record RE: data_type; end;

type second_rec is record RE: data_type; end;

Definition at line 263 of file vhdljjparser.cpp.

264{
265 return DString().setNum(idCounter++);
266}
static int idCounter

References idCounter, and DString::setNum().

◆ handleCommentBlock()

void VHDLOutlineParser::handleCommentBlock ( const DString & doc,
bool brief )

Definition at line 390 of file vhdljjparser.cpp.

391{
392 int position = 0;
393 bool needsEntry = false;
394 VhdlParser::SharedState *s = &p->shared;
395 DString doc = doc1;
396
397 if (doc.empty())
398 return;
399
400 if (checkMultiComment(doc, p->yyLineNr))
401 {
402 p->strComment.clear();
403 return;
404 }
405
406 if (checkInlineCode(doc) != DString::npos)
407 {
408 return;
409 }
410
411 Protection protection = Protection::Public;
413 if (doc.empty()) return;
414
415 if (p->oldEntry == s->current.get())
416 {
417 p->str_doc.doc = doc;
418 p->str_doc.iDocLine = p->iDocLine;
419 p->str_doc.brief = brief;
420 p->str_doc.pending = true;
421 return;
422 }
423
424 p->oldEntry = s->current.get();
425
426 if (brief)
427 {
428 s->current->briefLine = p->yyLineNr;
429 }
430 else
431 {
432 s->current->docLine = p->yyLineNr;
433 }
434
435
436
437 Markdown markdown(p->yyFileName,p->iDocLine);
438 int lineNr = p->iDocLine;
439 GuardedSectionStack guards;
440 DString processedDoc = Config_getBool(MARKDOWN_SUPPORT) ? markdown.process(doc,lineNr) : doc;
441
442 while (p->commentScanner.parseCommentBlock(
443 p->thisParser,
444 s->current.get(),
445 processedDoc, // text
446 p->yyFileName, // file
447 lineNr, // line of block start
448 brief,
449 0,
450 false,
451 protection,
452 position,
453 needsEntry,
454 Config_getBool(MARKDOWN_SUPPORT),
455 &guards
456 ))
457 {
458 if (needsEntry)
459 newEntry();
460 }
461 if (needsEntry)
462 {
463 if (p->varr)
464 {
465 p->varr = false;
466 s->current->name = p->varName;
467 s->current->section = EntryType::makeVariableDoc();
468 p->varName = "";
469 }
470 newEntry();
471 }
472 p->iDocLine = -1;
473 p->strComment.clear();
474}
size_t checkInlineCode(DString &doc)
bool checkMultiComment(DString &qcs, int line)
std::stack< GuardedSection > GuardedSectionStack
Definition commentscan.h:48
Protection
Definition types.h:32

References checkInlineCode(), checkMultiComment(), Config_getBool, vhdl::parser::VhdlParser::SharedState::current, DString::empty(), newEntry(), DString::npos, p, VhdlDocGen::prepareComment(), and Markdown::process().

Referenced by initEntry(), and oneLineComment().

◆ handleFlowComment()

void VHDLOutlineParser::handleFlowComment ( const DString & doc)

Definition at line 268 of file vhdljjparser.cpp.

269{
270 lineCount(doc);
271
273 {
274 DString qcs(doc);
275 qcs=qcs.stripWhiteSpace();
276 qcs.stripPrefix("--#");
277 FlowChart::addFlowChart(FlowChart::COMMENT_NO,DString(),DString(),qcs);
278 }
279}

References FlowChart::addFlowChart(), FlowChart::COMMENT_NO, VhdlDocGen::getFlowMember(), lineCount(), DString::stripPrefix(), and DString::stripWhiteSpace().

◆ initEntry()

void VHDLOutlineParser::initEntry ( Entry * e)

Definition at line 203 of file vhdljjparser.cpp.

204{
205 e->fileName = p->yyFileName;
206 e->lang = SrcLangExt::VHDL;
207 if (p->str_doc.pending)
208 {
209 p->str_doc.pending=false;
210 p->oldEntry=nullptr; // prevents endless recursion
211 p->iDocLine=p->str_doc.iDocLine;
212 handleCommentBlock(p->str_doc.doc,p->str_doc.brief);
213 p->iDocLine=-1;
214 }
215 p->commentScanner.initGroupInfo(e);
216}
void handleCommentBlock(const DString &doc, bool brief)

References Entry::fileName, handleCommentBlock(), Entry::lang, and p.

Referenced by addCompInst(), newEntry(), and parseInput().

◆ insertEntryAtLine()

void VHDLOutlineParser::insertEntryAtLine ( std::shared_ptr< Entry > ce,
int line )

Definition at line 831 of file vhdljjparser.cpp.

832{
833 for (const auto &rt : ce->children())
834 {
835 if (rt->bodyLine==line)
836 {
837 p->lineEntry.push_back(rt);
838 }
839
840 insertEntryAtLine(rt,line);
841 }
842}

References insertEntryAtLine(), and p.

Referenced by checkMultiComment(), and insertEntryAtLine().

◆ isFuncProcProced()

bool VHDLOutlineParser::isFuncProcProced ( )

Definition at line 607 of file vhdljjparser.cpp.

608{
609 VhdlParser::SharedState *s = &p->shared;
613 )
614 {
615 return true;
616 }
617 return false;
618}

References vhdl::parser::VhdlParser::SharedState::currP, FUNCTION, p, PROCEDURE, and PROCESS.

Referenced by addVhdlType().

◆ lineCount() [1/2]

void VHDLOutlineParser::lineCount ( )

Definition at line 187 of file vhdljjparser.cpp.

188{
189 p->yyLineNr++;
190}

References p.

Referenced by handleFlowComment().

◆ lineCount() [2/2]

void VHDLOutlineParser::lineCount ( const DString & text)

Definition at line 192 of file vhdljjparser.cpp.

193{
194 if (!text.empty())
195 {
196 for (const char* c=text.data() ; *c ; ++c )
197 {
198 if (*c == '\n') p->yyLineNr++;
199 }
200 }
201}
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:157

References DString::data(), DString::empty(), and p.

◆ mapLibPackage()

void VHDLOutlineParser::mapLibPackage ( Entry * root)

Definition at line 687 of file vhdljjparser.cpp.

688{
689 for (const auto &rt : p->libUse)
690 {
691 if (addLibUseClause(rt->name))
692 {
693 bool bFound=false;
694 for (const auto &current : root->children())
695 {
696 if (VhdlDocGen::isVhdlClass(current.get()))
697 {
698 if (current->startLine > rt->startLine)
699 {
700 bFound=true;
701 current->copyToSubEntry(rt);
702 break;
703 }
704 }
705 }//for
706 if (!bFound)
707 {
708 root->copyToSubEntry(rt);
709 }
710 } //if
711 }// for
712}//MapLib
const std::vector< std::shared_ptr< Entry > > & children() const
Definition entry.h:138
void copyToSubEntry(Entry *e)
Definition entry.cpp:158
bool addLibUseClause(const DString &type)
static bool isVhdlClass(const Entry *cu)
Definition vhdldocgen.h:209

References addLibUseClause(), Entry::children(), Entry::copyToSubEntry(), VhdlDocGen::isVhdlClass(), and p.

Referenced by parseInput().

◆ needsPreprocessing()

bool VHDLOutlineParser::needsPreprocessing ( const DString & extension) const
inlineoverridevirtual

Returns true if the language identified by extension needs the C preprocessor to be run before feed the result to the input parser.

See also
parseInput()

Implements OutlineParserInterface.

Definition at line 30 of file vhdljjparser.h.

30{ return true; }

◆ newEntry()

void VHDLOutlineParser::newEntry ( )

Definition at line 218 of file vhdljjparser.cpp.

219{
220 VhdlParser::SharedState *s = &p->shared;
221 p->previous = s->current.get();
222 if (s->current->vhdlSpec==VhdlSpecifier::ENTITY ||
223 s->current->vhdlSpec==VhdlSpecifier::PACKAGE ||
224 s->current->vhdlSpec==VhdlSpecifier::ARCHITECTURE ||
226 {
227 s->current_root->moveToSubEntryAndRefresh(s->current);
228 }
229 else
230 {
231 if (s->lastCompound)
232 {
233 s->lastCompound->moveToSubEntryAndRefresh(s->current);
234 }
235 else
236 {
237 if (s->lastEntity)
238 {
239 s->lastEntity->moveToSubEntryAndRefresh(s->current);
240 }
241 else
242 {
243 s->current_root->moveToSubEntryAndRefresh(s->current);
244 }
245 }
246 }
247 initEntry(s->current.get());
248}

References ARCHITECTURE, vhdl::parser::VhdlParser::SharedState::current, vhdl::parser::VhdlParser::SharedState::current_root, ENTITY, initEntry(), vhdl::parser::VhdlParser::SharedState::lastCompound, vhdl::parser::VhdlParser::SharedState::lastEntity, p, PACKAGE, and PACKAGE_BODY.

Referenced by addCompInst(), addVhdlType(), and handleCommentBlock().

◆ oneLineComment()

void VHDLOutlineParser::oneLineComment ( DString qcs)

Definition at line 801 of file vhdljjparser.cpp.

802{
803 if (size_t j=qcs.find("--!"); j!=DString::npos) qcs=qcs.mid(j+3);
804 if (!checkMultiComment(qcs,p->iDocLine))
805 {
806 handleCommentBlock(qcs,true);
807 }
808}

References checkMultiComment(), DString::find(), handleCommentBlock(), DString::mid(), DString::npos, and p.

◆ parseInput()

void VHDLOutlineParser::parseInput ( const DString & fileName,
const char * fileBuf,
const std::shared_ptr< Entry > & root,
ClangTUParser * clangParser )
overridevirtual

Parses a single input file with the goal to build an Entry tree.

Parameters
[in]fileNameThe full name of the file.
[in]fileBufThe contents of the file (zero terminated).
[in,out]rootThe root of the tree of Entry *nodes representing the information extracted from the file.
[in]clangParserThe clang translation unit parser object or nullptr if disabled.

Implements OutlineParserInterface.

Definition at line 136 of file vhdljjparser.cpp.

138{
139 VhdlParser::SharedState *s = &p->shared;
140 p->thisParser=this;
141 p->inputString=fileBuf;
142
143 // fprintf(stderr,"\n ============= %s\n ==========\n",fileBuf);
144
145 bool inLine = fileName.empty();
146
147 if (!inLine) msg("Parsing file {}...\n",fileName);
148
149 p->yyFileName=fileName;
150
151 bool xilinx_ucf=isConstraintFile(p->yyFileName,".ucf");
152 bool altera_qsf=isConstraintFile(p->yyFileName,".qsf");
153
154 // support XILINX(ucf) and ALTERA (qsf) file
155
156 if (xilinx_ucf)
157 {
158 VhdlDocGen::parseUCF(fileBuf,root.get(),p->yyFileName,false);
159 return;
160 }
161 if (altera_qsf)
162 {
163 VhdlDocGen::parseUCF(fileBuf,root.get(),p->yyFileName,true);
164 return;
165 }
166 p->yyLineNr=1;
167 s->current_root=root;
168 s->lastCompound=nullptr;
169 s->lastEntity=nullptr;
170 p->oldEntry = nullptr;
171 s->current=std::make_shared<Entry>();
172 initEntry(s->current.get());
173 p->commentScanner.enterFile(fileName,p->yyLineNr);
174 p->lineParse.reserve(200);
175 p->parseVhdlfile(fileName,fileBuf,inLine);
176 p->commentScanner.leaveFile(fileName,p->yyLineNr);
177
178 s->current.reset();
179
180 if (!inLine)
181 mapLibPackage(root.get());
182
183 p->yyFileName.clear();
184 p->libUse.clear();
185}
void mapLibPackage(Entry *root)
static void parseUCF(const DString &input, Entry *entity, const DString &f, bool vendor)
#define msg(fmt,...)
Definition message.h:94
static bool isConstraintFile(const DString &fileName, const DString &ext)

References vhdl::parser::VhdlParser::SharedState::current, vhdl::parser::VhdlParser::SharedState::current_root, DString::empty(), initEntry(), isConstraintFile(), vhdl::parser::VhdlParser::SharedState::lastCompound, vhdl::parser::VhdlParser::SharedState::lastEntity, mapLibPackage(), msg, p, and VhdlDocGen::parseUCF().

◆ parsePrototype()

void VHDLOutlineParser::parsePrototype ( const DString & text)
overridevirtual

Callback function called by the comment block scanner.

It provides a string text containing the prototype of a function or variable. The parser should parse this and store the information in the Entry node that corresponds with the node for which the comment block parser was invoked.

Implements OutlineParserInterface.

Definition at line 476 of file vhdljjparser.cpp.

477{
478 p->varName=text;
479 p->varr=true;
480}

References p.

◆ popLabel()

DString VHDLOutlineParser::popLabel ( DString & q)

Definition at line 626 of file vhdljjparser.cpp.

627{
628 size_t i=q.rfind('|');
629 if (i==DString::npos) return DString();
630 q = q.left(i);
631 return q;
632}
size_t rfind(char c, size_t pos=npos) const
Definition dstring.h:244

References DString::left(), DString::npos, and DString::rfind().

◆ pushLabel()

void VHDLOutlineParser::pushLabel ( DString & label,
DString & val )

Definition at line 620 of file vhdljjparser.cpp.

621{
622 label+="|";
623 label+=val;
624}

◆ setLineParsed()

void VHDLOutlineParser::setLineParsed ( int tok)

Definition at line 731 of file vhdljjparser.cpp.

732{
733 if ((int)p->lineParse.size()<=tok) p->lineParse.resize(tok+1);
734 p->lineParse[tok]=p->yyLineNr;
735}

References p.

◆ setMultCommentLine()

void VHDLOutlineParser::setMultCommentLine ( )

Definition at line 796 of file vhdljjparser.cpp.

797{
798 p->iDocLine=p->yyLineNr;
799}

References p.

Member Data Documentation

◆ p


The documentation for this class was generated from the following files: