89 const DString &inputBuffer,
bool inLine)
98 tokenManager->
ReInit(stream,0);
114 catch( std::exception &){ }
136 p->inputString=fileBuf;
140 bool inLine = fileName.
empty();
142 if (!inLine)
msg(
"Parsing file {}...\n",fileName);
144 p->yyFileName=fileName;
165 p->oldEntry =
nullptr;
166 s->
current=std::make_shared<Entry>();
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);
178 p->yyFileName.clear();
191 for (
const char* c=text.
data() ; *c ; ++c )
193 if (*c ==
'\n')
p->yyLineNr++;
201 e->
lang = SrcLangExt::VHDL;
202 if (
p->str_doc.pending)
204 p->str_doc.pending=
false;
206 p->iDocLine=
p->str_doc.iDocLine;
210 p->commentScanner.initGroupInfo(e);
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)");
283 auto findRe = [](
const DString &str,
const reg::Ex &re,
size_t pos=0) ->
size_t
289 return match.position();
301 size_t index = findRe(doc,csRe);
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();
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);
327 for (
const auto &qcs_ : ql)
333 size_t i = qcs.
find(
'{');
334 size_t j = qcs.
find(
'}');
337 na = qcs.
mid(i+1, j-i-1);
341 qcs = replaceRe(qcs,cbriefRe,
"");
358 gBlock.
section = EntryType::makeVariable();
362 gBlock.
lang = SrcLangExt::VHDL;
363 std::shared_ptr<Entry> compound;
374 compound->copyToSubEntry(&gBlock);
378 gBlock.
type =
"misc";
381 p->strComment.clear();
388 bool needsEntry =
false;
397 p->strComment.clear();
408 if (doc.
empty())
return;
410 if (
p->oldEntry == s->
current.get())
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;
423 s->
current->briefLine =
p->yyLineNr;
433 int lineNr =
p->iDocLine;
437 while (
p->commentScanner.parseCommentBlock(
462 s->
current->section = EntryType::makeVariableDoc();
468 p->strComment.clear();
481 s->
current->section=EntryType::makeVariable();
511 s->
current=std::make_shared<Entry>();
532 for (
size_t u=0;u<ql.size();u++)
535 s->
current->startLine=startLine;
536 s->
current->bodyLine=startLine;
549 p->libUse.emplace_back(std::make_shared<Entry>(*s->
current));
560 s->
current->section=EntryType::makeFunction();
562 if (impure==
"impure" || impure==
"pure")
570 s->
current->section=EntryType::makeFunction();
591 for (
const auto &name : q1)
595 s->
current->argList.push_back(arg);
623 size_t i=q.
rfind(
'|');
637 for (
const auto &n : ql)
664 s->
current->argList.push_back(arg);
684 for (
const auto &rt :
p->libUse)
689 for (
const auto ¤t : root->
children())
693 if (current->startLine > rt->startLine)
696 current->copyToSubEntry(rt);
728 if ((
int)
p->lineParse.size()<=tok)
p->lineParse.resize(tok+1);
729 p->lineParse[tok]=
p->yyLineNr;
734 int val=
p->lineParse[tok];
793 p->iDocLine=
p->yyLineNr;
811 if (
p->lineEntry.empty())
return false;
814 while (!
p->lineEntry.empty())
816 std::shared_ptr<Entry> e=
p->lineEntry.back();
820 p->lineEntry.pop_back();
828 for (
const auto &rt : ce->children())
830 if (rt->bodyLine==line)
832 p->lineEntry.push_back(rt);
849 p->vhdlParser->getNextToken();
850 op=
p->vhdlParser->getToken(1);
851 if (op==
nullptr)
break;
853 }
while (op->
kind != kind);
854 p->vhdlParser->clearError();
864 if (s.
length()<4)
return s;
867 const char *p=s.
data()+3;
869 while (*p ==
' ' || *p ==
'\t') p++;
876 while (*p ==
' ' || *p ==
'\t') p++;
877 while (*p ==
'*') p++;
883 size_t len = result.
length();
884 if (len>=2 && result[len-1]==
'/' && result[len-2]==
'*')
887 while (len>0 && result[len-1] ==
'*') len--;
888 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 lineCount(const DString &)
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...
CharStream(const JJChar *buf, int sz, int startline, int startcolumn, int buffersize)
Describes the input token stream.
int kind
An integer that describes the kind of this token.
void setLexParser(VhdlParser *p)
VhdlErrorHandler(const char *fileName)
void setSharedState(SharedState *s)
void setOutlineParser(VHDLOutlineParser *p)
VhdlParser(TokenManager *tokenManager)
void setErrorHandler(ErrorHandler *eh)
void ReInit(JAVACC_CHARSTREAM *stream, int lexState=0)
VhdlParserTokenManager(JAVACC_CHARSTREAM *stream, int lexState=0)
void setErrorHandler(TokenManagerErrorHandler *eh)
VhdlTokenManagerErrorHandler(const char *fileName)
#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...
Web server based search engine.
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)