94 const DString &inputBuffer,
bool inLine)
103 tokenManager->
ReInit(stream,0);
119 catch( std::exception &){ }
141 p->inputString=fileBuf;
145 bool inLine = fileName.
empty();
147 if (!inLine)
msg(
"Parsing file {}...\n",fileName);
149 p->yyFileName=fileName;
170 p->oldEntry =
nullptr;
171 s->
current=std::make_shared<Entry>();
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);
183 p->yyFileName.clear();
196 for (
const char* c=text.
data() ; *c ; ++c )
198 if (*c ==
'\n')
p->yyLineNr++;
206 e->
lang = SrcLangExt::VHDL;
207 if (
p->str_doc.pending)
209 p->str_doc.pending=
false;
211 p->iDocLine=
p->str_doc.iDocLine;
215 p->commentScanner.initGroupInfo(e);
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)");
288 auto findRe = [](
const DString &str,
const reg::Ex &re,
size_t pos=0) ->
size_t
294 return match.position();
306 size_t index = findRe(doc,csRe);
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();
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);
332 for (
const auto &qcs_ : ql)
338 size_t i = qcs.
find(
'{');
339 size_t j = qcs.
find(
'}');
342 na = qcs.
mid(i+1, j-i-1);
346 qcs = replaceRe(qcs,cbriefRe,
"");
363 gBlock.
section = EntryType::makeVariable();
367 gBlock.
lang = SrcLangExt::VHDL;
368 std::shared_ptr<Entry> compound;
379 compound->copyToSubEntry(&gBlock);
383 gBlock.
type =
"misc";
386 p->strComment.clear();
393 bool needsEntry =
false;
402 p->strComment.clear();
413 if (doc.
empty())
return;
415 if (
p->oldEntry == s->
current.get())
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;
428 s->
current->briefLine =
p->yyLineNr;
438 int lineNr =
p->iDocLine;
442 while (
p->commentScanner.parseCommentBlock(
467 s->
current->section = EntryType::makeVariableDoc();
473 p->strComment.clear();
486 s->
current->section=EntryType::makeVariable();
516 s->
current=std::make_shared<Entry>();
537 for (
size_t u=0;u<ql.size();u++)
540 s->
current->startLine=startLine;
541 s->
current->bodyLine=startLine;
554 p->libUse.emplace_back(std::make_shared<Entry>(*s->
current));
565 s->
current->section=EntryType::makeFunction();
567 if (impure==
"impure" || impure==
"pure")
575 s->
current->section=EntryType::makeFunction();
596 for (
const auto &name : q1)
600 s->
current->argList.push_back(arg);
628 size_t i=q.
rfind(
'|');
642 for (
const auto &n : ql)
669 s->
current->argList.push_back(arg);
689 for (
const auto &rt :
p->libUse)
694 for (
const auto ¤t : root->
children())
698 if (current->startLine > rt->startLine)
701 current->copyToSubEntry(rt);
733 if ((
int)
p->lineParse.size()<=tok)
p->lineParse.resize(tok+1);
734 p->lineParse[tok]=
p->yyLineNr;
739 int val=
p->lineParse[tok];
798 p->iDocLine=
p->yyLineNr;
816 if (
p->lineEntry.empty())
return false;
819 while (!
p->lineEntry.empty())
821 std::shared_ptr<Entry> e=
p->lineEntry.back();
825 p->lineEntry.pop_back();
833 for (
const auto &rt : ce->children())
835 if (rt->bodyLine==line)
837 p->lineEntry.push_back(rt);
854 p->vhdlParser->getNextToken();
855 op=
p->vhdlParser->getToken(1);
856 if (op==
nullptr)
break;
858 }
while (op->
kind != kind);
859 p->vhdlParser->clearError();
869 if (s.
length()<4)
return s;
872 const char *p=s.
data()+3;
874 while (*p ==
' ' || *p ==
'\t') p++;
881 while (*p ==
' ' || *p ==
'\t') p++;
882 while (*p ==
'*') p++;
888 size_t len = result.
length();
889 if (len>=2 && result[len-1]==
'/' && result[len-2]==
'*')
892 while (len>0 && result[len-1] ==
'*') len--;
893 while (len>0 && ((c = result[len-1]) ==
' ' || c ==
'\t')) len--;
This class contains the information about the argument of a function or template.
Clang parser object for a single translation unit, which consists of a source file and the directly o...
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
DString & setNum(short n)
void resize(size_t newlen)
size_t rfind(char c, size_t pos=npos) const
DString mid(size_t index, size_t len=npos) const
DString simplifyWhiteSpace() const
return a copy of this string with leading and trailing whitespace removed and multiple internal white...
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
DString right(size_t len) const
size_t size() const
Returns the length of the string, not counting the 0-terminator.
DString & prepend(const char *s)
int contains(char c, bool cs=true) const
size_t find(char c, size_t pos=0) const
void reserve(size_t size)
Reserve space for size bytes without changing the string contents.
DString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
DString left(size_t len) const
const std::string & str() const
bool stripPrefix(const DString &prefix)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Represents an unstructured piece of information, about an entity found in the sources.
VhdlSpecifier vhdlSpec
VHDL specifiers.
const std::vector< std::shared_ptr< Entry > > & children() const
int endBodyLine
line number where the definition ends
DString fileName
file this entry was extracted from
SrcLangExt lang
programming language in which this entry was found
DString doc
documentation block (partly parsed)
DString brief
brief description (doc block)
int startLine
start line of entry in the source
EntryType section
entry type (see Sections);
int bodyLine
line number of the body in the source
void copyToSubEntry(Entry *e)
DString inbodyDocs
documentation inside the body of a function
Wrapper class for the Entry type.
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)
Helper class to process markdown formatted text.
DString process(const DString &input, int &startNewlines, bool fromParseInput=false)
size_t checkInlineCode(DString &doc)
DString popLabel(DString &q)
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.
void oneLineComment(DString qcs)
void error_skipto(int kind)
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 parsePrototype(const DString &text) override
Callback function called by the comment block scanner.
void setLineParsed(int tok)
void addVhdlType(const DString &n, int startLine, EntryType section, VhdlSpecifier spec, const DString &args, const DString &type, Protection prot)
std::unique_ptr< Private > p
~VHDLOutlineParser() override
void insertEntryAtLine(std::shared_ptr< Entry > ce, int line)
bool addLibUseClause(const DString &type)
DString getNameID()
returns a unique id for each record member.
void addCompInst(const DString &n, const DString &instName, const DString &comp, int iLine)
void pushLabel(DString &, DString &)
bool checkMultiComment(DString &qcs, int line)
void handleCommentBlock(const DString &doc, bool brief)
void setMultCommentLine()
void mapLibPackage(Entry *root)
void handleFlowComment(const DString &)
static const MemberDef * getFlowMember()
static void prepareComment(DString &)
static void deleteAllChars(DString &s, char c)
static bool isVhdlClass(const Entry *cu)
static void parseUCF(const DString &input, Entry *entity, const DString &f, bool vendor)
static DString getRecordNumber()
Class representing a regular expression.
Object representing the matching results.
This class describes a character stream that maintains line and column number positions of the charac...
Describes the input token stream.
int kind
An integer that describes the kind of this token.
void setLexParser(VhdlParser *p)
void setSharedState(SharedState *s)
void setOutlineParser(VHDLOutlineParser *p)
void setErrorHandler(ErrorHandler *eh)
void ReInit(JAVACC_CHARSTREAM *stream, int lexState=0)
void setErrorHandler(TokenManagerErrorHandler *eh)
#define Config_getBool(name)
std::vector< int > IntVector
std::vector< std::string > StringVector
std::vector< std::shared_ptr< Entry > > EntryList
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.
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...
Some helper functions for std::string.
StringVector split(const std::string &s, const std::string &delimiter)
split input string s by string delimiter delimiter.
VHDLOutlineParser * thisParser
void parseVhdlfile(const DString &fileName, const DString &inputBuffer, bool inLine)
CommentScanner commentScanner
VhdlParser::SharedState shared
std::shared_ptr< Entry > lastEntity
std::shared_ptr< Entry > lastCompound
std::shared_ptr< Entry > current_root
std::shared_ptr< Entry > tempEntry
std::shared_ptr< Entry > current
This file contains a number of basic enums and types.
DString stripLeadingAndTrailingEmptyLines(const DString &s, int &docLine)
Special version of DString::stripWhiteSpace() that only strips completely blank lines.
A bunch of utility functions.
const EntryList & getVhdlInstList()
static EntryList g_instFiles
static bool isConstraintFile(const DString &fileName, const DString &ext)
DString filter2008VhdlComment(const DString &s)