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