1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
|
/******************************************************************************
*
* Copyright (C) 1997-2020 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation under the terms of the GNU General Public License is hereby
* granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
* Documents produced by Doxygen are derivative works derived from the
* input used in their production; they are not affected by this license.
*
*/
/******************************************************************************
* Parser for syntax highlighting and references for vhdl subset
* written by M. Kreis
* supports VHDL-87/93/2008
******************************************************************************/
%option never-interactive
%option case-insensitive
%option prefix="vhdlcodeYY"
%option reentrant
%option extra-type="struct vhdlcodeYY_state *"
%top{
#include <stdint.h>
}
%{
#include <unordered_set>
#include <string>
/*
* includes
*/
#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 "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"
#define YY_NO_INPUT 1
#define YY_NO_UNISTD_H 1
#define USE_STATE2STRING 0
// Toggle for some debugging info
//#define DBG_CTX(x) fprintf x
#define DBG_CTX(x) do { } while(0)
/* -----------------------------------------------------------------
* statics
*/
// ----------------- <vhdl> ----------------------------------
struct vhdlcodeYY_state
{
bool isFuncProto = false;
bool isComponent = false;
bool isPackageBody = false;
bool isProto = false;
bool startCode = false;
QCString prevString;
QCString currClass;
std::unordered_set<std::string> vhdlKeyDict;
QCString tempComp;
QCString PortMapComp;
const MemberDef * vhdlMember = 0;
QCString funcProto;
CodeOutputInterface * code = 0;
const char * inputString = 0; //!< the code fragment as text
yy_size_t inputPosition = 0; //!< read offset during parsing
int inputLines = 0; //!< number of line in the code fragment
int yyLineNr = 0; //!< current line number
bool needsTermination = false;
const Definition *searchCtx = 0;
bool exampleBlock = false;
QCString exampleName;
QCString exampleFile;
bool currArch = false;
const FileDef * sourceFileDef = 0;
const Definition * currentDefinition = 0;
const MemberDef * currentMemberDef = 0;
bool includeCodeFragment = false;
const char * currentFontClass = 0;
bool lexInit = false;
int braceCount = 0;
};
static void writeFont(yyscan_t yyscanner,const char *s,const QCString &text);
static void generateMemLink(yyscan_t yyscanner,CodeOutputInterface &ol,QCString &clName,QCString& memberName);
static bool writeColoredWord(yyscan_t yyscanner,QCString& word );
static void generateClassOrGlobalLink(yyscan_t yyscanner,CodeOutputInterface &ol,const QCString &clName, bool typeOnly=false, const QCString &curr_class=QCString());
static void setCurrentDoc(yyscan_t yyscanner,const QCString &anchor);
static bool checkVhdlString(yyscan_t yyscanner,QCString &name);
static void addToSearchIndex(yyscan_t yyscanner,const QCString &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 QCString &word,const QCString &curr_class=QCString(),bool classLink=false);
static void codifyLines(yyscan_t yyscanner,const QCString &text,const QCString &cl=QCString(),bool classlink=false,bool comment=false);
static void writeMultiLineCodeLink(yyscan_t yyscanner,CodeOutputInterface &ol,
const Definition *d,
const QCString &text);
static void generateFuncLink(yyscan_t yyscanner,CodeOutputInterface &ol,const MemberDef* mdef);
static int countLines(yyscan_t yyscanner);
static void endFontClass(yyscan_t yyscanner);
static void startFontClass(yyscan_t yyscanner,const char *s);
static void appStringLower(QCString& qcs,const char* text);
static void codifyMapLines(yyscan_t yyscanner,const QCString &text);
static void writeFuncProto(yyscan_t yyscanner);
static void writeProcessProto(yyscan_t yyscanner);
static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size);
#if USE_STATE2STRING
static const char *stateToString(int state);
#endif
//-------------------------------------------------------------------
#undef YY_INPUT
#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
%}
B [ \t]
BN [ \t\n\r]
STRING ["][^"\n]*["]
NAME [a-z_A-Z][ a-z_A-Z0-9]*
FUNCNAME [a-z_A-Z"][a-z_A-Z0-9+*"/=<>-]*
ID "$"?[a-z_A-Z][a-z_A-Z0-9]*
SPECSIGN [:;, +*&\/=<>'\t]*
DIGITSS [0-9]+|[0-9]+("#")*[0-9_a-fA-F\+\.\-]+("#")*
ALLTYPESMAP {B}*[_a-zA-Z0-9. ]+{BN}*
ALLTYPESMAP1 {BN}*[_a-zA-Z0-9.() ]+{BN}*
ARCHITECTURE ^{B}*("architecture"){BN}+{FUNCNAME}{BN}+("of"){BN}+{FUNCNAME}{BN}+("is")
PROCESS ({BN}*{FUNCNAME}{BN}*[:]+{BN}*("process"){BN}*[(]*)|[^a-zA-Z]("process "|"process("){BN}*[ (]*|[^a-zA-Z]("process"){BN}+
END1 {B}*("end "){BN}+("if"|"case"|"loop"|"generate"|"for")
END2 [^a-zA-Z_]("end"){BN}*[;]
END3 {BN}*[^a-zA-Z]("end"){BN}+{FUNCNAME}{BN}*[;]
END4 {B}*("end"){BN}+"function"{BN}+{FUNCNAME}{BN}*[;]
ENDEFUNC {END3}|{END4}|{END2}
KEYWORD ("of"|"new"|"event"|"break"|"case"|"end"|"loop"|"else"|"for"|"goto"|"if"|"return"|"generate"|"is"|"while"|"in")
TYPEKW ^{B}*("type"|"subtype"|"constant"|"attribute"|"signal"|"variable","alias","configuration")
FUNC ^{B}*("function"|"procedure"){BN}*{FUNCNAME}{BN}*("(")
ARITHOP "+"|"-"|"/"|"*"|"%"|"/="|":="
ASSIGNOP "="|"*="|"/="|"%="|"+="|"-="|"<<="|">>="|"&="|"^="|"|="
LOGICOP "=="|"!="|">"|"<"|">="|"<="|"&&"|"||"|"!"
BITOP "&"|"|"|"^"|"<<"|">>"|"~"
OPERATOR {ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}
PORT {B}*("port"){BN}*("(")
GENERIC {B}*("generic"){BN}*("(")
BRACEOPEN [(]{1}
BRACECLOSE [)]{1}
TEXTT {B}*"--"[^\n]*
MAPCOMPONENT1 ({ALLTYPESMAP}[:]{ALLTYPESMAP}{TEXTT}*{BN}+("port"|"generic"){BN}+("map"){BN}*("("){1})
MAPCOMPONENT2 {BN}*("port"|"generic"){BN}+("map"){BN}*("("){1}
MAPCOMPONENT3 ({ALLTYPESMAP}[:]{BN}*{ALLTYPESMAP1}{TEXTT}*{BN}+("port"|"generic"){BN}+("map"){BN}*("("){1})
MAPCOMPONENT4 ({ALLTYPESMAP}[:]{BN}*("entity"|"component"|"configuration"){BN}+{ALLTYPESMAP1}{TEXTT}*{BN}*("port"|"generic"){BN}*("map"){BN}*("("){1})
XILINX "INST"|"NET"|"PIN"|"BLKNM"|"BUFG"|"COLLAPSE"|"CPLD"|"COMPGRP"|"CONFIG"|"CONFIG_MODE"|"COOL_CLK"|"DATA_GATE"|"DCI_VALUE"|"DISABLE"|"DRIVE"|"DROP_SPEC"|"ENABLE"|"FAST"|"FEEDBACK"|"FILE"|"FLOAT"|"FROM-THRU-TO"|"FROM-TO"|"HBLKNM"|"HU_SET"|"INREG"|"IOB"|"IOBDELAY"|"IOSTANDARD"|"KEEP"|"KEEPER"|"LOC"|"LOCATE"|"LOCK_PINS"|"MAP"|"MAXDELAY"|"MAXPT"|"MAXSKEW"|"NODELAY"|"NOREDUCE"|"OFFSET"|"OPEN_DRAIN"|"OPT_EFFORT"|"OPTIMIZE"|"PERIOD"|"PIN"|"PRIORITY"|"PROHIBIT"|"PULLDOWN"|"PULLUP"|"PWR_MODE"|"REG"|"RLOC"|"RLOC_ORIGIN"|"RLOC_RANGE"|"SAVE NET"|"FLAG"|"SYSTEM_JITTER"|"TEMPERATURE"|"TIMEGRP"|"TIMESPEC"|"VOLTAGE"
%option noyywrap
%option nounput
%x Bases
%x ParseType
%x ParseFuncProto
%x ParseComponent
%x ParsePackage
%x ParseProcessProto
%x ClassName
%x PackageName
%x ClassVar
%x ClassesName
%x Map
%x End
%x Body
%%
. {
BEGIN(Bases);
}
<Map>{BRACEOPEN} {
yyextra->braceCount++;
writeFont(yyscanner,"vhdlchar",yytext);
BEGIN(Map);
}
<Map>[^()\n,--]* { /* write and link a port map lines */
QCString tt(yytext);
VhdlDocGen::deleteAllChars(tt,',');
auto ql = split(tt.str(),"=>");
if (ql.size()>=2)
{
unsigned int index=0;
QCString t1(ql[0]);
char cc=t1.at(index);
while (cc==' ' || cc=='\t')
{
char c2[2];
c2[0]=cc;
c2[1]=0;
yyextra->code->codify(c2);
index++;
if (index>=t1.size()) break;
cc=t1.at(index);
}
QCString s1=t1;
s1=s1.stripWhiteSpace();
// if (!yyextra->PortMapComp.isEmpty())
generateMemLink(yyscanner,*yyextra->code,yyextra->PortMapComp,s1);
while (index++<t1.size())
{
cc=t1.at(index);
if (cc==' ' || cc=='\t')
{
char c2[2];
c2[0]=cc;
c2[1]=0;
yyextra->code->codify(c2);
}
}
codifyLines(yyscanner,"=>");
index=0;
QCString s2(ql[1]);
t1=s2;
cc=t1.at(index);
while (cc==' ' || cc=='\t')
{
char c2[2];
c2[0]=cc;
c2[1]=0;
yyextra->code->codify(c2);
index++;
if (index>=t1.size()) break;
cc=t1.at(index);
}
s2=s2.stripWhiteSpace();
if (!checkVhdlString(yyscanner,s2))
{
generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,s2);
}
while (index++<t1.size())
{
if (t1.at(index)==' ')
{
yyextra->code->codify(" ");
}
}
}
else
{
codifyLines(yyscanner,yytext,yyextra->currClass);
}
BEGIN(Map);
}
<Map>"\n"|"," {
codifyLines(yyscanner,yytext);
BEGIN(Map);
}
<Map>{BRACECLOSE} {
yyextra->braceCount--;
writeFont(yyscanner,"vhdlchar",yytext);
if (yyextra->braceCount==0)
{
BEGIN(Bases);
}
}
<ParseFuncProto>{NAME} {
QCString tmp(yytext);
tmp=tmp.stripWhiteSpace();
appStringLower(yyextra->prevString,yytext);
yyextra->vhdlKeyDict.insert(yyextra->prevString.str());
if (!writeColoredWord(yyscanner,tmp))
{
generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,tmp);
}
BEGIN(Bases);
}
<ParseType>{STRING} {
QCString qcs(yytext);
VhdlDocGen::deleteAllChars(qcs,'"');
VhdlDocGen::deleteAllChars(qcs,' ');
if (VhdlDocGen::isNumber(qcs.str()))
{
writeFont(yyscanner,"vhdllogic",yytext);
}
else
{
writeFont(yyscanner,"keyword",yytext);
}
}
<ParseType>"\n" {
yyextra->funcProto.append(yytext);
if (yyextra->isProto)
{
codifyLines(yyscanner,yytext);
}
BEGIN(ParseType);
}
<ParseType>{TEXTT} {
yyextra->funcProto.append(yytext);
if (yyextra->isProto)
{
writeFont(yyscanner,"keyword",yytext);
}
BEGIN(ParseType);
}
<ParseType>{ENDEFUNC} {
QCString tt(yytext);
codifyLines(yyscanner,yytext,yyextra->currClass);
tt=tt.lower();
VhdlDocGen::deleteAllChars(tt,';');
tt.stripWhiteSpace();
static const reg::Ex regg(R"(\s+)"); // any number of whitespace
auto ql = split(tt.str(),regg);
int index=findIndex(ql,"if")+1;
index+=findIndex(ql,"case")+1;
index+=findIndex(ql,"loop")+1;
index+=findIndex(ql,"generate")+1;
if (index==0)
{
BEGIN(Bases);
}
else
{
BEGIN(ParseType);
}
}
<ParseType>{END1} {
codifyLines(yyscanner,yytext,yyextra->currClass);
yyextra->vhdlKeyDict.clear();
}
<ParseType>^{B}*("begin "|"begin") {
codifyLines(yyscanner,yytext,yyextra->currClass);
yyextra->isFuncProto=false;
}
<ParseType>{SPECSIGN} {
yyextra->funcProto.append(yytext);
if (yyextra->isProto)
{
codifyLines(yyscanner,yytext,yyextra->currClass);
}
}
<ParseType>["_a-zA-Z0-9]* {
QCString val(yytext);
yyextra->funcProto.append(yytext);
appStringLower(yyextra->prevString,yytext);
if (yyextra->isFuncProto && yyextra->braceCount==0)
{
yyextra->vhdlKeyDict.insert(yyextra->prevString.str());
}
if (yyextra->isProto)
{
if (!writeColoredWord(yyscanner,val))
{
if (!yyextra->isFuncProto &&
yyextra->vhdlKeyDict.find(yyextra->prevString.str())==yyextra->vhdlKeyDict.end())
{
val=val.stripWhiteSpace();
if (VhdlDocGen::isNumber(val.str()))
{
startFontClass(yyscanner,"vhdllogic");
codifyLines(yyscanner,yytext,yyextra->currClass);
endFontClass(yyscanner);
}
else
{
generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,val);
}
}
else
{
codifyLines(yyscanner,yytext,yyextra->currClass);
}
}
}
BEGIN(ParseType);
}
<ParseType>{BRACEOPEN} {
yyextra->braceCount++;
yyextra->funcProto+='(';
if (yyextra->isProto)
{
writeFont(yyscanner,"vhdlchar",yytext);
}
BEGIN(ParseType);
}
<ParseType>{BRACECLOSE} {
yyextra->braceCount--;
yyextra->funcProto+=')';
if (yyextra->isProto)
{
writeFont(yyscanner,"vhdlchar",yytext);
}
if (yyextra->braceCount==0 && !yyextra->isProto)// && !yyextra->isPackageBody)
{
yyextra->isProto=true;
appStringLower(yyextra->prevString,yytext);
writeFuncProto(yyscanner);
BEGIN(Bases);
}
if (yyextra->isPackageBody)
{
BEGIN(ParseType);
}
}
<ClassesName>{FUNCNAME} {
appStringLower(yyextra->prevString,yytext);
yyextra->currClass.resize(0);
yyextra->currClass.append(yytext);
yyextra->currClass=yyextra->currClass.stripWhiteSpace();
generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
BEGIN(Bases);
}
<ParseComponent>{BRACEOPEN} {
yyextra->braceCount++;
yyextra->code->codify(yytext);
}
<ParseComponent>{BRACECLOSE} {
yyextra->braceCount--;
yyextra->code->codify(yytext);
if (yyextra->braceCount==0 && !yyextra->isComponent)
{
yyextra->tempComp.resize(0);
BEGIN(Bases);
}
else
{
BEGIN(ParseComponent);
}
}
<ParseComponent>{B}*"-" {
if (strlen(yytext)>=2) // found text ?
{
writeFont(yyscanner,"keyword",yytext);
}
else
{
writeFont(yyscanner,"vhdlchar",yytext);
}
}
<ParseComponent>{SPECSIGN} {
codifyLines(yyscanner,yytext);
}
<ParseComponent>"\n"|" " {
codifyLines(yyscanner,yytext);
}
<ParseComponent>{DIGITSS} {
startFontClass(yyscanner,"vhdllogic");
codifyLines(yyscanner,yytext);
endFontClass(yyscanner);
}
<ParseComponent>{PORT} {
codifyLines(yyscanner,yytext);
yyextra->braceCount=1;
yyextra->isComponent=false;
}
<ParseComponent>{GENERIC} {
codifyLines(yyscanner,yytext);
yyextra->braceCount=1;
}
<ParseComponent>[_a-zA_Z][_a-zA-Z0-9]* {
QCString temp(yytext);
appStringLower(yyextra->prevString,yytext);
if (!checkVhdlString(yyscanner,temp))
{
if (!writeColoredWord(yyscanner,yyextra->prevString))
{
generateMemLink(yyscanner,*yyextra->code,yyextra->tempComp,temp);
}
}
}
<ParseComponent>{STRING} {
QCString temp(yytext);
if (!checkVhdlString(yyscanner,temp))
{
codifyLines(yyscanner,yytext);
}
}
<ParseProcessProto>[^()]* {
yyextra->funcProto.append(yytext);
}
<ParseProcessProto>{BRACEOPEN} {
yyextra->funcProto.append(yytext);
yyextra->braceCount++;
}
<ParseProcessProto>{BRACECLOSE} {
yyextra->funcProto.append(yytext);
yyextra->braceCount--;
if (yyextra->braceCount==0)
{
writeProcessProto(yyscanner);
BEGIN(Bases);
}
}
<ParsePackage>[^:;]* { //found package
StringVector strl=split(yytext,".");
if (strl.size()>2)
{
std::string s1=strl[0];
std::string s2=strl[1];
std::string s3=strl[2];
s1.append(".");
s3.insert(0,".");
codifyLines(yyscanner,s1.c_str(),yyextra->currClass);
ClassDef *cd=VhdlDocGen::getPackageName(s2.c_str());
if (cd)
{
generateClassOrGlobalLink(yyscanner,*yyextra->code,s2.c_str());
}
else
{
codifyLines(yyscanner,s2.c_str());
}
codifyLines(yyscanner,s3.c_str());
}
else
{
writeFont(yyscanner,"keywordflow",yytext);
}
BEGIN(Bases);
}
<Bases>{MAPCOMPONENT1}|{MAPCOMPONENT2}|{MAPCOMPONENT3}|{MAPCOMPONENT4} { // found port or generic map
QCString tt(yytext);
int j=tt.find('.');
if (j>0)
{
QCString left=tt.left(j+1);
codifyLines(yyscanner,left);
tt=tt.right(tt.length()-j-1);
left=VhdlDocGen::getIndexWord(tt,0);
if (!left.isEmpty())
{
if (left.contains('('))
{
j=left.find('(',false);
QCString name=left.left(j);
generateClassOrGlobalLink(yyscanner,*yyextra->code,name);
yyextra->PortMapComp=name;
name=tt.right(tt.length()-name.length());
codifyLines(yyscanner,name);
}
else
{
generateClassOrGlobalLink(yyscanner,*yyextra->code,left);
tt.stripPrefix(left); //=tt.right(tt.length()-left.length()-1);
yyextra->PortMapComp=left;
codifyLines(yyscanner,tt);
}
}
}
else
{
if (tt.contains(':',false))
{
codifyMapLines(yyscanner,tt);
}
else
{
codifyLines(yyscanner,tt);
}
}
yyextra->braceCount=1;
BEGIN(Map);
}
<Bases>^{B}*("component"){BN}+{FUNCNAME} { // found component
appStringLower(yyextra->prevString,yytext);
QCString temp=VhdlDocGen::getIndexWord(yytext,1);
temp=temp.stripWhiteSpace();
VhdlDocGen::deleteAllChars(temp,'\n');
yyextra->tempComp=temp;
codifyLines(yyscanner,yytext,temp,true);
yyextra->braceCount=0;
yyextra->isComponent=true;
BEGIN(ParseComponent);
}
<Bases>{ARCHITECTURE} { // found architecture
yyextra->PortMapComp.resize(0);
QCString temp = VhdlDocGen::getIndexWord(yytext,3);
yyextra->currArch = true;
temp+="::";
temp+=VhdlDocGen::getIndexWord(yytext,1);
yyextra->currClass=temp;
VhdlDocGen::deleteAllChars(temp,'\n');
codifyLines(yyscanner,yytext,temp,true);
yyextra->isPackageBody=false;
}
<Bases>^{B}*("package "){BN}*("body"){BN}*{FUNCNAME} { // found package body
QCString ss(yytext);
QCString temp=VhdlDocGen::getIndexWord(yytext,2);
StringVector ql=split(yytext,temp.str());
std::string ll=ql[0];
codifyLines(yyscanner,ll.c_str(),yyextra->currClass);
temp=temp.stripWhiteSpace();
temp.prepend("_");
generateClassOrGlobalLink(yyscanner,*yyextra->code,temp);
yyextra->currClass.resize(0);
yyextra->currClass=temp;
yyextra->isProto=false;
yyextra->isPackageBody=true;
}
<Bases>{PROCESS} { // found process
yyextra->isFuncProto=true;
yyextra->funcProto.resize(0);
yyextra->funcProto.append(yytext);
yyextra->vhdlKeyDict.clear();
appStringLower(yyextra->prevString,yytext);
if (yyextra->prevString.contains('('))
{
yyextra->braceCount=1;
BEGIN(ParseProcessProto);
}
else
{
writeProcessProto(yyscanner);
}
}
<Bases>("end"){BN}+("process") { // end of process
yyextra->isFuncProto=false;
codifyLines(yyscanner,yytext);
BEGIN(Bases);
}
<Bases>^{B}*("begin "|"begin") {
yyextra->isFuncProto=false;
writeFont(yyscanner,"vhdlkeyword",yytext);
}
<Bases>^{B}*("use"|"library"){BN}+ { //found package or library
writeFont(yyscanner,"vhdlkeyword",yytext);
BEGIN(ParsePackage);
}
<Bases>^{B}*("use"){BN}+("configuration")[^\n]* {
codifyLines(yyscanner,yytext);
}
<Bases>{FUNC} { // found function|procedure
yyextra->vhdlKeyDict.clear();
yyextra->funcProto.resize(0);
yyextra->isProto=false;
yyextra->funcProto.append(yytext);
yyextra->braceCount=1;
BEGIN(ParseType);
}
<Bases>^{B}*("entity"|"package"){BN}+ {
appStringLower(yyextra->prevString,yytext);
writeFont(yyscanner,"keywordflow",yytext);
yyextra->isPackageBody=false;
BEGIN(ClassesName);
}
<Bases>"end"{BN}+"architecture"{BN}+{FUNCNAME} {
codifyLines(yyscanner,yytext,yyextra->currClass,true);
yyextra->currArch = false;
}
<Bases>"end"{BN}+{FUNCNAME} {
if (yyextra->currArch)
{
codifyLines(yyscanner,yytext,yyextra->currClass,true);
yyextra->currArch = false;
}
else
{
REJECT;
}
}
<Bases>"end" {
appStringLower(yyextra->prevString,yytext);
QCString temp(yytext);
temp=temp.stripWhiteSpace();
writeColoredWord(yyscanner,temp);
BEGIN(End);
}
<End>{ID} {
appStringLower(yyextra->prevString,yytext);
QCString temp(yytext);
temp=temp.stripWhiteSpace();
if (!writeColoredWord(yyscanner,temp))
{
generateClassOrGlobalLink(yyscanner,*yyextra->code,temp);
}
}
<End>";" {
codifyLines(yyscanner,yytext);
BEGIN(Bases);
}
<Bases>{KEYWORD} { // found keyword
QCString qcs(yytext);
if (!writeColoredWord(yyscanner,qcs))
{
startFontClass(yyscanner,"vhdlchar");
yyextra->code->codify(yytext);
endFontClass(yyscanner);
}
}
<Bases>{ID} {
appStringLower(yyextra->prevString,yytext);
QCString temp(yytext);
temp=temp.stripWhiteSpace();
if (!writeColoredWord(yyscanner,temp))
{
startFontClass(yyscanner,"vhdlchar");
generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,temp);
endFontClass(yyscanner);
}
}
<Bases,ParseComponent>{DIGITSS} {
startFontClass(yyscanner,"vhdllogic");
codifyLines(yyscanner,yytext);
endFontClass(yyscanner);
}
<Bases>^{B}*("use"){BN}+("entity"|"component")[^\n]* {
codifyLines(yyscanner,yytext,yyextra->currClass,true);
}
<Bases>{TYPEKW} {
codifyLines(yyscanner,yytext);
if (yyextra->isFuncProto)
{
BEGIN(ParseFuncProto);
}
else
{
BEGIN(Bases);
}
}
<Bases>{OPERATOR} {
startFontClass(yyscanner,"vhdlchar");
yyextra->code->codify(yytext);
endFontClass(yyscanner);
}
<Bases>","|"."|":"|"'"|"("|")" {
startFontClass(yyscanner,"vhdlchar");
yyextra->code->codify(yytext);
endFontClass(yyscanner);
}
<Bases>{STRING} {
QCString qcs(yytext);
VhdlDocGen::deleteAllChars(qcs,'"');
VhdlDocGen::deleteAllChars(qcs,' ');
if (VhdlDocGen::isNumber(qcs.str()))
{
writeFont(yyscanner,"vhdllogic",yytext);
}
else
{
writeFont(yyscanner,"keyword",yytext);
}
}
<Bases>{B}*"#"[^\n]* {
writeFont(yyscanner,"keyword",yytext);
}
<Bases>^{B}*{XILINX}/[^a-zA-Z0-9_] {
writeWord(yyscanner,yytext);
//codifyLines(yyscanner,yytext,yyextra->currClass,true);
}
<Bases>^{B}*"set_"[^\n]* {
writeWord(yyscanner,yytext);
}
<*>\n {
codifyLines(yyscanner,yytext);
BEGIN(Bases);
}
<*>[\x80-\xFF]* { // keep utf8 characters together...
yyextra->code->codify(yytext);
}
<*>. {
yyextra->code->codify(yytext);
}
<*>\n{TEXTT} { // found normal or special comment on its own line
QCString text(yytext);
int i=text.find("--");
if (text.mid(i,3)=="--!") // && // hide special comment
{
if (!Config_getBool(STRIP_CODE_COMMENTS))
{
codifyLines(yyscanner,text,0,false,true);
}
else yyextra->yyLineNr++; // skip complete line, but count line
}
else // normal comment
{
codifyLines(yyscanner,text,0,false,true);
}
}
<*>{TEXTT} { // found normal or special comment after something
QCString text(yytext);
int i=text.find("--");
if (text.mid(i,3)=="--!")
{
// hide special comment
if (!Config_getBool(STRIP_CODE_COMMENTS))
{
codifyLines(yyscanner,text,0,false,true);
}
}
else // normal comment
{
codifyLines(yyscanner,text,0,false,true);
}
}
%%
/*@ ----------------------------------------------------------------------------
*/
static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
yy_size_t inputPosition = yyextra->inputPosition;
const char *s = yyextra->inputString + inputPosition;
yy_size_t c=0;
while( c < max_size && *s)
{
*buf++ = *s++;
c++;
}
yyextra->inputPosition += c;
return c;
}
static void setCurrentDoc(yyscan_t yyscanner,const QCString &anchor)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
if (Doxygen::searchIndex)
{
if (yyextra->searchCtx)
{
yyextra->code->setCurrentDoc(yyextra->searchCtx,yyextra->searchCtx->anchor(),false);
}
else
{
yyextra->code->setCurrentDoc(yyextra->sourceFileDef,anchor,true);
}
}
}
static bool checkVhdlString(yyscan_t yyscanner,QCString &name)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
if (name.isEmpty()) return false;
int len=name.length();
if (name.at(0)=='"' && name.at(len-1)=='"' && len > 2)
{
std::string inside = name.str().substr(1,len-2);
static const reg::Ex regg(R"(\s+)"); // any number of whitespace
auto qrl=split(inside,regg);
if (VhdlDocGen::isNumber(qrl[0]))
{
yyextra->code->codify("\"");
startFontClass(yyscanner,"vhdllogic");
yyextra->code->codify(inside.c_str());
endFontClass(yyscanner);
yyextra->code->codify("\"");
}
else
{
startFontClass(yyscanner,"keyword");
yyextra->code->codify(name);
endFontClass(yyscanner);
}
return true;
}
if (VhdlDocGen::isNumber(name.str()))
{
startFontClass(yyscanner,"vhdllogic");
yyextra->code->codify(name);
endFontClass(yyscanner);
return true;
}
return false;
}
static void addToSearchIndex(yyscan_t yyscanner,const QCString &text)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
if (Doxygen::searchIndex)
{
yyextra->code->addWord(text,false);
}
}
/*! 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.
*/
static void startCodeLine(yyscan_t yyscanner)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
//if (yyextra->currentFontClass) { yyextra->code->endFontClass(); }
if (yyextra->sourceFileDef)
{
//QCString lineNumber,lineAnchor;
//lineNumber.sprintf("%05d",yyextra->yyLineNr);
//lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
// if ((yyextra->yyLineNr % 500) == 0)
// fprintf(stderr,"\n starting Line %d:",yyextra->yyLineNr);
const Definition *d = yyextra->sourceFileDef->getSourceDefinition(yyextra->yyLineNr);
//printf("startCodeLine %d d=%s\n", yyextra->yyLineNr,qPrint(d ? d->name()) : "<null>");
if (!yyextra->includeCodeFragment && d)
{
yyextra->currentDefinition = d;
yyextra->currentMemberDef = yyextra->sourceFileDef->getSourceMember(yyextra->yyLineNr);
if (!yyextra->tempComp.isEmpty() && yyextra->currentMemberDef )
{
//ClassDef *cf=VhdlDocGen::getClass(yyextra->tempComp);
QCString nn=yyextra->currentMemberDef->name();
const MemberDef* mdeff=VhdlDocGen::findMember(yyextra->tempComp,nn);
if (mdeff)
{
yyextra->currentMemberDef=mdeff;
}
}
QCString lineAnchor;
lineAnchor.sprintf("l%05d",yyextra->yyLineNr);
if (yyextra->currentMemberDef)
{
yyextra->code->writeLineNumber(yyextra->currentMemberDef->getReference(),
yyextra->currentMemberDef->getOutputFileBase(),
yyextra->currentMemberDef->anchor(),yyextra->yyLineNr);
setCurrentDoc(yyscanner,lineAnchor);
}
else if (d->isLinkableInProject())
{
yyextra->code->writeLineNumber(d->getReference(),
d->getOutputFileBase(),
QCString(),yyextra->yyLineNr);
setCurrentDoc(yyscanner,lineAnchor);
}
}
else
{
yyextra->code->writeLineNumber(QCString(),QCString(),QCString(),yyextra->yyLineNr);
}
}
yyextra->code->startCodeLine(yyextra->sourceFileDef);
yyextra->startCode=true;
if (yyextra->currentFontClass)
{
yyextra->code->startFontClass(yyextra->currentFontClass);
}
}
static void endCodeLine(yyscan_t yyscanner)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
endFontClass(yyscanner);
yyextra->code->endCodeLine();
}
static void nextCodeLine(yyscan_t yyscanner)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
if (yyextra->startCode)
{
endCodeLine(yyscanner); // </div>
}
const char *fc = yyextra->currentFontClass;
if (yyextra->yyLineNr<yyextra->inputLines)
{
yyextra->currentFontClass = fc;
startCodeLine(yyscanner); //<div>
}
}
/*! writes a word to the output.
* If curr_class is defined, the word belongs to a class
* and will be linked.
*/
static void writeWord(yyscan_t yyscanner,const QCString &word,const QCString &curr_class,bool classLink)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
bool found=false;
QCString temp;
QCString tclass(curr_class);
QCString ttt(word);
if (ttt.isEmpty()) return;
for (unsigned int j=0;j<ttt.length();j++)
{
char c=ttt.at(j);
if (c==' '|| c==',' || c==';' || c==':' || c=='(' || c==')' || c=='\r' || c=='\t' || c=='.')
{
if (found)
{
if (!writeColoredWord(yyscanner,temp)) // is it a keyword ?
{
//if (VhdlDocGen::findKeyWord(temp))
// writeFont(yyscanner,"vhdlkeyword",temp);
//printf("writeWord: %s\n",qPrint(temp));
if (!tclass.isEmpty())
{
if (!classLink)
{
generateMemLink(yyscanner,*yyextra->code,tclass,temp);
}
else
{
generateClassOrGlobalLink(yyscanner,*yyextra->code,temp,false,curr_class);
}
}
else
{
if (!checkVhdlString(yyscanner,temp))
{
yyextra->code->codify(temp);
}
}
}
temp.resize(0);
found=false;
}
char cc[2];
cc[0]=c;
cc[1]=0;
yyextra->code->codify(cc);
}
else
{
found=true;
temp+=c;
}
} // for
if (!temp.isEmpty())
{
if (!writeColoredWord(yyscanner,temp))
{
if (!tclass.isEmpty())
{
if (!classLink)
{
generateMemLink(yyscanner,*yyextra->code,tclass,temp); // generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,left);
}
else
{
generateClassOrGlobalLink(yyscanner,*yyextra->code,temp,false,curr_class);
}
}
else
{
QCString qc(temp);
if (VhdlDocGen::isNumber(qc.str()))
{
startFontClass(yyscanner,"vhdllogic");
yyextra->code->codify(temp);
endFontClass(yyscanner);
}
else
{
yyextra->code->codify(temp);
}
}
}
}
}// writeWord
/*! write a code fragment 'text' that may span multiple lines, inserting
* line numbers for each line.
*/
static void codifyLines(yyscan_t yyscanner,const QCString &text,const QCString &cl,bool classlink,bool comment)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
if (text.isEmpty()) return;
//printf("codifyLines(%d,\"%s\")\n",yyextra->yyLineNr,text);
const char *p=text.data(),*sp=p;
char c;
bool done=false;
while (!done)
{
sp=p;
while ((c=*p++) && c!='\n') {}
if (c=='\n')
{
yyextra->yyLineNr++;
QCString line = sp;
line = line.left((int)(p-sp)-1);
if (comment)
{
writeFont(yyscanner,"comment",line);
}
else
{
writeWord(yyscanner,line,cl,classlink);
}
nextCodeLine(yyscanner);
}
else
{
if (comment)
{
writeFont(yyscanner,"comment",sp);
}
else
{
writeWord(yyscanner,sp,cl,classlink);
}
done=true;
}
}
}
/*! writes a link to a fragment \a text that may span multiple lines, inserting
* line numbers for each line. If \a text contains newlines, the link will be
* split into multiple links with the same destination, one for each line.
*/
static void writeMultiLineCodeLink(yyscan_t yyscanner,CodeOutputInterface &ol,
const Definition *d,
const QCString &text)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
if (text.isEmpty()) return;
static bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS);
TooltipManager::instance().addTooltip(ol,d);
QCString ref = d->getReference();
QCString file = d->getOutputFileBase();
QCString anchor = d->anchor();
QCString tooltip;
if (!sourceTooltips) // fall back to simple "title" tooltips
{
tooltip = d->briefDescriptionAsTooltip();
}
bool done=false;
const char *p=text.data();
while (!done)
{
const char *sp=p;
char c;
while ((c=*p++) && c!='\n') {}
if (c=='\n')
{
yyextra->yyLineNr++;
// printf("writeCodeLink(%s,%s,%s,%s)\n",ref,file,anchor,sp);
ol.writeCodeLink(ref,file,anchor,QCString(sp,p-sp-1),tooltip);
nextCodeLine(yyscanner);
}
else
{
ol.writeCodeLink(ref,file,anchor,sp,tooltip);
done=true;
}
}
}
/*! writes a link to a function or procedure
*/
static void generateFuncLink(yyscan_t yyscanner,CodeOutputInterface &ol,const MemberDef* mdef)
{
//printf("generateFuncLink(FuncName=%s)\n",qPrint(mdef->name()));
QCString memberName=mdef->name();
if (mdef->isLinkable()) // is it a linkable class
{
writeMultiLineCodeLink(yyscanner,ol,mdef,mdef->name());
addToSearchIndex(yyscanner,memberName);
return;
}
codifyLines(yyscanner,memberName);
addToSearchIndex(yyscanner,memberName);
} // generateFuncLink
static void generateMemLink(yyscan_t yyscanner,CodeOutputInterface &ol,QCString &clName,QCString& memberName)
{
if (memberName.isEmpty()) return;
if (clName.isEmpty())
{
codifyLines(yyscanner,memberName);
return;
}
QCString className=clName;
//MemberDef *comp=0;
//bool isLocal=false;
const MemberDef *md=VhdlDocGen::findMember(className,memberName);
ClassDef *po=VhdlDocGen::getClass(className);
if (md==0 && po && (VhdlDocGen::VhdlClasses)po->protection()==VhdlDocGen::PACKBODYCLASS)
{
QCString temp=className;//.stripPrefix("_");
temp.stripPrefix("_");
md=VhdlDocGen::findMember(temp,memberName);
}
if (md && md->isLinkable()) // is it a linkable class
{
writeMultiLineCodeLink(yyscanner,ol,md,memberName);
addToSearchIndex(yyscanner,memberName);
return;
}
// nothing found, just write out the word
codifyLines(yyscanner,memberName);
addToSearchIndex(yyscanner,memberName);
}// generateMemLink
static void generateClassOrGlobalLink(yyscan_t yyscanner,CodeOutputInterface &ol,
const QCString &clName, bool /*typeOnly*/, const QCString &curr_class)
{
QCString className=clName;
if (className.isEmpty()) return;
ClassDef *cd=0;
//MemberDef *md=0;
//bool isLocal=false;
className.stripPrefix("_");
cd = getClass(className);
if (!cd && !curr_class.isEmpty())
{
QCString cls = curr_class;
QCString suffix = "::";
suffix+=clName;
if (cls.right(suffix.length())==suffix)
{
cd = getClass(curr_class);
}
}
while (cd)
{
//className.stripPrefix("_");
QCString temp(clName);
temp.stripPrefix("_");
if (cd && cd->isLinkable()) // is it a linkable class
{
//if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ARCHITECTURECLASS)
//{
// temp=VhdlDocGen::getClassName(cd);
//}
writeMultiLineCodeLink(yyscanner,ol,cd,temp);
addToSearchIndex(yyscanner,className);
return;
}
Definition *d = cd->getOuterScope();
if (d && d->definitionType()==Definition::TypeClass)
{
cd = toClassDef(d);
}
else
{
cd = 0;
}
}
// nothing found, just write out the word
codifyLines(yyscanner,clName);
addToSearchIndex(yyscanner,clName);
}// generateClasss or global link
/*! counts the number of lines in the input */
static int countLines(yyscan_t yyscanner)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
const char *p=yyextra->inputString;
char c;
int count=1;
while ((c=*p))
{
p++ ;
if (c=='\n') count++;
}
if (p>yyextra->inputString && *(p-1)!='\n')
{ // last line does not end with a \n, so we add an extra
// line and explicitly terminate the line after parsing.
count++,
yyextra->needsTermination=true;
}
return count;
}
static void endFontClass(yyscan_t yyscanner)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
if (yyextra->currentFontClass)
{
yyextra->code->endFontClass();
yyextra->currentFontClass=0;
}
}
static void startFontClass(yyscan_t yyscanner,const char *s)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
if (s==0) return;
endFontClass(yyscanner);
yyextra->code->startFontClass(s);
yyextra->currentFontClass=s;
}
static void writeFont(yyscan_t yyscanner,const char *s,const QCString &text)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
if (s==0 || text.isEmpty()) return;
//printf("writeFont(yyscanner,%d,\"%s\")\n",yyextra->yyLineNr,text);
yyextra->code->startFontClass(s);
yyextra->code->codify(text);
yyextra->code->endFontClass();
}
//----------------------------------------------------------------------------
static void appStringLower(QCString& qcs,const char* text)
{
qcs.resize(0);
qcs.append(text);
qcs=qcs.stripWhiteSpace();
}
/* writes and links a port map statement */
static void codifyMapLines(yyscan_t yyscanner,const QCString &text)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
if (text.isEmpty()) return;
QCString temp;
//bool dot=false;
int wordCounter=0;
QCString ctemp;
//printf("codifyMapLines(%d,\"%s\")\n",yyextra->yyLineNr,qPrint(text));
const char *p=text.data();
char c;
bool done=false;
while (!done)
{
//sp=p;
while ((c=*p++) && c!='\n' && c!=':' && c != ' ' && c != '(' && c!='\0' && c!='\t')
{
if (c!=0x9)
temp+=c;
}
if (c=='\0') return;
if (!temp.isEmpty()) wordCounter++;
if (!temp.isEmpty())
{
// different kinds of component instantiations
// xxx:yyy (generic/port) map(
// xxx:(entity/component/configuration) yyy (generic/port) map(
// xxx: entity yyy(zzz) (generic/port) map(
if (wordCounter==2 || wordCounter==3)
{
QCString q=temp.lower(); // consider (upper/lower) cases
if (q=="entity" || q=="component" || q=="configuration" || q=="port" || q=="generic")
{
generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,temp);
}
else
{
yyextra->PortMapComp=temp;
generateClassOrGlobalLink(yyscanner,*yyextra->code,temp);
}
}
else
{
generateMemLink(yyscanner,*yyextra->code,yyextra->currClass,temp);
}
}
ctemp.fill(c,1);
codifyLines(yyscanner,ctemp);
ctemp.resize(0);
temp.resize(0);
}//while
}//codifyMapLines
/*
* writes a function|procedure prototype and links the function|procedure name
*/
static void writeFuncProto(yyscan_t yyscanner)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
QCString name,ret;
VhdlDocGen::parseFuncProto(yyextra->funcProto,name,ret,false);
if (name.isEmpty())
{
codifyLines(yyscanner,yyextra->funcProto,yyextra->currClass);
return;
}
StringVector qlist=split(yyextra->funcProto.str(),name.str());
QCString temp(qlist[0]);
codifyLines(yyscanner,temp,yyextra->currClass);
yyextra->funcProto.stripPrefix(temp);
temp.resize(0);
temp=yyextra->currClass;
if (yyextra->isPackageBody)
{
temp.stripPrefix("_");// _{package body name}
}
const MemberDef *mdef=VhdlDocGen::findFunction(name,temp);
if (mdef)
{
generateFuncLink(yyscanner,*yyextra->code,mdef);
yyextra->funcProto.stripPrefix(name);
codifyLines(yyscanner,yyextra->funcProto,yyextra->currClass);
}
else
{
codifyLines(yyscanner,yyextra->funcProto,yyextra->currClass);
}
}// writeFuncProto
/* writes a process prototype to the output */
static void writeProcessProto(yyscan_t yyscanner)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
codifyLines(yyscanner,yyextra->funcProto,yyextra->currClass);
yyextra->vhdlKeyDict.clear();
}// writeProcessProto
/* writes a keyword */
static bool writeColoredWord(yyscan_t yyscanner,QCString& word )
{
QCString qcs=word.lower();
const char *ss=VhdlDocGen::findKeyWord(qcs);
if (ss)
{
writeFont(yyscanner,ss,word);
return true;
}
return false;
}
//-----------------------------------------------------------------------------------
struct VHDLCodeParser::Private
{
yyscan_t yyscanner;
vhdlcodeYY_state state;
};
VHDLCodeParser::VHDLCodeParser() : p(std::make_unique<Private>())
{
vhdlcodeYYlex_init_extra(&p->state,&p->yyscanner);
#ifdef FLEX_DEBUG
vhdlcodeYYset_debug(1,p->yyscanner);
#endif
resetCodeParserState();
}
VHDLCodeParser::~VHDLCodeParser()
{
vhdlcodeYYlex_destroy(p->yyscanner);
}
void VHDLCodeParser::resetCodeParserState()
{
p->state.vhdlKeyDict.clear();
}
void VHDLCodeParser::parseCode(CodeOutputInterface &od,
const QCString &className,
const QCString &s,
SrcLangExt,
bool exBlock,
const QCString &exName,
FileDef *fd,
int startLine,
int endLine,
bool inlineFragment,
const MemberDef *memberDef,
bool,
const Definition *searchCtx,
bool /* collectXRefs */)
{
yyscan_t yyscanner = p->yyscanner;
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
//printf("***parseCode() exBlock=%d exName=%s fd=%p\n",exBlock,exName,fd);
if (s.isEmpty()) return;
printlex(yy_flex_debug, true, __FILE__, fd ? qPrint(fd->fileName()): NULL);
if (memberDef)
{
const ClassDef *dd=memberDef->getClassDef();
if (dd) yyextra->currClass=dd->name();
}
resetCodeParserState();
yyextra->code = &od;
yyextra->inputString = s.data();
yyextra->inputPosition = 0;
yyextra->currentFontClass = 0;
yyextra->needsTermination = false;
yyextra->searchCtx = searchCtx;
if (startLine!=-1)
yyextra->yyLineNr = startLine;
else
yyextra->yyLineNr = 1;
if (endLine!=-1)
yyextra->inputLines = endLine+1;
else
yyextra->inputLines = yyextra->yyLineNr + countLines(yyscanner) - 1;
// yyextra->theCallContext.clear();
yyextra->exampleBlock = exBlock;
yyextra->exampleName = exName;
yyextra->sourceFileDef = fd;
bool cleanupSourceDef = false;
if (exBlock && fd==0)
{
// create a dummy filedef for the example
yyextra->sourceFileDef = createFileDef("",exName);
cleanupSourceDef = true;
}
if (yyextra->sourceFileDef)
{
setCurrentDoc(yyscanner,"l00001");
}
yyextra->currentDefinition = 0;
yyextra->currentMemberDef = 0;
yyextra->vhdlMember=0;
if (!yyextra->exampleName.isEmpty())
{
yyextra->exampleFile = convertNameToFile(yyextra->exampleName+"-example");
}
yyextra->includeCodeFragment = inlineFragment;
startCodeLine(yyscanner);
if (!yyextra->lexInit)
{
VhdlDocGen::init();
yyextra->lexInit=true;
}
/*int iLine=*/countLines(yyscanner);
vhdlcodeYYrestart( 0, yyscanner );
BEGIN( Bases );
vhdlcodeYYlex(yyscanner);
if (yyextra->needsTermination)
{
endCodeLine(yyscanner);
}
if (cleanupSourceDef)
{
// delete the temporary file definition used for this example
delete yyextra->sourceFileDef;
yyextra->sourceFileDef=0;
}
yyextra->startCode=false;
// write the tooltips
TooltipManager::instance().writeTooltips(od);
printlex(yy_flex_debug, false, __FILE__, fd ? qPrint(fd->fileName()): NULL);
}
#if USE_STATE2STRING
#include "vhdlcode.l.h"
#endif
|