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