Doxygen
Loading...
Searching...
No Matches
vhdlcode.l File Reference
#include <stdint.h>
#include <unordered_set>
#include <string>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include "vhdlcode.h"
#include "entry.h"
#include "doxygen.h"
#include "message.h"
#include "outputlist.h"
#include "util.h"
#include "stringutil.h"
#include "membername.h"
#include "searchindex.h"
#include "vhdldocgen.h"
#include "arguments.h"
#include "config.h"
#include "classdef.h"
#include "filedef.h"
#include "tooltip.h"
#include "regex.h"
#include "debug.h"
#include "doxygen_lex.h"
#include "vhdlcode.l.h"
Include dependency graph for vhdlcode.l:

Go to the source code of this file.

Classes

struct  vhdlcodeYY_state
struct  VHDLCodeParser::Private

Macros

#define YY_TYPEDEF_YY_SCANNER_T
#define YY_NO_INPUT   1
#define YY_NO_UNISTD_H   1
#define DBG_CTX(x)
#define YY_INPUT(buf, result, max_size)

Typedefs

typedef yyguts_t * yyscan_t

Functions

static void writeFont (yyscan_t yyscanner, const char *s, const DString &text, bool specialComment=false)
static void generateMemLink (yyscan_t yyscanner, OutputCodeList &ol, DString &clName, DString &memberName)
static bool writeColoredWord (yyscan_t yyscanner, DString &word)
static void generateClassOrGlobalLink (yyscan_t yyscanner, OutputCodeList &ol, const DString &clName, bool typeOnly=false, const DString &curr_class=DString())
static void setCurrentDoc (yyscan_t yyscanner, const DString &anchor)
static bool checkVhdlString (yyscan_t yyscanner, DString &name)
static void addToSearchIndex (yyscan_t yyscanner, const DString &text)
static void startCodeLine (yyscan_t yyscanner)
static void endCodeLine (yyscan_t yyscanner)
static void nextCodeLine (yyscan_t yyscanner)
static void writeWord (yyscan_t yyscanner, const DString &word, const DString &curr_class=DString(), bool classLink=false)
static void codifyLines (yyscan_t yyscanner, const DString &text, const DString &cl=DString(), bool classlink=false, bool comment=false)
static void writeMultiLineCodeLink (yyscan_t yyscanner, OutputCodeList &ol, const Definition *d, const DString &text)
static void generateFuncLink (yyscan_t yyscanner, OutputCodeList &ol, const MemberDef *mdef)
static int countLines (yyscan_t yyscanner)
static void startFontClass (yyscan_t yyscanner, const char *s, bool specialComment=false)
static void endFontClass (yyscan_t yyscanner, bool specialComment=false)
static void appStringLower (DString &qcs, const char *text)
static void codifyMapLines (yyscan_t yyscanner, const DString &text)
static void writeFuncProto (yyscan_t yyscanner)
static void writeProcessProto (yyscan_t yyscanner)
static int yyread (yyscan_t yyscanner, char *buf, int max_size)
static const char * stateToString (int state)
static const char * getLexerFILE ()
int yylex (yyscan_t yyscanner)
static void codeFolding (yyscan_t yyscanner, const Definition *d)

Macro Definition Documentation

◆ DBG_CTX

#define DBG_CTX ( x)
Value:
do { } while(0)

Definition at line 68 of file vhdlcode.l.

◆ YY_INPUT

#define YY_INPUT ( buf,
result,
max_size )
Value:
result=yyread(yyscanner,buf,max_size);
static int yyread(yyscan_t yyscanner, char *buf, int max_size)
Definition xml.l:230

Definition at line 152 of file vhdlcode.l.

◆ YY_NO_INPUT

#define YY_NO_INPUT   1

Definition at line 63 of file vhdlcode.l.

◆ YY_NO_UNISTD_H

#define YY_NO_UNISTD_H   1

Definition at line 64 of file vhdlcode.l.

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 28 of file vhdlcode.l.

Typedef Documentation

◆ yyscan_t

typedef yyguts_t* yyscan_t

Definition at line 30 of file vhdlcode.l.

Function Documentation

◆ addToSearchIndex()

void addToSearchIndex ( yyscan_t yyscanner,
const DString & text )
static

Definition at line 1009 of file vhdlcode.l.

1010{
1011 if (Doxygen::searchIndex.enabled())
1012 {
1013 Doxygen::searchIndex.addWord(text,false);
1014 }
static SearchIndexIntf searchIndex
Definition doxygen.h:117
void addWord(const DString &word, bool hiPriority)
1015}

References SearchIndexIntf::addWord(), and Doxygen::searchIndex.

Referenced by generateClassOrGlobalLink(), generateFuncLink(), and generateMemLink().

◆ appStringLower()

void appStringLower ( DString & qcs,
const char * text )
static

Definition at line 1505 of file vhdlcode.l.

1506{
1507 qcs.clear();
1508 qcs.append(text);
1509 qcs=qcs.stripWhiteSpace();
void clear()
Definition dstring.h:218
DString & append(char c)
Definition dstring.h:493
DString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition dstring.h:341
1510}

References DString::append(), DString::clear(), and DString::stripWhiteSpace().

◆ checkVhdlString()

bool checkVhdlString ( yyscan_t yyscanner,
DString & name )
static

Definition at line 971 of file vhdlcode.l.

972{
973 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
974 if (name.empty()) return false;
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:152
975
976 size_t len=name.length();
977 if (len>2 && name.at(0)=='"' && name.at(len-1)=='"')
978 {
979 DString inside = name.mid(1,len-2);
980 static const reg::Ex regg(R"(\s+)"); // any number of whitespace
981 auto qrl=split(inside.str(),regg);
982 if (!qrl.empty() && VhdlDocGen::isNumber(qrl[0]))
983 {
984 yyextra->code->codify("\"");
985 startFontClass(yyscanner,"vhdllogic");
986 yyextra->code->codify(inside);
987 endFontClass(yyscanner);
988 yyextra->code->codify("\"");
989 }
990 else
991 {
992 startFontClass(yyscanner,"keyword");
993 yyextra->code->codify(name);
994 endFontClass(yyscanner);
995 }
996 return true;
997 }
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:88
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:322
char & at(size_t i)
Returns a reference to the character at index i.
Definition dstring.h:690
const std::string & str() const
Definition dstring.h:649
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:155
static bool isNumber(const std::string &s)
Class representing a regular expression.
Definition regex.h:39
StringVector split(const std::string &s, const std::string &delimiter)
split input string s by string delimiter delimiter.
Definition stringutil.h:117
static void startFontClass(yyscan_t yyscanner, const char *s, bool specialComment=false)
Definition vhdlcode.l:1474
static void endFontClass(yyscan_t yyscanner, bool specialComment=false)
Definition vhdlcode.l:1457
998
999 if (VhdlDocGen::isNumber(name.str()))
1000 {
1001 startFontClass(yyscanner,"vhdllogic");
1002 yyextra->code->codify(name);
1003 endFontClass(yyscanner);
1004 return true;
1005 }
1006 return false;
1007}

References DString::at(), DString::empty(), endFontClass(), VhdlDocGen::isNumber(), DString::length(), DString::mid(), split(), startFontClass(), and DString::str().

Referenced by writeWord().

◆ codeFolding()

void codeFolding ( yyscan_t yyscanner,
const Definition * d )
static

Definition at line 1017 of file vhdlcode.l.

1018{
1019 // TODO: the VHDL parse doesn't seem to record startLine and endBodyLine for many of the constructs, preventing folding from working.
1020 if (Config_getBool(HTML_CODE_FOLDING))
1021 {
1022 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1023 while (!yyextra->foldStack.empty())
1024 {
1025 const Definition *dd = yyextra->foldStack.back();
1026 if (dd->getEndBodyLine()+1==yyextra->yyLineNr) // +1 to close the section after the end of the body
1027 {
1028 yyextra->code->endFold();
1029 //printf("%d: end codeFolding for %s [%d..%d]\n",yyextra->yyLineNr,qPrint(dd->name()),dd->getStartDefLine(),dd->getEndBodyLine());
1030 yyextra->foldStack.pop_back();
1031 }
1032 else
1033 {
1034 break;
1035 }
1036 }
1037 if (d)
1038 {
1039 int startLine = d->getStartDefLine();
1040 int endLine = d->getEndBodyLine();
1041 if (endLine!=-1 && startLine!=endLine && (yyextra->foldStack.empty() || yyextra->foldStack.back()->getEndBodyLine()!=startLine))
1042 {
1043 //printf("%d: start codeFolding for %s [%d..%d]\n",yyextra->yyLineNr,qPrint(d->name()),d->getStartDefLine(),d->getEndBodyLine());
1044 yyextra->code->startFold(yyextra->yyLineNr,"","");
1045 yyextra->foldStack.push_back(d);
1046 }
1047 }
1048 }
The common base class of all entity definitions found in the sources.
Definition definition.h:77
virtual int getEndBodyLine() const =0
virtual int getStartDefLine() const =0
#define Config_getBool(name)
Definition config.h:33
1049}

References Config_getBool, Definition::getEndBodyLine(), and Definition::getStartDefLine().

Referenced by startCodeLine().

◆ codifyLines()

void codifyLines ( yyscan_t yyscanner,
const DString & text,
const DString & cl,
bool classlink,
bool comment )
static

write a code fragment 'text' that may span multiple lines, inserting line numbers for each line.

Definition at line 1243 of file vhdlcode.l.

1244{
1245 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1246 if (text.empty()) return;
1247 //printf("codifyLines(%d,\"%s\")\n",yyextra->yyLineNr,text);
1248 const char *p=text.data(),*sp=p;
1249 char c;
1250 bool done=false;
1251 while (!done)
1252 {
1253 sp=p;
1254 while ((c=*p++) && c!='\n') {}
1255 if (c=='\n')
1256 {
1257 yyextra->yyLineNr++;
1258 DString line = sp;
1259 line = line.left((int)(p-sp)-1);
1260 if (comment)
1261 {
1262 writeFont(yyscanner,"comment",line);
1263 }
1264 else
1265 {
1266 writeWord(yyscanner,line,cl,classlink);
1267 }
1268 nextCodeLine(yyscanner);
1269 }
1270 else
1271 {
1272 if (comment)
1273 {
1274 writeFont(yyscanner,"comment",sp);
1275 }
1276 else
1277 {
1278 writeWord(yyscanner,sp,cl,classlink);
1279 }
1280 done=true;
1281 }
1282 }
DString left(size_t len) const
Definition dstring.h:310
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
static void nextCodeLine(yyscan_t yyscanner)
Definition vhdlcode.l:1131
static void writeFont(yyscan_t yyscanner, const char *s, const DString &text, bool specialComment=false)
Definition vhdlcode.l:1493
static void writeWord(yyscan_t yyscanner, const DString &word, const DString &curr_class=DString(), bool classLink=false)
Definition vhdlcode.l:1151
1283}

References DString::data(), DString::empty(), DString::left(), nextCodeLine(), writeFont(), and writeWord().

Referenced by codifyMapLines(), generateClassOrGlobalLink(), generateFuncLink(), generateMemLink(), writeFuncProto(), and writeProcessProto().

◆ codifyMapLines()

void codifyMapLines ( yyscan_t yyscanner,
const DString & text )
static

Definition at line 1513 of file vhdlcode.l.

1514{
1515 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1516 if (text.empty()) return;
1517 DString temp;
1518 //bool dot=false;
1519 int wordCounter=0;
1520 DString ctemp;
1521 //printf("codifyMapLines(%d,\"%s\")\n",yyextra->yyLineNr,qPrint(text));
1522 const char *p=text.data();
1523 char c;
1524 bool done=false;
1525 while (!done)
1526 {
1527 //sp=p;
1528 while ((c=*p++) && c!='\n' && c!=':' && c != ' ' && c != '(' && c!='\0' && c!='\t')
1529 {
1530 if (c!=0x9)
1531 temp+=c;
1532 }
1533 if (c=='\0') return;
1534 if (!temp.empty()) wordCounter++;
1535
1536 if (!temp.empty())
1537 {
1538 // different kinds of component instantiations
1539 // xxx:yyy (generic/port) map(
1540 // xxx:(entity/component/configuration) yyy (generic/port) map(
1541 // xxx: entity yyy(zzz) (generic/port) map(
1542 if (wordCounter==2 || wordCounter==3)
1543 {
1544 DString q=temp.lower(); // consider (upper/lower) cases
1545 if (q=="entity" || q=="component" || q=="configuration" || q=="port" || q=="generic")
1546 {
1547 generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,temp);
1548 }
1549 else
1550 {
1551 yyextra->PortMapComp=temp;
1552 generateClassOrGlobalLink(yyscanner,*yyextra->code,temp);
1553 }
1554 }
1555 else
1556 {
1557 generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,temp);
1558 }
1559 }
1560 ctemp.fill(c,1);
1561 codifyLines(yyscanner,ctemp);
1562 ctemp.clear();
1563 temp.clear();
1564 }//while
DString fill(char c, size_t len)
Fills a string with a predefined character.
Definition dstring.h:282
DString lower() const
Definition dstring.h:330
static void generateClassOrGlobalLink(yyscan_t yyscanner, OutputCodeList &ol, const DString &clName, bool typeOnly=false, const DString &curr_class=DString())
Definition vhdlcode.l:1382
static void codifyLines(yyscan_t yyscanner, const DString &text, const DString &cl=DString(), bool classlink=false, bool comment=false)
Definition vhdlcode.l:1243
static void generateMemLink(yyscan_t yyscanner, OutputCodeList &ol, DString &clName, DString &memberName)
Definition vhdlcode.l:1345
1565}//codifyMapLines

References DString::clear(), codifyLines(), DString::data(), DString::empty(), DString::fill(), generateClassOrGlobalLink(), generateMemLink(), and DString::lower().

◆ countLines()

int countLines ( yyscan_t yyscanner)
static

counts the number of lines in the input

Definition at line 1438 of file vhdlcode.l.

1439{
1440 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1441 const char *p=yyextra->inputString;
1442 char c;
1443 int count=1;
1444 while ((c=*p))
1445 {
1446 p++ ;
1447 if (c=='\n') count++;
1448 }
1449 if (p>yyextra->inputString && *(p-1)!='\n')
1450 { // last line does not end with a \n, so we add an extra
1451 // line and explicitly terminate the line after parsing.
1452 count++;
1453 }
1454 return count;
1455}

Referenced by VHDLCodeParser::parseCode().

◆ endCodeLine()

void endCodeLine ( yyscan_t yyscanner)
static

Definition at line 1123 of file vhdlcode.l.

1124{
1125 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1126 endFontClass(yyscanner);
1127 yyextra->code->endCodeLine();
1128 yyextra->insideCodeLine=false;
1129}

References endFontClass().

Referenced by nextCodeLine(), and VHDLCodeParser::parseCode().

◆ endFontClass()

void endFontClass ( yyscan_t yyscanner,
bool specialComment = false )
static

Definition at line 1457 of file vhdlcode.l.

1458{
1459 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1460 //printf("endFontClass: specialComment=%d insideSpecialComment=%d\n",
1461 // specialComment,yyextra->insideSpecialComment);
1462 if (yyextra->currentFontClass)
1463 {
1464 yyextra->code->endFontClass();
1465 yyextra->currentFontClass=0;
1466 }
1467 if (specialComment && yyextra->insideSpecialComment)
1468 {
1469 yyextra->code->endSpecialComment();
1470 yyextra->insideSpecialComment=false;
1471 }
1472}

Referenced by checkVhdlString(), endCodeLine(), startFontClass(), writeFont(), and writeWord().

◆ generateClassOrGlobalLink()

void generateClassOrGlobalLink ( yyscan_t yyscanner,
OutputCodeList & ol,
const DString & clName,
bool typeOnly = false,
const DString & curr_class = DString() )
static

Definition at line 1382 of file vhdlcode.l.

1384{
1385 DString className=clName;
1386
1387 if (className.empty()) return;
1388
1389 ClassDef *cd=nullptr;
1390 //MemberDef *md=nullptr;
1391 //bool isLocal=false;
1392 className.stripPrefix("_");
1393 cd = getClass(className);
1394 if (!cd && !curr_class.empty())
1395 {
1396 DString cls = curr_class;
1397 DString suffix = "::";
1398 suffix+=clName;
1399 if (cls.right(suffix.length())==suffix)
1400 {
1401 cd = getClass(curr_class);
1402 }
1403 }
A abstract class representing of a compound symbol.
Definition classdef.h:100
DString right(size_t len) const
Definition dstring.h:315
bool stripPrefix(const DString &prefix)
Definition dstring.h:294
ClassDef * getClass(const DString &n)
1404
1405 while (cd)
1406 {
1407 //className.stripPrefix("_");
1408 DString temp(clName);
1409 temp.stripPrefix("_");
1410 if (cd && cd->isLinkable()) // is it a linkable class
1411 {
1412 //if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ARCHITECTURECLASS)
1413 //{
1414 // temp=VhdlDocGen::getClassName(cd);
1415 //}
1416 writeMultiLineCodeLink(yyscanner,ol,cd,temp);
1417 addToSearchIndex(yyscanner,className);
1418 return;
1419 }
1420 Definition *d = cd->getOuterScope();
1422 {
1423 cd = toClassDef(d);
1424 }
1425 else
1426 {
1427 cd = nullptr;
1428 }
1429 }
virtual bool isLinkable() const =0
virtual DefType definitionType() const =0
virtual Definition * getOuterScope() const =0
ClassDef * toClassDef(Definition *d)
static void addToSearchIndex(yyscan_t yyscanner, const DString &text)
Definition vhdlcode.l:1009
static void writeMultiLineCodeLink(yyscan_t yyscanner, OutputCodeList &ol, const Definition *d, const DString &text)
Definition vhdlcode.l:1289
1430
1431 // nothing found, just write out the word
1432 codifyLines(yyscanner,clName);
1433 addToSearchIndex(yyscanner,clName);
1434}// generateClasss or global link

References addToSearchIndex(), codifyLines(), Definition::definitionType(), DString::empty(), getClass(), Definition::getOuterScope(), Definition::isLinkable(), DString::length(), DString::right(), DString::stripPrefix(), toClassDef(), Definition::TypeClass, and writeMultiLineCodeLink().

Referenced by codifyMapLines(), and writeWord().

◆ generateFuncLink()

void generateFuncLink ( yyscan_t yyscanner,
OutputCodeList & ol,
const MemberDef * mdef )
static

writes a link to a function or procedure

Definition at line 1329 of file vhdlcode.l.

1330{
1331 //printf("generateFuncLink(FuncName=%s)\n",qPrint(mdef->name()));
1332 DString memberName=mdef->name();
virtual const DString & name() const =0
1333
1334 if (mdef->isLinkable()) // is it a linkable class
1335 {
1336 writeMultiLineCodeLink(yyscanner,ol,mdef,mdef->name());
1337 addToSearchIndex(yyscanner,memberName);
1338 return;
1339 }
1340 codifyLines(yyscanner,memberName);
1341 addToSearchIndex(yyscanner,memberName);
1342} // generateFuncLink

References addToSearchIndex(), codifyLines(), Definition::isLinkable(), Definition::name(), and writeMultiLineCodeLink().

Referenced by writeFuncProto().

◆ generateMemLink()

void generateMemLink ( yyscan_t yyscanner,
OutputCodeList & ol,
DString & clName,
DString & memberName )
static

Definition at line 1345 of file vhdlcode.l.

1346{
1347 if (memberName.empty()) return;
1348 if (clName.empty())
1349 {
1350 codifyLines(yyscanner,memberName);
1351
1352 return;
1353 }
1354
1355 DString className=clName;
1356
1357 //MemberDef *comp=nullptr;
1358 //bool isLocal=false;
1359
1360 const MemberDef *md=VhdlDocGen::findMember(className,memberName);
1361 ClassDef *po=VhdlDocGen::getClass(className);
A model of a class/file/namespace member symbol.
Definition memberdef.h:45
static const MemberDef * findMember(const DString &className, const DString &memName)
static ClassDef * getClass(const DString &name)
1362
1363 if (md==nullptr && po && (VhdlDocGen::VhdlClasses)po->protection()==VhdlDocGen::PACKBODYCLASS)
1364 {
1365 DString temp=className;//.stripPrefix("_");
1366 temp.stripPrefix("_");
1367 md=VhdlDocGen::findMember(temp,memberName);
1368 }
virtual Protection protection() const =0
Return the protection level (Public,Protected,Private) in which this compound was found.
1369
1370 if (md && md->isLinkable()) // is it a linkable class
1371 {
1372 writeMultiLineCodeLink(yyscanner,ol,md,memberName);
1373 addToSearchIndex(yyscanner,memberName);
1374 return;
1375 }
1376 // nothing found, just write out the word
1377 codifyLines(yyscanner,memberName);
1378 addToSearchIndex(yyscanner,memberName);
1379}// generateMemLink

References addToSearchIndex(), codifyLines(), DString::empty(), VhdlDocGen::findMember(), VhdlDocGen::getClass(), Definition::isLinkable(), VhdlDocGen::PACKBODYCLASS, ClassDef::protection(), DString::stripPrefix(), and writeMultiLineCodeLink().

Referenced by codifyMapLines(), and writeWord().

◆ getLexerFILE()

const char * getLexerFILE ( )
inlinestatic

Definition at line 155 of file vhdlcode.l.

155{return __FILE__;}

◆ nextCodeLine()

void nextCodeLine ( yyscan_t yyscanner)
static

Definition at line 1131 of file vhdlcode.l.

1132{
1133 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1134 if (yyextra->insideCodeLine)
1135 {
1136 endCodeLine(yyscanner); // </div>
1137 }
1138 const char *fc = yyextra->currentFontClass;
1139 if (yyextra->yyLineNr<yyextra->inputLines)
1140 {
1141 yyextra->currentFontClass = fc;
1142 startCodeLine(yyscanner); //<div>
1143 }
static void endCodeLine(yyscan_t yyscanner)
Definition vhdlcode.l:1123
static void startCodeLine(yyscan_t yyscanner)
Definition vhdlcode.l:1055
1144}

References endCodeLine(), and startCodeLine().

Referenced by codifyLines(), and writeMultiLineCodeLink().

◆ setCurrentDoc()

void setCurrentDoc ( yyscan_t yyscanner,
const DString & anchor )
static

Definition at line 955 of file vhdlcode.l.

956{
957 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
958 if (Doxygen::searchIndex.enabled())
959 {
960 if (yyextra->searchCtx)
961 {
962 Doxygen::searchIndex.setCurrentDoc(yyextra->searchCtx,yyextra->searchCtx->anchor(),false);
963 }
964 else
965 {
966 Doxygen::searchIndex.setCurrentDoc(yyextra->sourceFileDef,anchor,true);
967 }
968 }
void setCurrentDoc(const Definition *ctx, const DString &anchor, bool isSourceFile)
969}

References Doxygen::searchIndex, and SearchIndexIntf::setCurrentDoc().

Referenced by VHDLCodeParser::parseCode(), and startCodeLine().

◆ startCodeLine()

void startCodeLine ( yyscan_t yyscanner)
static

start a new line of code, inserting a line number if yyextra->sourceFileDef is true. If a definition starts at the current line, then the line number is linked to the documentation of that definition.

Definition at line 1055 of file vhdlcode.l.

1056{
1057 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1058 //if (yyextra->currentFontClass) { yyextra->code->endFontClass(); }
1059 if (yyextra->sourceFileDef && yyextra->lineNumbers)
1060 {
1061 //DString lineNumber,lineAnchor;
1062 //lineNumber.sprintf("%05d",yyextra->yyLineNr);
1063 //lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
1064 // if ((yyextra->yyLineNr % 500) == 0)
1065 // fprintf(stderr,"\n starting Line %d:",yyextra->yyLineNr);
1066 const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
1067 //printf("startCodeLine %d d=%s\n", yyextra->yyLineNr,qPrint(d ? d->name()) : "<null>");
1068 if (!yyextra->includeCodeFragment && d)
1069 {
1070 yyextra->currentDefinition = d;
1071 yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
1072 if (!yyextra->tempComp.empty() && yyextra->currentMemberDef )
1073 {
1074 //ClassDef *cf=VhdlDocGen::getClass(yyextra->tempComp);
1075 DString nn=yyextra->currentMemberDef->name();
1076 const MemberDef* mdeff=VhdlDocGen::findMember(yyextra->tempComp,nn);
1077 if (mdeff)
1078 {
1079 yyextra->currentMemberDef=mdeff;
1080 }
1081 }
1082
1083 DString lineAnchor;
1084 lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
1085 if (yyextra->currentMemberDef)
1086 {
1087 codeFolding(yyscanner,yyextra->currentMemberDef);
1088 yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
1089 yyextra->currentMemberDef->getOutputFileBase(),
1090 yyextra->currentMemberDef->anchor(),yyextra->yyLineNr,
1091 !yyextra->includeCodeFragment);
1092 setCurrentDoc(yyscanner,lineAnchor);
1093 }
1094 else if (d->isLinkableInProject())
1095 {
1096 codeFolding(yyscanner,yyextra->currentMemberDef);
1097 yyextra->code->writeLineNumber(d->getReference(),
1098 d->getOutputFileBase(),
1099 DString(),yyextra->yyLineNr,
1100 !yyextra->includeCodeFragment);
1101 setCurrentDoc(yyscanner,lineAnchor);
1102 }
1103 else
1104 {
1105 codeFolding(yyscanner,nullptr);
1106 }
1107 }
1108 else
1109 {
1110 codeFolding(yyscanner,nullptr);
1111 yyextra->code->writeLineNumber(DString(),DString(),DString(),yyextra->yyLineNr,
1112 !yyextra->includeCodeFragment);
1113 }
1114 }
1115 yyextra->code->startCodeLine(yyextra->yyLineNr);
1116 yyextra->insideCodeLine=true;
1117 if (yyextra->currentFontClass)
1118 {
1119 yyextra->code->startFontClass(yyextra->currentFontClass);
1120 }
DString & sprintf(const char *format,...)
Definition dstring.cpp:30
virtual bool isLinkableInProject() const =0
virtual DString getReference() const =0
virtual DString getOutputFileBase() const =0
static void setCurrentDoc(yyscan_t yyscanner, const DString &anchor)
Definition vhdlcode.l:955
static void codeFolding(yyscan_t yyscanner, const Definition *d)
Definition vhdlcode.l:1017
1121}

References codeFolding(), VhdlDocGen::findMember(), Definition::getOutputFileBase(), Definition::getReference(), Definition::isLinkableInProject(), setCurrentDoc(), and DString::sprintf().

Referenced by nextCodeLine(), and VHDLCodeParser::parseCode().

◆ startFontClass()

void startFontClass ( yyscan_t yyscanner,
const char * s,
bool specialComment = false )
static

Definition at line 1474 of file vhdlcode.l.

1475{
1476 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1477 if (s==nullptr) return;
1478 //printf("startFontClass(%s): specialComment=%d insideSpecialComment=%d\n",s,
1479 // specialComment,yyextra->insideSpecialComment);
1480 if (specialComment)
1481 {
1482 yyextra->code->startSpecialComment();
1483 yyextra->insideSpecialComment = true;
1484 }
1485 if (dstrcmp(yyextra->currentFontClass,s)!=0)
1486 {
1487 endFontClass(yyscanner);
1488 yyextra->code->startFontClass(s);
1489 yyextra->currentFontClass=s;
1490 }
int dstrcmp(const char *str1, const char *str2)
Definition dstring.h:54
1491}

References dstrcmp(), and endFontClass().

Referenced by checkVhdlString(), writeFont(), and writeWord().

◆ stateToString()

const char * stateToString ( int state)
static

◆ writeColoredWord()

bool writeColoredWord ( yyscan_t yyscanner,
DString & word )
static

Definition at line 1617 of file vhdlcode.l.

1618{
1619 DString qcs=word.lower();
1620 const char *ss=VhdlDocGen::findKeyWord(qcs);
1621 if (ss)
1622 {
1623 writeFont(yyscanner,ss,word);
1624 return true;
1625 }
1626 return false;
static const char * findKeyWord(const DString &word)
1627}

References VhdlDocGen::findKeyWord(), DString::lower(), and writeFont().

Referenced by writeWord().

◆ writeFont()

void writeFont ( yyscan_t yyscanner,
const char * s,
const DString & text,
bool specialComment = false )
static

Definition at line 1493 of file vhdlcode.l.

1494{
1495 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1496 if (s==nullptr || text.empty()) return;
1497 //printf("writeFont(yyscanner,%d,\"%s\")\n",yyextra->yyLineNr,text);
1498 startFontClass(yyscanner,s,specialComment);
1499 yyextra->code->codify(text);
1500 endFontClass(yyscanner,specialComment);
1501}

References DString::empty(), endFontClass(), and startFontClass().

Referenced by codifyLines(), and writeColoredWord().

◆ writeFuncProto()

void writeFuncProto ( yyscan_t yyscanner)
static

Definition at line 1571 of file vhdlcode.l.

1572{
1573 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1574 DString name,ret;
1575 VhdlDocGen::parseFuncProto(yyextra->funcProto,name,ret,false);
static void parseFuncProto(const DString &text, DString &name, DString &ret, bool doc=false)
1576
1577 if (name.empty())
1578 {
1579 codifyLines(yyscanner,yyextra->funcProto,yyextra->currClass);
1580 return;
1581 }
1582 StringVector qlist=split(yyextra->funcProto.str(),name.str());
1583 DString temp(qlist[0]);
1584 codifyLines(yyscanner,temp,yyextra->currClass);
1585 yyextra->funcProto.stripPrefix(temp);
1586 temp.clear();
1587 temp=yyextra->currClass;
1588 if (yyextra->isPackageBody)
1589 {
1590 temp.stripPrefix("_");// _{package body name}
1591 }
1592 const MemberDef *mdef=VhdlDocGen::findFunction(name,temp);
static const MemberDef * findFunction(const DString &name, const DString &package)
std::vector< std::string > StringVector
Definition containers.h:33
1593
1594 if (mdef)
1595 {
1596 generateFuncLink(yyscanner,*yyextra->code,mdef);
1597 yyextra->funcProto.stripPrefix(name);
1598 codifyLines(yyscanner,yyextra->funcProto,yyextra->currClass);
1599 }
1600 else
1601 {
1602 codifyLines(yyscanner,yyextra->funcProto,yyextra->currClass);
1603 }
static void generateFuncLink(yyscan_t yyscanner, OutputCodeList &ol, const MemberDef *mdef)
Definition vhdlcode.l:1329
1604}// writeFuncProto

References DString::clear(), codifyLines(), DString::empty(), VhdlDocGen::findFunction(), generateFuncLink(), VhdlDocGen::parseFuncProto(), split(), DString::str(), and DString::stripPrefix().

◆ writeMultiLineCodeLink()

void writeMultiLineCodeLink ( yyscan_t yyscanner,
OutputCodeList & ol,
const Definition * d,
const DString & text )
static

writes a link to a fragment text that may span multiple lines, inserting line numbers for each line. If text contains newlines, the link will be split into multiple links with the same destination, one for each line.

Definition at line 1289 of file vhdlcode.l.

1292{
1293 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1294 if (text.empty()) return;
1295 bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS);
1296 yyextra->tooltipManager.addTooltip(d);
1297 DString ref = d->getReference();
1298 DString file = d->getOutputFileBase();
1299 DString anchor = d->anchor();
1300 DString tooltip;
1301 if (!sourceTooltips) // fall back to simple "title" tooltips
1302 {
1303 tooltip = d->briefDescriptionAsTooltip();
1304 }
1305 bool done=false;
1306 const char *p=text.data();
1307 while (!done)
1308 {
1309 const char *sp=p;
1310 char c;
1311 while ((c=*p++) && c!='\n') {}
1312 if (c=='\n')
1313 {
1314 yyextra->yyLineNr++;
1315 // printf("writeCodeLink(%s,%s,%s,%s)\n",ref,file,anchor,sp);
1316 ol.writeCodeLink(d->codeSymbolType(),ref,file,anchor,DString(sp,p-sp-1),tooltip);
1317 nextCodeLine(yyscanner);
1318 }
1319 else
1320 {
1321 ol.writeCodeLink(d->codeSymbolType(),ref,file,anchor,sp,tooltip);
1322 done=true;
1323 }
1324 }
virtual DString briefDescriptionAsTooltip() const =0
virtual DString anchor() const =0
virtual CodeSymbolType codeSymbolType() const =0
void writeCodeLink(CodeSymbolType type, const DString &ref, const DString &file, const DString &anchor, const DString &name, const DString &tooltip)
Definition outputlist.h:247
1325}

References Definition::anchor(), Definition::briefDescriptionAsTooltip(), Definition::codeSymbolType(), Config_getBool, DString::data(), DString::empty(), Definition::getOutputFileBase(), Definition::getReference(), nextCodeLine(), and OutputCodeList::writeCodeLink().

Referenced by generateClassOrGlobalLink(), generateFuncLink(), and generateMemLink().

◆ writeProcessProto()

void writeProcessProto ( yyscan_t yyscanner)
static

Definition at line 1608 of file vhdlcode.l.

1609{
1610 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1611 codifyLines(yyscanner,yyextra->funcProto,yyextra->currClass);
1612 yyextra->vhdlKeyDict.clear();
1613}// writeProcessProto

References codifyLines().

◆ writeWord()

void writeWord ( yyscan_t yyscanner,
const DString & word,
const DString & curr_class,
bool classLink )
static

writes a word to the output. If curr_class is defined, the word belongs to a class and will be linked.

Definition at line 1151 of file vhdlcode.l.

1152{
1153 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1154 bool found=false;
1155 DString temp;
1156 DString tclass(curr_class);
1157 DString ttt(word);
1158 if (ttt.empty()) return;
1159 for (unsigned int j=0;j<ttt.length();j++)
1160 {
1161 char c=ttt.at(j);
1162 if (c==' '|| c==',' || c==';' || c==':' || c=='(' || c==')' || c=='\r' || c=='\t' || c=='.')
1163 {
1164 if (found)
1165 {
1166 if (!writeColoredWord(yyscanner,temp)) // is it a keyword ?
1167 {
1168 //if (VhdlDocGen::findKeyWord(temp))
1169 // writeFont(yyscanner,"vhdlkeyword",temp);
1170 //printf("writeWord: %s\n",qPrint(temp));
1171 if (!tclass.empty())
1172 {
1173 if (!classLink)
1174 {
1175 generateMemLink(yyscanner,*yyextra->code,tclass,temp);
1176 }
1177 else
1178 {
1179 generateClassOrGlobalLink(yyscanner,*yyextra->code,temp,false,curr_class);
1180 }
1181 }
1182 else
1183 {
1184 if (!checkVhdlString(yyscanner,temp))
1185 {
1186 yyextra->code->codify(temp);
1187 }
1188 }
1189 }
1190 temp.clear();
1191 found=false;
1192 }
static bool writeColoredWord(yyscan_t yyscanner, DString &word)
Definition vhdlcode.l:1617
static bool checkVhdlString(yyscan_t yyscanner, DString &name)
Definition vhdlcode.l:971
1193
1194 char cc[2];
1195 cc[0]=c;
1196 cc[1]=0;
1197 yyextra->code->codify(cc);
1198 }
1199 else
1200 {
1201 found=true;
1202 temp+=c;
1203 }
1204 } // for
1205
1206 if (!temp.empty())
1207 {
1208 if (!writeColoredWord(yyscanner,temp))
1209 {
1210 if (!tclass.empty())
1211 {
1212 if (!classLink)
1213 {
1214 generateMemLink(yyscanner,*yyextra->code,tclass,temp); // generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,left);
1215 }
1216 else
1217 {
1218 generateClassOrGlobalLink(yyscanner,*yyextra->code,temp,false,curr_class);
1219 }
1220 }
1221 else
1222 {
1223 DString qc(temp);
1224 if (VhdlDocGen::isNumber(qc.str()))
1225 {
1226 startFontClass(yyscanner,"vhdllogic");
1227 yyextra->code->codify(temp);
1228 endFontClass(yyscanner);
1229 }
1230 else
1231 {
1232 yyextra->code->codify(temp);
1233 }
1234 }
1235 }
1236 }
1237}// writeWord

References DString::at(), checkVhdlString(), DString::clear(), DString::empty(), endFontClass(), generateClassOrGlobalLink(), generateMemLink(), VhdlDocGen::isNumber(), DString::length(), startFontClass(), DString::str(), and writeColoredWord().

Referenced by codifyLines().

◆ yylex()

int yylex ( yyscan_t yyscanner)

Definition at line 220 of file vhdlcode.l.

222 {
223 BEGIN(Bases);
224 }
225
226<Map>{BRACEOPEN} {
227 yyextra->braceCount++;
228 writeFont(yyscanner,"vhdlchar",yytext);
229 BEGIN(Map);
230 }
231
232<Map>[^()\n,--]* { /* write and link a port map lines */
233 DString tt(yytext);
235 auto ql = split(tt.str(),"=>");
236 if (ql.size()>=2)
237 {
238 unsigned int index=0;
239 DString t1(ql[0]);
240 char cc=t1.at(index);
241 while (cc==' ' || cc=='\t')
242 {
243 char c2[2];
244 c2[0]=cc;
245 c2[1]=0;
246 yyextra->code->codify(c2);
247 index++;
248 if (index>=t1.size()) break;
249 cc=t1.at(index);
250 }
static void deleteAllChars(DString &s, char c)
251
252 DString s1=t1;
253 s1=s1.stripWhiteSpace();
254
255 // if (!yyextra->PortMapComp.empty())
256 generateMemLink(yyscanner,*yyextra->code,yyextra->PortMapComp,s1);
257 while (index++<t1.size())
258 {
259 cc=t1.at(index);
260 if (cc==' ' || cc=='\t')
261 {
262 char c2[2];
263 c2[0]=cc;
264 c2[1]=0;
265 yyextra->code->codify(c2);
266 }
267 }
268 codifyLines(yyscanner,"=>");
269 index=0;
270 DString s2(ql[1]);
271 t1=s2;
272 cc=t1.at(index);
273 while (cc==' ' || cc=='\t')
274 {
275 char c2[2];
276 c2[0]=cc;
277 c2[1]=0;
278 yyextra->code->codify(c2);
279 index++;
280 if (index>=t1.size()) break;
281 cc=t1.at(index);
282 }
283 s2=s2.stripWhiteSpace();
284 if (!checkVhdlString(yyscanner,s2))
285 {
286 generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,s2);
287 }
288 while (index++<t1.size())
289 {
290 if (t1.at(index)==' ')
291 {
292 yyextra->code->codify(" ");
293 }
294 }
295 }
296 else
297 {
298 codifyLines(yyscanner,yytext,yyextra->currClass);
299 }
300 BEGIN(Map);
301 }
302
303<Map>"\n"|"," {
304 codifyLines(yyscanner,yytext);
305 BEGIN(Map);
306 }
307
308<Map>{BRACECLOSE} {
309 yyextra->braceCount--;
310 writeFont(yyscanner,"vhdlchar",yytext);
311 if (yyextra->braceCount==0)
312 {
313 BEGIN(Bases);
314 }
315 }
316
317<ParseFuncProto>{NAME} {
318 DString tmp(yytext);
319 tmp=tmp.stripWhiteSpace();
320 appStringLower(yyextra->prevString,yytext);
321 yyextra->vhdlKeyDict.insert(yyextra->prevString.str());
322 if (!writeColoredWord(yyscanner,tmp))
323 {
324 generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,tmp);
325 }
326 BEGIN(Bases);
327 }
static void appStringLower(DString &qcs, const char *text)
Definition vhdlcode.l:1505
328
329<ParseType>{STRING} {
330 DString qcs(yytext);
333 if (VhdlDocGen::isNumber(qcs.str()))
334 {
335 writeFont(yyscanner,"vhdllogic",yytext);
336 }
337 else
338 {
339 writeFont(yyscanner,"keyword",yytext);
340 }
341 }
342
343<ParseType>"\n" {
344 yyextra->funcProto.append(yytext);
345 if (yyextra->isProto)
346 {
347 codifyLines(yyscanner,yytext);
348 }
349 BEGIN(ParseType);
350 }
351
352
353<ParseType>{TEXTT} {
354 yyextra->funcProto.append(yytext);
355 if (yyextra->isProto)
356 {
357 writeFont(yyscanner,"keyword",yytext);
358 }
359 BEGIN(ParseType);
360 }
361
362<ParseType>{ENDEFUNC} {
363 DString tt(yytext);
364 codifyLines(yyscanner,yytext,yyextra->currClass);
365 tt=tt.lower();
367 tt.stripWhiteSpace();
368 static const reg::Ex regg(R"(\s+)"); // any number of whitespace
369 auto ql = split(tt.str(),regg);
370 size_t index1=findIndex(ql,"if");
371 size_t index2=findIndex(ql,"case");
372 size_t index3=findIndex(ql,"loop");
373 size_t index4=findIndex(ql,"generate");
374 if (index1==std::string::npos &&
375 index2==std::string::npos &&
376 index3==std::string::npos &&
377 index4==std::string::npos)
378 {
379 BEGIN(Bases);
380 }
381 else
382 {
383 BEGIN(ParseType);
384 }
385 }
size_t findIndex(const StringVector &sv, const std::string &s)
find the index of a string in a vector of strings, returns std::string::npos if the string could not ...
Definition stringutil.h:167
386
387<ParseType>{END1} {
388 codifyLines(yyscanner,yytext,yyextra->currClass);
389 yyextra->vhdlKeyDict.clear();
390 }
391
392<ParseType>^{B}*("begin "|"begin") {
393 codifyLines(yyscanner,yytext,yyextra->currClass);
394 yyextra->isFuncProto=false;
395 }
396
397<ParseType>{SPECSIGN} {
398 yyextra->funcProto.append(yytext);
399 if (yyextra->isProto)
400 {
401 codifyLines(yyscanner,yytext,yyextra->currClass);
402 }
403 }
404
405<ParseType>["_a-zA-Z0-9]* {
406 DString val(yytext);
407 yyextra->funcProto.append(yytext);
408 appStringLower(yyextra->prevString,yytext);
409
410 if (yyextra->isFuncProto && yyextra->braceCount==0)
411 {
412 yyextra->vhdlKeyDict.insert(yyextra->prevString.str());
413 }
414
415 if (yyextra->isProto)
416 {
417 if (!writeColoredWord(yyscanner,val))
418 {
419 if (!yyextra->isFuncProto &&
420 yyextra->vhdlKeyDict.find(yyextra->prevString.str())==yyextra->vhdlKeyDict.end())
421 {
422 val=val.stripWhiteSpace();
423 if (VhdlDocGen::isNumber(val.str()))
424 {
425 startFontClass(yyscanner,"vhdllogic");
426 codifyLines(yyscanner,yytext,yyextra->currClass);
427 endFontClass(yyscanner);
428 }
429 else
430 {
431 generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,val);
432 }
433 }
434 else
435 {
436 codifyLines(yyscanner,yytext,yyextra->currClass);
437 }
438 }
439 }
440 BEGIN(ParseType);
441 }
442
443<ParseType>{BRACEOPEN} {
444 yyextra->braceCount++;
445 yyextra->funcProto+='(';
446 if (yyextra->isProto)
447 {
448 writeFont(yyscanner,"vhdlchar",yytext);
449 }
450 BEGIN(ParseType);
451 }
452
453<ParseType>{BRACECLOSE} {
454 yyextra->braceCount--;
455 yyextra->funcProto+=')';
456 if (yyextra->isProto)
457 {
458 writeFont(yyscanner,"vhdlchar",yytext);
459 }
460 if (yyextra->braceCount==0 && !yyextra->isProto)// && !yyextra->isPackageBody)
461 {
462 yyextra->isProto=true;
463 appStringLower(yyextra->prevString,yytext);
464 writeFuncProto(yyscanner);
465 BEGIN(Bases);
466 }
467 if (yyextra->isPackageBody)
468 {
469 BEGIN(ParseType);
470 }
471 }
static void writeFuncProto(yyscan_t yyscanner)
Definition vhdlcode.l:1571
472
473
474<ClassesName>{FUNCNAME} {
475 appStringLower(yyextra->prevString,yytext);
476 yyextra->currClass.clear();
477 yyextra->currClass.append(yytext);
478 yyextra->currClass=yyextra->currClass.stripWhiteSpace();
479
480 generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
481 BEGIN(Bases);
482 }
483
484
485<ParseComponent>{BRACEOPEN} {
486 yyextra->braceCount++;
487 yyextra->code->codify(yytext);
488 }
489
490
491<ParseComponent>{BRACECLOSE} {
492 yyextra->braceCount--;
493 yyextra->code->codify(yytext);
494 if (yyextra->braceCount==0 && !yyextra->isComponent)
495 {
496 yyextra->tempComp.clear();
497 BEGIN(Bases);
498 }
499 else
500 {
501 BEGIN(ParseComponent);
502 }
503 }
504
505<ParseComponent>{B}*"-" {
506 if (strlen(yytext)>=2) // found text ?
507 {
508 writeFont(yyscanner,"keyword",yytext);
509 }
510 else
511 {
512 writeFont(yyscanner,"vhdlchar",yytext);
513 }
514 }
515
516<ParseComponent>{SPECSIGN} {
517 codifyLines(yyscanner,yytext);
518 }
519
520
521
522<ParseComponent>"\n"|" " {
523 codifyLines(yyscanner,yytext);
524 }
525
526<ParseComponent>{DIGITSS} {
527 startFontClass(yyscanner,"vhdllogic");
528 codifyLines(yyscanner,yytext);
529 endFontClass(yyscanner);
530 }
531
532<ParseComponent>{PORT} {
533 codifyLines(yyscanner,yytext);
534 yyextra->braceCount=1;
535 yyextra->isComponent=false;
536 }
537
538<ParseComponent>{GENERIC} {
539 codifyLines(yyscanner,yytext);
540 yyextra->braceCount=1;
541 }
542
543<ParseComponent>[_a-zA_Z][_a-zA-Z0-9]* {
544 DString temp(yytext);
545 appStringLower(yyextra->prevString,yytext);
546 if (!checkVhdlString(yyscanner,temp))
547 {
548 if (!writeColoredWord(yyscanner,yyextra->prevString))
549 {
550 generateMemLink(yyscanner,*yyextra->code,yyextra->tempComp,temp);
551 }
552 }
553 }
554
555<ParseComponent>{STRING} {
556 DString temp(yytext);
557 if (!checkVhdlString(yyscanner,temp))
558 {
559 codifyLines(yyscanner,yytext);
560 }
561 }
562
563
564<ParseProcessProto>[^()]* {
565 yyextra->funcProto.append(yytext);
566 }
567
568
569
570<ParseProcessProto>{BRACEOPEN} {
571 yyextra->funcProto.append(yytext);
572 yyextra->braceCount++;
573 }
574
575<ParseProcessProto>{BRACECLOSE} {
576 yyextra->funcProto.append(yytext);
577 yyextra->braceCount--;
578 if (yyextra->braceCount==0)
579 {
580 writeProcessProto(yyscanner);
581 BEGIN(Bases);
582 }
583 }
static void writeProcessProto(yyscan_t yyscanner)
Definition vhdlcode.l:1608
584
585<ParsePackage>[^:;]* { //found package
586 StringVector strl=split(yytext,".");
587 if (strl.size()>2)
588 {
589 DString s1 = strl[0];
590 DString s2 = strl[1];
591 DString s3 = strl[2];
592 s1.append(".");
593 s3.prepend(".");
594 codifyLines(yyscanner,s1,yyextra->currClass);
596 if (cd)
597 {
598 generateClassOrGlobalLink(yyscanner,*yyextra->code,s2);
599 }
600 else
601 {
602 codifyLines(yyscanner,s2);
603 }
604 codifyLines(yyscanner,s3);
605 }
606 else
607 {
608 writeFont(yyscanner,"keywordflow",yytext);
609 }
610 BEGIN(Bases);
611 }
DString & prepend(const char *s)
Definition dstring.h:519
static ClassDef * getPackageName(const DString &name)
612
613<Bases>{MAPCOMPONENT1}|{MAPCOMPONENT2}|{MAPCOMPONENT3}|{MAPCOMPONENT4} { // found port or generic map
614 DString tt(yytext);
615 size_t j=tt.find('.');
616
617 if (j!=DString::npos && j>0)
618 {
619 DString left=tt.left(j+1);
620 codifyLines(yyscanner,left);
621 tt=tt.mid(j+1);
622 left=VhdlDocGen::getIndexWord(tt,0);
623 if (!left.empty())
624 {
625 j=left.find('(');
626 if (j!=DString::npos)
627 {
628 DString name=left.left(j);
629 generateClassOrGlobalLink(yyscanner,*yyextra->code,name);
630 yyextra->PortMapComp=name;
631 name=tt.mid(name.length());
632 codifyLines(yyscanner,name);
633 }
634 else
635 {
636 generateClassOrGlobalLink(yyscanner,*yyextra->code,left);
637 tt.stripPrefix(left);
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
static DString getIndexWord(const DString &, int index)
638
639 yyextra->PortMapComp=left;
640 codifyLines(yyscanner,tt);
641 }
642 }
643 }
644 else
645 {
646 if (tt.contains(':',false))
647 {
648 codifyMapLines(yyscanner,tt);
649 }
650 else
651 {
652 codifyLines(yyscanner,tt);
653 }
654 }
655 yyextra->braceCount=1;
656 BEGIN(Map);
657 }
static void codifyMapLines(yyscan_t yyscanner, const DString &text)
Definition vhdlcode.l:1513
658
659<Bases>^{B}*("component"){BN}+{FUNCNAME} { // found component
660 appStringLower(yyextra->prevString,yytext);
661 DString temp=VhdlDocGen::getIndexWord(yytext,1);
662 temp=temp.stripWhiteSpace();
664 yyextra->tempComp=temp;
665 codifyLines(yyscanner,yytext,temp,true);
666 yyextra->braceCount=0;
667 yyextra->isComponent=true;
668 BEGIN(ParseComponent);
669 }
670
671
672
673<Bases>{ARCHITECTURE} { // found architecture
674 yyextra->PortMapComp.clear();
675 DString temp = VhdlDocGen::getIndexWord(yytext,3);
676 yyextra->currArch = true;
677 temp+="::";
678 temp+=VhdlDocGen::getIndexWord(yytext,1);
679 yyextra->currClass=temp;
681 codifyLines(yyscanner,yytext,temp,true);
682 yyextra->isPackageBody=false;
683 }
684
685
686<Bases>^{B}*("package "){BN}*("body"){BN}*{FUNCNAME} { // found package body
687 DString ss(yytext);
688 DString temp=VhdlDocGen::getIndexWord(yytext,2);
689 StringVector ql=split(yytext,temp.str());
690 DString ll = ql[0];
691 codifyLines(yyscanner,ll,yyextra->currClass);
692 temp=temp.stripWhiteSpace();
693 temp.prepend("_");
694 generateClassOrGlobalLink(yyscanner,*yyextra->code,temp);
695 yyextra->currClass.clear();
696 yyextra->currClass=temp;
697 yyextra->isProto=false;
698 yyextra->isPackageBody=true;
699 }
700
701<Bases>{PROCESS} { // found process
702 yyextra->isFuncProto=true;
703 yyextra->funcProto.clear();
704 yyextra->funcProto.append(yytext);
705 yyextra->vhdlKeyDict.clear();
706 appStringLower(yyextra->prevString,yytext);
707 if (yyextra->prevString.contains('('))
708 {
709 yyextra->braceCount=1;
710 BEGIN(ParseProcessProto);
711 }
712 else
713 {
714 writeProcessProto(yyscanner);
715 }
716 }
717
718<Bases>("end"){BN}+("process") { // end of process
719 yyextra->isFuncProto=false;
720 codifyLines(yyscanner,yytext);
721 BEGIN(Bases);
722 }
723
724
725<Bases>^{B}*("begin "|"begin") {
726 yyextra->isFuncProto=false;
727 writeFont(yyscanner,"vhdlkeyword",yytext);
728 }
729
730<Bases>^{B}*("use"|"library"){BN}+ { //found package or library
731 writeFont(yyscanner,"vhdlkeyword",yytext);
732 BEGIN(ParsePackage);
733 }
734
735
736<Bases>^{B}*("use"){BN}+("configuration")[^\n]* {
737 codifyLines(yyscanner,yytext);
738 }
739
740<Bases>{FUNC} { // found function|procedure
741 yyextra->vhdlKeyDict.clear();
742 yyextra->funcProto.clear();
743 yyextra->isProto=false;
744 yyextra->funcProto.append(yytext);
745 yyextra->braceCount=1;
746 BEGIN(ParseType);
747 }
748
749<Bases>^{B}*("entity"|"package"){BN}+ {
750 appStringLower(yyextra->prevString,yytext);
751 writeFont(yyscanner,"keywordflow",yytext);
752 yyextra->isPackageBody=false;
753 BEGIN(ClassesName);
754 }
755
756<Bases>"end"{BN}+"architecture"{BN}+{FUNCNAME} {
757 codifyLines(yyscanner,yytext,yyextra->currClass,true);
758 yyextra->currArch = false;
759 }
760<Bases>"end"{BN}+{FUNCNAME} {
761 if (yyextra->currArch)
762 {
763 codifyLines(yyscanner,yytext,yyextra->currClass,true);
764 yyextra->currArch = false;
765 }
766 else
767 {
768 REJECT;
769 }
770 }
771<Bases>"end" {
772 appStringLower(yyextra->prevString,yytext);
773 DString temp(yytext);
774 temp=temp.stripWhiteSpace();
775
776 writeColoredWord(yyscanner,temp);
777 BEGIN(End);
778 }
779<End>{ID} {
780 appStringLower(yyextra->prevString,yytext);
781 DString temp(yytext);
782 temp=temp.stripWhiteSpace();
783
784 if (!writeColoredWord(yyscanner,temp))
785 {
786 generateClassOrGlobalLink(yyscanner,*yyextra->code,temp);
787 }
788 }
789<End>";" {
790 codifyLines(yyscanner,yytext);
791 BEGIN(Bases);
792 }
793<Bases>{KEYWORD} { // found keyword
794 DString qcs(yytext);
795 if (!writeColoredWord(yyscanner,qcs))
796 {
797 startFontClass(yyscanner,"vhdlchar");
798 yyextra->code->codify(yytext);
799 endFontClass(yyscanner);
800 }
801 }
802
803
804<Bases>{ID} {
805 appStringLower(yyextra->prevString,yytext);
806 DString temp(yytext);
807 temp=temp.stripWhiteSpace();
808
809 if (!writeColoredWord(yyscanner,temp))
810 {
811 startFontClass(yyscanner,"vhdlchar");
812 generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,temp);
813 endFontClass(yyscanner);
814 }
815 }
816
817<Bases,ParseComponent>{DIGITSS} {
818 startFontClass(yyscanner,"vhdllogic");
819 codifyLines(yyscanner,yytext);
820 endFontClass(yyscanner);
821 }
822
823<Bases>^{B}*("use"){BN}+("entity"|"component")[^\n]* {
824 codifyLines(yyscanner,yytext,yyextra->currClass,true);
825 }
826
827
828<Bases>{TYPEKW} {
829 codifyLines(yyscanner,yytext);
830 if (yyextra->isFuncProto)
831 {
832 BEGIN(ParseFuncProto);
833 }
834 else
835 {
836 BEGIN(Bases);
837 }
838 }
839
840<Bases>{OPERATOR} {
841 startFontClass(yyscanner,"vhdlchar");
842 yyextra->code->codify(yytext);
843 endFontClass(yyscanner);
844 }
845
846<Bases>","|"."|":"|"'"|"("|")" {
847 startFontClass(yyscanner,"vhdlchar");
848 yyextra->code->codify(yytext);
849 endFontClass(yyscanner);
850 }
851
852<Bases>{STRING} {
853 DString qcs(yytext);
856
857 if (VhdlDocGen::isNumber(qcs.str()))
858 {
859 writeFont(yyscanner,"vhdllogic",yytext);
860 }
861 else
862 {
863 writeFont(yyscanner,"keyword",yytext);
864 }
865 }
866
867<Bases>{B}*"#"[^\n]* {
868 writeFont(yyscanner,"keyword",yytext);
869 }
870
871<Bases>^{B}*{XILINX}/[^a-zA-Z0-9_] {
872 writeWord(yyscanner,yytext);
873 //codifyLines(yyscanner,yytext,yyextra->currClass,true);
874 }
875
876<Bases>^{B}*"set_"[^\n]* {
877 writeWord(yyscanner,yytext);
878 }
879
880<*>\n {
881 codifyLines(yyscanner,yytext);
882 BEGIN(Bases);
883 }
884
885<*>[\x80-\xFF]* { // keep utf8 characters together...
886 yyextra->code->codify(yytext);
887 }
888<*>. {
889 yyextra->code->codify(yytext);
890 }
891
892
893<*>\n?"--!"[^\n]*/\n{B}*"--!" { // found special multi-line comment on its own line
894 if (YY_START!=CopyComment)
895 {
896 startFontClass(yyscanner,"comment",true);
897 yyextra->lastCopyCommentContext=YY_START;
898 BEGIN(CopyComment);
899 }
900 codifyLines(yyscanner,yytext,DString(),false,true);
901 }
902<*>\n{TEXTT} { // found normal or special comment on its own line
903 DString text(yytext);
904 size_t i=text.find("--");
905 bool isSpecialComment = i!=DString::npos && yytext[i+2]=='!';
906 if (isSpecialComment && YY_START!=CopyComment)
907 {
908 startFontClass(yyscanner,"comment",true);
909 }
910 codifyLines(yyscanner,text,DString(),false,true);
911 if (isSpecialComment)
912 {
913 endFontClass(yyscanner,true);
914 }
915 if (YY_START==CopyComment)
916 {
917 BEGIN(yyextra->lastCopyCommentContext);
918 }
919 }
920<*>{TEXTT} { // found normal or special comment after something
921 DString text(yytext);
922 size_t i=text.find("--");
923 bool isSpecialComment = i!=DString::npos && yytext[i+2]=='!';
924 if (isSpecialComment)
925 {
926 startFontClass(yyscanner,"comment",true);
927 }
928 codifyLines(yyscanner,yytext,DString(),false,true);
929 if (isSpecialComment)
930 {
931 endFontClass(yyscanner,true);
932 }
933 }
934
935%%

◆ yyread()

int yyread ( yyscan_t yyscanner,
char * buf,
int max_size )
static

Definition at line 940 of file vhdlcode.l.

941{
942 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
943 int inputPosition = yyextra->inputPosition;
944 const char *s = yyextra->inputString + inputPosition;
945 int c=0;
946 while( c < max_size && *s)
947 {
948 *buf++ = *s++;
949 c++;
950 }
951 yyextra->inputPosition += c;
952 return c;
953}