File: vtkParse.l

package info (click to toggle)
vtk 5.0.2-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 51,080 kB
  • ctags: 67,442
  • sloc: cpp: 522,627; ansic: 221,292; tcl: 43,377; python: 14,072; perl: 3,102; java: 1,436; yacc: 1,033; sh: 469; lex: 248; makefile: 181; asm: 154
file content (248 lines) | stat: -rw-r--r-- 6,597 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
%option yylineno
%{

/*

This file must be translated to C and modified to build everywhere.

Run flex like this:

  flex -olex.yy.c vtkParse.l

Modify lex.yy.c:
  - remove yyunput function
  - remove TABs

*/

/* We do not care of interactive mode */
#define YY_NEVER_INTERACTIVE 1
#define YY_NO_UNPUT 1

/* Do not include unistd.h in generated source. */
#define YY_NO_UNISTD_H

/* Skip declaring this function.  It is a macro.  */
#define YY_SKIP_YYWRAP

#ifdef _WIN32
#pragma warning ( disable : 4127 )
#pragma warning ( disable : 4131 )
#pragma warning ( disable : 4244 )
#pragma warning ( disable : 4251 )
#pragma warning ( disable : 4267 )
#pragma warning ( disable : 4305 )
#pragma warning ( disable : 4309 )
#pragma warning ( disable : 4706 )
#pragma warning ( disable : 4786 )
#endif

%}


%%

"/*" { int c1 = 0, c2 = input();
       for (;;)
	 {
         if (c2 == 0) 
           {
           fprintf(yyout,"Cannot find closing comment.\n");
           break;
           }
         if (c1 == '*' && c2 == '/') break;
         c1 = c2; c2 = input();
         }
     };

^[\t ]*"//BTX".*$ { 
       int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = input();
       for (;;)
	 {
         if (c5 == 0) 
           {
           fprintf(yyout,"Cannot find matching //ETX.\n");
           break;
           }
         if (c1 == '/' && c2 == '/' && c3 == 'E' && c4 == 'T' && c5 == 'X') break;
         c1 = c2; c2 = c3; c3 = c4; c4 = c5; c5 = input();
         }
       for (;;)
         {
         if (c5 == 0) break;
         if (c5 == '\n') break;
         c5 = input();
         } 
     };

^[\t ]*"// .NAME".* { 
     int pos = 1;
     while (yytext[pos-1] != 'M' || yytext[pos] != 'E')
       {
       pos++; 
       }
     yylval.str = (char *)malloc(yyleng + 1 - pos - 1);
     memcpy(yylval.str,yytext+ pos + 1,yyleng - pos - 1);
     yylval.str[yyleng - pos - 1] = '\0';
     data.NameComment = vtkstrdup(yylval.str);
     };

^[\t ]*"// .SECTION Description".* { 
     CommentState = 1;
     data.Description = (char*)malloc(100000);
     data.Description[0] = '\0';
     };

^[\t ]*"// .SECTION See Also".* { 
     CommentState = 3;
     data.SeeAlso = (char*)malloc(100000);
     data.SeeAlso[0] = '\0';
     };

^[\t ]*"// .SECTION see also".* { 
     CommentState = 3;
     data.SeeAlso = (char*)malloc(100000);
     data.SeeAlso[0] = '\0';
     };

^[\t ]*"// .SECTION Caveats".* { 
     CommentState = 4;
     data.Caveats = (char*)malloc(100000);
     data.Caveats[0] = '\0';
     };

^[\t ]*"// Description:".* { 
     CommentState = 2;
     HaveComment = 1;
     CommentText[0] = '\0';
     };

^[\t ]*[\r\n]  { 
     HaveComment = 0; 
     CommentState = 0; 
     };

^[\t ]*"//".*   { 
     int pos = 1;
     while (yytext[pos-1] != '/' || yytext[pos] != '/') pos++; 
     yylval.str = (char *)malloc(yyleng + 1 - pos - 1 + 1);
     memcpy(yylval.str,yytext+ pos + 1,yyleng - pos - 1);
     yylval.str[yyleng - pos - 1] = '\n';
     yylval.str[yyleng - pos] = '\0';
     switch (CommentState)
       {
       case 1: strcat(data.Description,yylval.str); break;
       case 2: strcat(CommentText,yylval.str); break;
       case 3: strcat(data.SeeAlso,yylval.str); break;
       case 4: strcat(data.Caveats,yylval.str); break;
       }
     };

"//".* ;

[A-Za-z0-9_]*"_EXPORT" ;

"vtkNotUsed"[ ]*"("[^)]*")" ;

"["[\t\n\r\ ]*[1-9][0-9]*[\t\n\r ]*"]"  {
   sscanf(yytext+1,"%d",&yylval.integer); return(ARRAY_NUM);}


"class "[\t\n\r ]*"vtk"[a-zA-Z0-9_]*[\t\n\r ]*";"  return(CLASS_REF);

"void"[\t\n\r ]*"("[\t\n\r ]*"*"[a-zA-Z0-9_]*[\t\n\r ]*")"[\t\n\r ]*"("[\t\n\r ]*"void"[\t\n\r ]*"*"[\n\t ]*")" return(VAR_FUNCTION);

"short"[\t\n\r ]*"int" return(SHORT);
"long"[\t\n\r ]*"int"  return(LONG);
"int"[\t\n\r ]*"short" return(SHORT);
"int"[\t\n\r ]*"long"  return(LONG);

"long"[\t\n\r ]*"long"  return(LONG_LONG);
"int"[\t\n\r ]*"long"[\t\n\r ]*"long"  return(LONG_LONG);
"long"[\t\n\r ]*"long"[\t\n\r ]*"int"  return(LONG_LONG);

"__int64"  return(INT64__);

"signed"[\t\n\r ]*"char"  return(SIGNED_CHAR);

"class"		return(CLASS);
"public"  	return(PUBLIC);
"private"  	return(PRIVATE);
"protected" 	return(PROTECTED);
"int" 	        return(INT);
"float" 	return(FLOAT);
"short" 	return(SHORT);
"long"  	return(LONG);
"double" 	return(DOUBLE);
"void" 	        return(VOID);
"char" 	        return(CHAR);
"virtual"       return(VIRTUAL);
"const"         return(CONST);
"operator"      return(OPERATOR);
"unsigned"      return(UNSIGNED);
"friend"        return(FRIEND);
"static"        return(STATIC);

"vtkFloatingPointType" return(DOUBLE);
"vtkIdType"            return(IdType);
"vtkStdString"         return(StdString);
"vtkSetMacro"          return(SetMacro);
"vtkGetMacro"          return(GetMacro);
"vtkSetStringMacro"    return(SetStringMacro);
"vtkGetStringMacro"    return(GetStringMacro);
"vtkSetClampMacro"     return(SetClampMacro);
"vtkSetObjectMacro"    return(SetObjectMacro);
"vtkSetReferenceCountedObjectMacro" return(SetReferenceCountedObjectMacro);
"vtkGetObjectMacro"    return(GetObjectMacro);
"vtkBooleanMacro"      return(BooleanMacro);
"vtkSetVector2Macro"   return(SetVector2Macro);
"vtkSetVector3Macro"   return(SetVector3Macro);
"vtkSetVector4Macro"   return(SetVector4Macro);
"vtkSetVector6Macro"   return(SetVector6Macro);
"vtkGetVector2Macro"   return(GetVector2Macro);
"vtkGetVector3Macro"   return(GetVector3Macro);
"vtkGetVector4Macro"   return(GetVector4Macro);
"vtkGetVector6Macro"   return(GetVector6Macro);
"vtkSetVectorMacro"    return(SetVectorMacro);
"vtkGetVectorMacro"    return(GetVectorMacro);
"vtkViewportCoordinateMacro"     return(ViewportCoordinateMacro);
"vtkWorldCoordinateMacro" return(WorldCoordinateMacro);
"vtkTypeMacro"         return(TypeMacro);
"vtkTypeRevisionMacro" return(TypeMacro);
"VTK_LEGACY"           return(VTK_LEGACY);

[0-9]+		{ sscanf(yytext,"%d",&yylval.integer); return(NUM);}

\"[^\"]+\"	{
		yylval.str =  vtkstrdup(yytext + 1);
		yylval.str[strlen(yytext)-2] = '\0';
		return(STRING);
		}

^"#"[^\n]*$     ;


"vtk"[0-9a-zA-Z_]*  { yylval.str = (char *)malloc(yyleng + 1);
                     memcpy(yylval.str,yytext,yyleng);
                     yylval.str[yyleng] = '\0';
                     return(VTK_ID);
                    }

[a-zA-Z_][0-9a-zA-Z_]*  { yylval.str = (char *)malloc(yyleng + 1);
                          memcpy(yylval.str,yytext,yyleng);
                          yylval.str[yyleng] = '\0';
                          return(ID);
                        }

[\t\n\r ] ;


"["	return(yytext[0]);
"]"	return(yytext[0]);


[~{}():;*=,&.\-] {	return(yytext[0]); }

.		return(OTHER);
%%