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 123 of file vhdljjparser.cpp.

123 : p(std::make_unique<Private>())
124{
125}
std::unique_ptr< Private > p

References p.

◆ ~VHDLOutlineParser()

VHDLOutlineParser::~VHDLOutlineParser ( )
override

Definition at line 127 of file vhdljjparser.cpp.

128{
129}

Member Function Documentation

◆ addCompInst()

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

Definition at line 477 of file vhdljjparser.cpp.

478{
479 VhdlParser::SharedState *s = &p->shared;
481 s->current->section=EntryType::makeVariable();
482 s->current->startLine=iLine;
483 s->current->bodyLine=iLine;
484 s->current->type=instName; // foo:instname e.g proto or work. proto(ttt)
485 s->current->exception=s->genLabels.lower(); // |arch|label1:label2...
486 s->current->name=n; // foo
487 if (s->lastCompound)
488 {
489 s->current->args=s->lastCompound->name; // architecture name
490 }
491 s->current->includeName=comp; // component/entity/configuration
492 size_t u=s->genLabels.find('|',1);
493 if (u!=DString::npos && u>0)
494 {
495 s->current->write=s->genLabels.mid(u);
496 s->current->read=s->genLabels.left(u);
497 }
498 //printf (" \n genlabel: [%s] inst: [%s] name: [%s] %d\n",n,instName,comp,iLine);
499
500 if (s->lastCompound)
501 {
502 s->current->args=s->lastCompound->name;
503 if (true) // !findInstant(current->type))
504 {
505 initEntry(s->current.get());
506 // TODO: protect with mutex
507 g_instFiles.emplace_back(std::make_shared<Entry>(*s->current));
508 // TODO: end protect with mutex
509 }
510
511 s->current=std::make_shared<Entry>();
512 }
513 else
514 {
515 newEntry();
516 }
517}
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:322
DString lower() const
Definition dstring.h:330
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:182
size_t find(char c, size_t pos=0) const
Definition dstring.h:243
DString left(size_t len) const
Definition dstring.h:310
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 709 of file vhdljjparser.cpp.

710{
711 bool showIEEESTD=Config_getBool(FORCE_LOCAL_INCLUDES);
712
713 if (showIEEESTD) // all standard packages and libraries will not be shown
714 {
715 if (type.lower().stripPrefix("ieee")) return false;
716 if (type.lower().stripPrefix("std")) return false;
717 }
718 return true;
719}
bool stripPrefix(const DString &prefix)
Definition dstring.h:294
#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 631 of file vhdljjparser.cpp.

633{
634 VhdlParser::SharedState *s = &p->shared;
635 StringVector ql=split(s2.str(),",");
636
637 for (const auto &n : ql)
638 {
639 Argument arg;
640 arg.name=n;
641 if (!s3.empty())
642 {
643 arg.type=s3;
644 }
645 arg.type+=" ";
646 arg.type+=s4;
647 if (!s6.empty())
648 {
649 arg.type+=s6;
650 }
652 {
653 arg.defval="generic";
654 }
655
657 {
658 // assert(false);
659 }
660
661 arg.defval+=s1;
662 arg.attrib="";//s6;
663
664 s->current->argList.push_back(arg);
665 s->current->args+=s2;
666 s->current->args+=",";
667 }
668}
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:152
const std::string & str() const
Definition dstring.h:649
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 519 of file vhdljjparser.cpp.

521{
522 VhdlParser::SharedState *s = &p->shared;
524
526 {
528 }
529
530 StringVector ql=split(n.str(),",");
531
532 for (size_t u=0;u<ql.size();u++)
533 {
534 s->current->name=ql[u];
535 s->current->startLine=startLine;
536 s->current->bodyLine=startLine;
537 s->current->section=section;
538 s->current->vhdlSpec=spec;
539 s->current->fileName=p->yyFileName;
540 if (s->current->args.empty())
541 {
542 s->current->args=args;
543 }
544 s->current->type=type;
545 s->current->protection=prot;
546
547 if (!s->lastCompound && section.isVariable() && (spec == VhdlSpecifier::USE || spec == VhdlSpecifier::LIBRARY) )
548 {
549 p->libUse.emplace_back(std::make_shared<Entry>(*s->current));
550 s->current->reset();
551 }
552 newEntry();
553 }
554}
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 276 of file vhdljjparser.cpp.

277{
278 static const reg::Ex csRe(R"([\\@]code)");
279 static const reg::Ex cendRe(R"(\s*[\\@]endcode)");
280 static const reg::Ex cbriefRe(R"([\\@]brief)");
281
282 // helper to simulate behavior of QString.find(const QRegExp &re,int pos)
283 auto findRe = [](const DString &str,const reg::Ex &re,size_t pos=0) -> size_t
284 {
285 if (str.length()<pos) return DString::npos;
286 reg::Match match;
287 if (reg::search(str.str(),match,re,pos)) // match found
288 {
289 return match.position();
290 }
291 else // not found
292 {
293 return DString::npos;
294 }
295 };
296 auto replaceRe = [](const DString &str,const reg::Ex &re,const DString &replacement) -> DString
297 {
298 return reg::replace(str.str(), re, replacement.str());
299 };
300
301 size_t index = findRe(doc,csRe);
302
303 if (findRe(doc,cendRe)!=DString::npos)
304 return 1;
305
306 if (index==DString::npos)
307 return index;
308
309 VhdlParser::SharedState *s = &p->shared;
310 p->strComment += doc;
311 p->code = findRe(p->inputString,csRe, p->code + 1);
312 size_t com = p->inputString.find(p->strComment);
313 size_t ref = findRe(p->inputString,cendRe, p->code + 1);
314 size_t len = p->strComment.size();
315
316 size_t ll = com + len;
317 int diff = static_cast<int>(ref) - static_cast<int>(ll) - 3;
318 DString code = p->inputString.mid(ll, diff);
319 int iLine = 0;
320 code = stripLeadingAndTrailingEmptyLines(code, iLine);
321 int val = code.contains('\n');
322 VhdlDocGen::prepareComment(p->strComment);
323 StringVector ql = split(p->strComment.str(),"\n");
324
325 DString co;
326 DString na;
327 for (const auto &qcs_ : ql)
328 {
329 DString qcs(qcs_);
330 qcs = qcs.simplifyWhiteSpace();
331 if (findRe(qcs,csRe)!=DString::npos)
332 {
333 size_t i = qcs.find('{');
334 size_t j = qcs.find('}');
335 if (i!=DString::npos && j!=DString::npos && i>0 && j > i)
336 {
337 na = qcs.mid(i+1, j-i-1);
338 }
339 continue;
340 }
341 qcs = replaceRe(qcs,cbriefRe, "");
342 co += qcs;
343 co += '\n';
344 }
345
347
348 Entry gBlock;
349 if (!na.empty())
350 gBlock.name = na;
351 else
352 gBlock.name = "misc" + VhdlDocGen::getRecordNumber();
353 gBlock.startLine = p->yyLineNr+iLine-1;
354 gBlock.bodyLine = p->yyLineNr+iLine-1 ;
355 gBlock.doc = code;
356 gBlock.inbodyDocs = code;
357 gBlock.brief = co;
358 gBlock.section = EntryType::makeVariable();
360 gBlock.fileName = p->yyFileName;
361 gBlock.endBodyLine = p->yyLineNr + val +iLine;
362 gBlock.lang = SrcLangExt::VHDL;
363 std::shared_ptr<Entry> compound;
364
365 if (s->lastEntity)
366 compound = s->lastEntity;
367 else if (s->lastCompound)
368 compound = s->lastCompound;
369 else
370 compound = nullptr;
371
372 if (compound)
373 {
374 compound->copyToSubEntry(&gBlock);
375 }
376 else
377 {
378 gBlock.type = "misc"; // global code like library ieee...
379 s->current_root->copyToSubEntry(&gBlock);
380 }
381 p->strComment.clear();
382 return 1;
383}
int contains(char c, bool cs=true) const
Definition dstring.cpp:81
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:155
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:847
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:869
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:858
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:3989

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 806 of file vhdljjparser.cpp.

807{
808 VhdlParser::SharedState *s = &p->shared;
810
811 if (p->lineEntry.empty()) return false;
812
814 while (!p->lineEntry.empty())
815 {
816 std::shared_ptr<Entry> e=p->lineEntry.back();
817 e->briefLine=line;
818 e->brief+=qcs;
819
820 p->lineEntry.pop_back();
821 }
822 return true;
823}
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 741 of file vhdljjparser.cpp.

742{
743 VhdlParser::SharedState *s = &p->shared;
745 {
746 return;
747 }
748 DString q,ret;
749
751 {
752 q=":function( ";
753 FlowChart::alignFuncProc(q,s->tempEntry->argList,true);
754 q+=")";
755 }
756 else if (s->currP==VhdlSpecifier::PROCEDURE)
757 {
758 q=":procedure (";
759 FlowChart::alignFuncProc(q,s->tempEntry->argList,false);
760 q+=")";
761 }
762 else
763 {
764 q=":process( "+s->tempEntry->args;
765 q+=")";
766 }
767
769
771
773 {
774 ret="end function ";
775 }
776 else if (s->currP==VhdlSpecifier::PROCEDURE)
777 {
778 ret="end procedure";
779 }
780 else
781 {
782 ret="end process ";
783 }
784
786 // FlowChart::printFlowList();
789}
DString()=default
DString & prepend(const char *s)
Definition dstring.h:519
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, DString::DString(), 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 556 of file vhdljjparser.cpp.

557{
558 VhdlParser::SharedState *s = &p->shared;
559 s->current->vhdlSpec=spec;
560 s->current->section=EntryType::makeFunction();
561
562 if (impure=="impure" || impure=="pure")
563 {
564 s->current->exception=impure;
565 }
566
568 {
569 s->current->vhdlSpec=VhdlSpecifier::GENERIC;
570 s->current->section=EntryType::makeFunction();
571 }
572
574 {
575 s->current->name=impure;
576 s->current->exception="";
577 }
578 else
579 {
580 s->current->name=fname;
581 }
582
583 if (spec==VhdlSpecifier::PROCESS)
584 {
585 s->current->args=fname;
586 s->current->name=impure;
588 if (!fname.empty())
589 {
590 StringVector q1=split(fname.str(),",");
591 for (const auto &name : q1)
592 {
593 Argument arg;
594 arg.name=name;
595 s->current->argList.push_back(arg);
596 }
597 }
598 }
599}
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 844 of file vhdljjparser.cpp.

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

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

◆ getLine() [1/2]

int VHDLOutlineParser::getLine ( )

Definition at line 721 of file vhdljjparser.cpp.

722{
723 return p->yyLineNr;
724}

References p.

◆ getLine() [2/2]

int VHDLOutlineParser::getLine ( int tok)

Definition at line 732 of file vhdljjparser.cpp.

733{
734 int val=p->lineParse[tok];
735 if (val<0) val=0;
736 //assert(val>=0 && val<=yyLineNr);
737 return val;
738}

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 258 of file vhdljjparser.cpp.

259{
260 return DString().setNum(idCounter++);
261}
static int idCounter

References DString::DString(), idCounter, and DString::setNum().

◆ handleCommentBlock()

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

Definition at line 385 of file vhdljjparser.cpp.

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

264{
265 lineCount(doc);
266
268 {
269 DString qcs(doc);
270 qcs=qcs.stripWhiteSpace();
271 qcs.stripPrefix("--#");
273 }
274}
void lineCount(const DString &)

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

◆ initEntry()

void VHDLOutlineParser::initEntry ( Entry * e)

Definition at line 198 of file vhdljjparser.cpp.

199{
200 e->fileName = p->yyFileName;
201 e->lang = SrcLangExt::VHDL;
202 if (p->str_doc.pending)
203 {
204 p->str_doc.pending=false;
205 p->oldEntry=nullptr; // prevents endless recursion
206 p->iDocLine=p->str_doc.iDocLine;
207 handleCommentBlock(p->str_doc.doc,p->str_doc.brief);
208 p->iDocLine=-1;
209 }
210 p->commentScanner.initGroupInfo(e);
211}
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 826 of file vhdljjparser.cpp.

827{
828 for (const auto &rt : ce->children())
829 {
830 if (rt->bodyLine==line)
831 {
832 p->lineEntry.push_back(rt);
833 }
834
835 insertEntryAtLine(rt,line);
836 }
837}

References insertEntryAtLine(), and p.

Referenced by checkMultiComment(), and insertEntryAtLine().

◆ isFuncProcProced()

bool VHDLOutlineParser::isFuncProcProced ( )

Definition at line 602 of file vhdljjparser.cpp.

603{
604 VhdlParser::SharedState *s = &p->shared;
608 )
609 {
610 return true;
611 }
612 return false;
613}

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

Referenced by addVhdlType().

◆ lineCount() [1/2]

void VHDLOutlineParser::lineCount ( )

Definition at line 182 of file vhdljjparser.cpp.

183{
184 p->yyLineNr++;
185}

References p.

◆ lineCount() [2/2]

void VHDLOutlineParser::lineCount ( const DString & text)

Definition at line 187 of file vhdljjparser.cpp.

188{
189 if (!text.empty())
190 {
191 for (const char* c=text.data() ; *c ; ++c )
192 {
193 if (*c == '\n') p->yyLineNr++;
194 }
195 }
196}
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:161

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

Referenced by handleFlowComment().

◆ mapLibPackage()

void VHDLOutlineParser::mapLibPackage ( Entry * root)

Definition at line 682 of file vhdljjparser.cpp.

683{
684 for (const auto &rt : p->libUse)
685 {
686 if (addLibUseClause(rt->name))
687 {
688 bool bFound=false;
689 for (const auto &current : root->children())
690 {
691 if (VhdlDocGen::isVhdlClass(current.get()))
692 {
693 if (current->startLine > rt->startLine)
694 {
695 bFound=true;
696 current->copyToSubEntry(rt);
697 break;
698 }
699 }
700 }//for
701 if (!bFound)
702 {
703 root->copyToSubEntry(rt);
704 }
705 } //if
706 }// for
707}//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 213 of file vhdljjparser.cpp.

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

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 796 of file vhdljjparser.cpp.

797{
798 if (size_t j=qcs.find("--!"); j!=DString::npos) qcs=qcs.mid(j+3);
799 if (!checkMultiComment(qcs,p->iDocLine))
800 {
801 handleCommentBlock(qcs,true);
802 }
803}

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 131 of file vhdljjparser.cpp.

133{
134 VhdlParser::SharedState *s = &p->shared;
135 p->thisParser=this;
136 p->inputString=fileBuf;
137
138 // fprintf(stderr,"\n ============= %s\n ==========\n",fileBuf);
139
140 bool inLine = fileName.empty();
141
142 if (!inLine) msg("Parsing file {}...\n",fileName);
143
144 p->yyFileName=fileName;
145
146 bool xilinx_ucf=isConstraintFile(p->yyFileName,".ucf");
147 bool altera_qsf=isConstraintFile(p->yyFileName,".qsf");
148
149 // support XILINX(ucf) and ALTERA (qsf) file
150
151 if (xilinx_ucf)
152 {
153 VhdlDocGen::parseUCF(fileBuf,root.get(),p->yyFileName,false);
154 return;
155 }
156 if (altera_qsf)
157 {
158 VhdlDocGen::parseUCF(fileBuf,root.get(),p->yyFileName,true);
159 return;
160 }
161 p->yyLineNr=1;
162 s->current_root=root;
163 s->lastCompound=nullptr;
164 s->lastEntity=nullptr;
165 p->oldEntry = nullptr;
166 s->current=std::make_shared<Entry>();
167 initEntry(s->current.get());
168 p->commentScanner.enterFile(fileName,p->yyLineNr);
169 p->lineParse.reserve(200);
170 p->parseVhdlfile(fileName,fileBuf,inLine);
171 p->commentScanner.leaveFile(fileName,p->yyLineNr);
172
173 s->current.reset();
174
175 if (!inLine)
176 mapLibPackage(root.get());
177
178 p->yyFileName.clear();
179 p->libUse.clear();
180}
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 471 of file vhdljjparser.cpp.

472{
473 p->varName=text;
474 p->varr=true;
475}

References p.

◆ popLabel()

DString VHDLOutlineParser::popLabel ( DString & q)

Definition at line 621 of file vhdljjparser.cpp.

622{
623 size_t i=q.rfind('|');
624 if (i==DString::npos) return DString();
625 q = q.left(i);
626 return q;
627}
size_t rfind(char c, size_t pos=npos) const
Definition dstring.h:248

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

◆ pushLabel()

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

Definition at line 615 of file vhdljjparser.cpp.

616{
617 label+="|";
618 label+=val;
619}

◆ setLineParsed()

void VHDLOutlineParser::setLineParsed ( int tok)

Definition at line 726 of file vhdljjparser.cpp.

727{
728 if ((int)p->lineParse.size()<=tok) p->lineParse.resize(tok+1);
729 p->lineParse[tok]=p->yyLineNr;
730}

References p.

◆ setMultCommentLine()

void VHDLOutlineParser::setMultCommentLine ( )

Definition at line 791 of file vhdljjparser.cpp.

792{
793 p->iDocLine=p->yyLineNr;
794}

References p.

Member Data Documentation

◆ p


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