summaryrefslogtreecommitdiffstats
path: root/src/tag.l
blob: edc5cf1504befc569acedcfd44e0b963e0020b69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/******************************************************************************
 *
 * $Id$
 *
 * Copyright (C) 1997-1999 by Dimitri van Heesch.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
 * All output generated with Doxygen is not covered by this license.
 *
 */

%{

/*
 *	includes
 */
#include <stdio.h>
#include <qstring.h>
#include <qfileinf.h>
  
#include "classdef.h"
#include "filedef.h"
#include "memberdef.h"
#include "doxygen.h"
#include "util.h"
#include "message.h"
  
#define YY_NO_UNPUT
#define YY_NEVER_INTERACTIVE 1

static int yyLineNr;
static QString className;
static QString fileName;
static QString tagName;
static QString memberName;
static QString anchorName;
static QString argString;
static ClassDef *cd;
static FileDef *fd;

static void addClass(const char *name,const char *fileName)
{
  //printf("adding class %s\n",name);
  if (name!=0 && strlen(name)>0 && classDict[name]==0)
  {
    cd = new ClassDef(name,ClassDef::Class,tagName,fileName);
    fd = 0;
    classList.inSort(cd);
    classDict.insert(className,cd);
  }
}

static void addFile(const char *name)
{
  //printf("adding file %s\n",name);
  fd = new FileDef(0,name,tagName);
  FileName *mn;
  if ((mn=inputNameDict[name]))
  {
    mn->append(fd); 
  }
  else
  {
    mn = new FileName(name);
    mn->append(fd);
    inputNameList.inSort(mn);
    inputNameDict.insert(name,mn);
  }
  cd = 0;
  //fileList.inSort(fd);
  //fileDict.insert(fileName,fd);
}

static void addMember(const char *name,const char *anchor,const char *args)
{
  //printf("adding member %s\n",name);
  if (cd || fd)
  {
    MemberNameDict *mnd=0;
    MemberNameList *mnl=0;
    MemberDef *md;
    md=new MemberDef(0,name,args,0,Public,Normal,FALSE,FALSE,
                       MemberDef::Function,0,0); 
    md->setReference(anchor);
    if (cd)
    {
      //md=new MemberDef(cd,name,args,anchor,tagName);
      md->setMemberClass(cd);
      cd->insertMember(md); 
      //printf("Adding member %s %s to class\n",name,args);
      mnd=&memberNameDict;
      mnl=&memberNameList;
    }
    else
    {
      //md=new MemberDef(&unrelatedClass,name,args,anchor,tagName);
      md->setFileDef(fd);
      fd->insertMember(md);
      //printf("Adding global member %s %s\n",name,args);
      mnd=&functionNameDict;
      mnl=&functionNameList;
    }
    MemberName *mn;
    if ((mn=(*mnd)[memberName]))
    {
      //printf("mn->inSort()\n");
      mn->append(md);
    }
    else
    {
      //printf("mn->append()\n");
      mn=new MemberName(memberName);
      mn->append(md);
      //printf("Adding memberName=%s\n",mn->memberName());
      mnl->inSort(mn);
      mnd->insert(memberName,mn);
    }
  }
}

/* -----------------------------------------------------------------
 */

%}

ID [a-z_A-Z][a-z_A-Z0-9]*
FILE [a-z_A-Z0-9\.\-\+\:\\\/]+

%x Pass1
%x Pass2
%x AnchorName
%x ArgString1
%x ArgString2
%x ClassName1
%x ClassName2
%x FileName
%x BaseClasses
%x ClassFile1
%x ClassFile2

%%

<Pass1>^">"				{
  					  BEGIN(ClassName1);
  					}
<Pass1>^"&"				{
  					  BEGIN(FileName);
  					}
<Pass1>^[~a-z_A-Z][^ \n]*/" "		{
  					  memberName=yytext;
					  BEGIN(AnchorName);
  					}
<Pass2>^">"				{
  					  BEGIN(ClassName2);
  					}
<AnchorName>{ID}			{
  					  anchorName=yytext;
					  BEGIN(ArgString1);
  					}
<ArgString1>"\""			{
  					  BEGIN(ArgString2);
  					}
<ArgString2>[^\"\n]*/"\""		{
  					  argString=yytext;
					  addMember(memberName,anchorName,argString);
					  BEGIN(Pass1);
  					}
<FileName>{FILE}/":"			{
  					  fileName=yytext;
					  addFile(yytext);
					  BEGIN(Pass1);
  					}
<ClassName1>{ID}/":"			{
  					  className=yytext;		  
					  BEGIN(ClassFile1);
  					}
<ClassFile1>\"				{
  					  BEGIN(ClassFile2);
  					}
<ClassFile2>[^\"]*/\"			{
  					  addClass(className,yytext); 
					  BEGIN(Pass1);
  					}
<ClassFile2>\n				{
  					  yyLineNr++;
					  BEGIN(Pass1);
  					}
<ClassName2>{ID}/":"			{
  					  cd=getClass(yytext);
					  BEGIN(BaseClasses);
  					}
<BaseClasses>{ID}/"?"			{
  					  ClassDef *bcd=getClass(yytext);
					  if (cd && bcd)
					  {
					    cd->insertBaseClass(bcd,Public,Normal);
					    bcd->insertSuperClass(cd,Public,Normal);
					  }
  					}
<BaseClasses>\n				{
  					  yyLineNr++;
  					  BEGIN(Pass2);
  					}
<*>.					
<*>\n					{ yyLineNr++ ; }

%%

/*@ ----------------------------------------------------------------------------
 */

void parseTagFile(const char *fileName)
{
  FILE *f=fopen(fileName,"r");
  QFileInfo fi(fileName);
  if (!f || !fi.exists());
  tagName = fi.fileName();
  tagYYin = f;

  cd=0;
  yyLineNr      = 1;
  tagYYrestart( tagYYin );
  BEGIN(Pass1);
  tagYYlex();

  rewind(f);
  cd=0;
  yyLineNr      = 1;
  tagYYrestart( tagYYin );
  BEGIN(Pass2);
  tagYYlex();

  fclose(f);
}

extern "C" { // some bogus code to keep the compiler happy
  int  tagYYwrap() { return 1 ; }
}