1 | /****************************************************************************
|
---|
2 | ** $Id: moc.l 2 2005-11-16 15:49:26Z dmik $
|
---|
3 | **
|
---|
4 | ** Lexical analyzer for meta object compiler
|
---|
5 | **
|
---|
6 | ** Created : 930417
|
---|
7 | **
|
---|
8 | ** Copyright (C) 1992-2001 Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | *****************************************************************************/
|
---|
37 |
|
---|
38 | %{
|
---|
39 | #ifdef MOC_YACC_CODE
|
---|
40 |
|
---|
41 | #ifdef MOC_MWERKS_PLUGIN
|
---|
42 | #ifdef Q_OS_MAC9
|
---|
43 | # define isascii(c) ((int)( (unsigned int) (c) <= (unsigned char)0x7F ))
|
---|
44 | #endif
|
---|
45 | const char *buf_buffer = NULL;
|
---|
46 | long buf_size_total = 0, buf_index = 0;
|
---|
47 | #define YY_INPUT(buf, result, max_size) \
|
---|
48 | { \
|
---|
49 | if(buf_index < buf_size_total ) { \
|
---|
50 | while(!isascii(buf_buffer[buf_index])) buf_index++; \
|
---|
51 | int ms = ((max_size < buf_size_total) ? max_size : buf_size_total); \
|
---|
52 | for(result = 0; result < ms; result++) { \
|
---|
53 | char c = buf_buffer[buf_index + result]; \
|
---|
54 | if(!isascii(c)) { \
|
---|
55 | buf_index++; \
|
---|
56 | break; \
|
---|
57 | } \
|
---|
58 | buf[result] = c == '\r' ? '\n' : c; \
|
---|
59 | } \
|
---|
60 | buf_index += result; \
|
---|
61 | } else result = YY_NULL; \
|
---|
62 | }
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | #include "qstring.h"
|
---|
66 |
|
---|
67 |
|
---|
68 | #define input yyinput // yyinput in C++
|
---|
69 |
|
---|
70 | #define X if(lexDebug){fprintf(stderr,"LEX (%i) : %s\n",lineNo,yytext);};
|
---|
71 | #define Y if(lexDebug){fprintf(stderr,"LEX (%i) : %s\n",lineNo,yytext);};
|
---|
72 | /*
|
---|
73 | #define Y if(lexDebug){fprintf(stderr,"LEX (%i) : %s updates level to %i\n"\
|
---|
74 | ,lineNo,yytext,templLevel);};
|
---|
75 | */
|
---|
76 | #define Z if(lexDebug){fprintf(stderr,"LEX (%i) : skipped the string %s\"\n"\
|
---|
77 | ,lineNo,yytext);};
|
---|
78 | #define BEGIN_INSIDE
|
---|
79 |
|
---|
80 |
|
---|
81 | #define linput() \
|
---|
82 | ( (c = input()) == '\n' ? (lineNo++, c) : (c == EOF) ? 0 : c )
|
---|
83 |
|
---|
84 | #include <string.h>
|
---|
85 | #include <stdlib.h>
|
---|
86 |
|
---|
87 | int classPLevel = 1; /* Depth of nested curly braces in IN_CLASS */
|
---|
88 | int namespacePLevel = 1; /* Depth of nested curly braces in IN_NAMESPACE */
|
---|
89 | int expLevel = 1; /* Depth of nested parentheses in IN_EXPR */
|
---|
90 | int enumLevel = 1; /* Depth of nested parentheses in IN_ENUM */
|
---|
91 | int fctLevel = 1; /* Depth of nested parentheses in IN_FCT */
|
---|
92 | int templLevel = 1; /* Depth of levels in IN_TEMPL_ARGS */
|
---|
93 |
|
---|
94 | int lastState = 0; /* Remembers the state when a
|
---|
95 | MOC_SKIP_BEGIN is encountered */
|
---|
96 | int skipLevel = 0; /* Depth of MOC_SKIP_BEGINs */
|
---|
97 |
|
---|
98 | class QString;
|
---|
99 |
|
---|
100 | extern void addExpressionChar( const char );
|
---|
101 | extern void addExpressionString( const char * );
|
---|
102 | extern void moc_warn( const char *msg );
|
---|
103 | %}
|
---|
104 |
|
---|
105 | %start OUTSIDE QT_DEF IN_CLASS IN_NAMESPACE IN_ENUM IN_EXPR IN_DEF_ARG IN_FCT IN_TEMPL_ARGS GIMME_SEMICOLON SKIP IN_PROPERTY IN_CLASSINFO
|
---|
106 |
|
---|
107 | ALMOSTSTRING \"([^"\n\\]|\\(.|\n))*
|
---|
108 | STRING {ALMOSTSTRING}\"
|
---|
109 |
|
---|
110 | %%
|
---|
111 |
|
---|
112 | <OUTSIDE>"class" { X;
|
---|
113 | BEGIN QT_DEF;
|
---|
114 | return CLASS; }
|
---|
115 | <OUTSIDE>"namespace" { X;
|
---|
116 | BEGIN QT_DEF;
|
---|
117 | return NAMESPACE; }
|
---|
118 | <OUTSIDE>"using" { X;
|
---|
119 | BEGIN QT_DEF;
|
---|
120 | return USING; }
|
---|
121 | <OUTSIDE>"template" { X;
|
---|
122 | BEGIN QT_DEF;
|
---|
123 | return TEMPLATE; }
|
---|
124 | <QT_DEF>"Q_OBJECT" { X; return Q_OBJECT; }
|
---|
125 | <QT_DEF>"signals" { X; return SIGNALS; }
|
---|
126 | <QT_DEF>"slots" { X; return SLOTS; }
|
---|
127 | <QT_DEF>"Q_CLASSINFO" { X; return Q_CLASSINFO; }
|
---|
128 | <QT_DEF>"Q_PROPERTY" { X; return Q_PROPERTY; }
|
---|
129 | <QT_DEF>"Q_OVERRIDE" { X; return Q_OVERRIDE; }
|
---|
130 | <QT_DEF>"Q_ENUMS" { X; return Q_ENUMS; }
|
---|
131 | <QT_DEF>"Q_SETS" { X; return Q_SETS; }
|
---|
132 |
|
---|
133 | <IN_FCT>"{" { fctLevel++;Y; }
|
---|
134 | <IN_FCT>"}" { fctLevel--;Y;if (fctLevel==0){X;return '}';}}
|
---|
135 | <IN_CLASS>"{" { classPLevel++;Y; }
|
---|
136 | <IN_CLASS>"}" { classPLevel--;Y;if (classPLevel == 0)
|
---|
137 | {X;return '}';} }
|
---|
138 | <IN_CLASS>"public" { X;if( classPLevel == 1 ) return PUBLIC; }
|
---|
139 | <IN_CLASS>"protected" { X;if( classPLevel == 1 ) return PROTECTED; }
|
---|
140 | <IN_CLASS>"private" { X;if( classPLevel == 1 ) return PRIVATE; }
|
---|
141 | <IN_CLASS>"signals" { X;if( classPLevel == 1 ) return SIGNALS; }
|
---|
142 | <IN_CLASS>"slots" { X;if( classPLevel == 1 ) return SLOTS; }
|
---|
143 | <IN_CLASS>"Q_CLASSINFO" { X;if( classPLevel == 1 ) return Q_CLASSINFO; }
|
---|
144 | <IN_CLASS>"Q_OBJECT" { X;
|
---|
145 | if ( classPLevel == 1 )
|
---|
146 | return Q_OBJECT;
|
---|
147 | else if ( classPLevel > 1 )
|
---|
148 | moc_warn( "Cannot use Q_OBJECT in nested class." );
|
---|
149 | }
|
---|
150 | <IN_CLASS>"Q_PROPERTY" { X;if( classPLevel == 1 ) return Q_PROPERTY; }
|
---|
151 | <IN_CLASS>"Q_OVERRIDE" { X;if( classPLevel == 1 ) return Q_OVERRIDE; }
|
---|
152 | <IN_CLASS>"Q_ENUMS" { X;if( classPLevel == 1 ) return Q_ENUMS; }
|
---|
153 | <IN_CLASS>"Q_SETS" { X;if( classPLevel == 1 ) return Q_SETS; }
|
---|
154 |
|
---|
155 | <IN_NAMESPACE>"{" { namespacePLevel++;Y; }
|
---|
156 | <IN_NAMESPACE>"}" { namespacePLevel--;Y;if (namespacePLevel == 0)
|
---|
157 | {X;return '}';}}
|
---|
158 | <IN_NAMESPACE>"class" { X;
|
---|
159 | BEGIN QT_DEF;
|
---|
160 | return CLASS; }
|
---|
161 | <IN_NAMESPACE>"template" { X;
|
---|
162 | BEGIN QT_DEF;
|
---|
163 | return TEMPLATE; }
|
---|
164 | <IN_NAMESPACE>"namespace" { X;
|
---|
165 | BEGIN QT_DEF;
|
---|
166 | return NAMESPACE; }
|
---|
167 | <IN_NAMESPACE>"using" { X;
|
---|
168 | BEGIN QT_DEF;
|
---|
169 | return USING; }
|
---|
170 |
|
---|
171 | <IN_PROPERTY>"(" { X; return '('; }
|
---|
172 | <IN_PROPERTY>")" { X; return ')'; }
|
---|
173 | <IN_PROPERTY>"READ" { X; return READ; }
|
---|
174 | <IN_PROPERTY>"WRITE" { X; return WRITE; }
|
---|
175 | <IN_PROPERTY>"STORED" { X; return STORED; }
|
---|
176 | <IN_PROPERTY>"RESET" { X; return RESET; }
|
---|
177 | <IN_PROPERTY>"DESIGNABLE" { X; return DESIGNABLE; }
|
---|
178 | <IN_PROPERTY>"SCRIPTABLE" { X; return SCRIPTABLE; }
|
---|
179 |
|
---|
180 |
|
---|
181 | <IN_EXPR>"(" { expLevel++;X; }
|
---|
182 | <IN_EXPR>")" { expLevel--;Y;if (expLevel == 0)
|
---|
183 | { X; BEGIN QT_DEF; return ')';} }
|
---|
184 | <IN_EXPR>"[" { expLevel++;X; }
|
---|
185 | <IN_EXPR>"]" { expLevel--;X;if (expLevel == 0)
|
---|
186 | { X; BEGIN QT_DEF; return ']';} }
|
---|
187 | <IN_EXPR>"," { if (expLevel == 0)
|
---|
188 | { X; BEGIN QT_DEF; return ',' ;} }
|
---|
189 | <IN_EXPR>";" { if (expLevel == 0)
|
---|
190 | { X; BEGIN QT_DEF; return ';' ;} }
|
---|
191 | <IN_DEF_ARG>"(" { expLevel++;X; }
|
---|
192 | <IN_DEF_ARG>")" { expLevel--;Y;if (expLevel == 0)
|
---|
193 | { X; BEGIN QT_DEF; return ')';} }
|
---|
194 | <IN_DEF_ARG>"[" { expLevel++;X; }
|
---|
195 | <IN_DEF_ARG>"]" { expLevel--;X;if (expLevel == 0)
|
---|
196 | { X; BEGIN QT_DEF; return ']';} }
|
---|
197 | <IN_DEF_ARG>"," { if (expLevel <= 1)
|
---|
198 | { X; BEGIN QT_DEF; return ',' ;} }
|
---|
199 | <IN_DEF_ARG>";" { if (expLevel == 0)
|
---|
200 | { X; BEGIN QT_DEF; return ';' ;} }
|
---|
201 | <IN_ENUM>"(" { enumLevel++;X; }
|
---|
202 | <IN_ENUM>")" { enumLevel--;X; }
|
---|
203 | <IN_ENUM>"[" { enumLevel++;X; }
|
---|
204 | <IN_ENUM>"]" { enumLevel--;X }
|
---|
205 | <IN_ENUM>"," { if (enumLevel == 0)
|
---|
206 | { X; BEGIN QT_DEF; return ',' ;} }
|
---|
207 | <IN_ENUM>";" { if (enumLevel == 0)
|
---|
208 | { X; BEGIN QT_DEF; return ';' ;} }
|
---|
209 | <IN_ENUM>"}" { if (enumLevel == 0)
|
---|
210 | { X; BEGIN QT_DEF; return '}' ;} }
|
---|
211 | <IN_TEMPL_ARGS>[[(<] { templLevel++;
|
---|
212 | Y;
|
---|
213 | addExpressionChar( yytext[0] );
|
---|
214 | }
|
---|
215 | <IN_TEMPL_ARGS>[])>] { templLevel--;
|
---|
216 | Y;
|
---|
217 | if ( templLevel == 0 ) {
|
---|
218 | X;
|
---|
219 | BEGIN QT_DEF;
|
---|
220 | return yytext[0];
|
---|
221 | } else {
|
---|
222 | addExpressionChar( yytext[0] );
|
---|
223 | }
|
---|
224 | }
|
---|
225 | <QT_DEF>"friend" { X;return FRIEND; }
|
---|
226 | <QT_DEF>"typedef" { X;return TYPEDEF; }
|
---|
227 | <QT_DEF>"auto" { X;return AUTO; }
|
---|
228 | <QT_DEF>"register" { X;return REGISTER; }
|
---|
229 | <QT_DEF>"static" { X;return STATIC; }
|
---|
230 | <QT_DEF>"extern" { X;return EXTERN; }
|
---|
231 | <QT_DEF>"inline" { X;return INLINE; }
|
---|
232 | <QT_DEF>"__inline__" { X;return INLINE; }
|
---|
233 | <QT_DEF>"virtual" { X;return VIRTUAL; }
|
---|
234 | <QT_DEF>"const" { X;return CONST; }
|
---|
235 | <QT_DEF>"volatile" { X;return VOLATILE; }
|
---|
236 | <QT_DEF>"char" { X;return CHAR; }
|
---|
237 | <QT_DEF>"short" { X;return SHORT; }
|
---|
238 | <QT_DEF>"int" { X;return INT; }
|
---|
239 | <QT_DEF>"long" { X;return LONG; }
|
---|
240 | <QT_DEF>"signed" { X;return SIGNED; }
|
---|
241 | <QT_DEF>"unsigned" { X;return UNSIGNED; }
|
---|
242 | <QT_DEF>"float" { X;return FLOAT; }
|
---|
243 | <QT_DEF>"double" { X;return DOUBLE; }
|
---|
244 | <QT_DEF>"void" { X;return VOID; }
|
---|
245 | <QT_DEF>"enum" { X;return ENUM; }
|
---|
246 | <QT_DEF>"class" { X;return CLASS; }
|
---|
247 | <QT_DEF>"struct" { X;return STRUCT; }
|
---|
248 | <QT_DEF>"union" { X;return UNION; }
|
---|
249 | <QT_DEF>"asm" { X;return ASM; }
|
---|
250 | <QT_DEF>"private" { X;return PRIVATE; }
|
---|
251 | <QT_DEF>"protected" { X;return PROTECTED; }
|
---|
252 | <QT_DEF>"public" { X;return PUBLIC; }
|
---|
253 | <QT_DEF>"operator" { X;return OPERATOR; }
|
---|
254 | <QT_DEF>"::" { X;return DBL_COLON; }
|
---|
255 | <QT_DEF>"..." { X;return TRIPLE_DOT; }
|
---|
256 | <QT_DEF>"template" { X;return TEMPLATE; }
|
---|
257 | <QT_DEF>"mutable" { X;return MUTABLE; }
|
---|
258 | <QT_DEF>"throw" { X;return THROW; }
|
---|
259 | <QT_DEF>"using" { X;return USING; }
|
---|
260 | <QT_DEF>"namespace" { X;return NAMESPACE; }
|
---|
261 |
|
---|
262 | <QT_DEF>[_a-zA-Z][_a-zA-Z0-9]* {
|
---|
263 | X;
|
---|
264 | yylval.string = qstrdup(yytext);
|
---|
265 | return IDENTIFIER;
|
---|
266 | }
|
---|
267 |
|
---|
268 | <IN_PROPERTY>[_a-zA-Z][_a-zA-Z0-9]* {
|
---|
269 | X;
|
---|
270 | yylval.string = qstrdup(yytext);
|
---|
271 | return IDENTIFIER;
|
---|
272 | }
|
---|
273 |
|
---|
274 | <IN_CLASSINFO>"(" { X; return '('; }
|
---|
275 | <IN_CLASSINFO>")" { X; return ')'; }
|
---|
276 | <IN_CLASSINFO>"," { X; return ','; }
|
---|
277 |
|
---|
278 | <IN_CLASSINFO>{ALMOSTSTRING} {
|
---|
279 | X;
|
---|
280 | yylval.string = qstrdup( yytext + 1 );
|
---|
281 | input(); /* discard the '"' */
|
---|
282 | return STRING;
|
---|
283 | }
|
---|
284 |
|
---|
285 | <OUTSIDE>[_a-zA-Z][_a-zA-Z0-9]* ;
|
---|
286 | <IN_CLASS>[_a-zA-Z][_a-zA-Z0-9]* ;
|
---|
287 | <IN_NAMESPACE>[_a-zA-Z][_a-zA-Z0-9]* ;
|
---|
288 |
|
---|
289 | <OUTSIDE>{STRING} { /* discard strings */
|
---|
290 | Z;
|
---|
291 | }
|
---|
292 |
|
---|
293 | <IN_CLASS>{STRING} { /* discard strings */
|
---|
294 | Z;
|
---|
295 | }
|
---|
296 |
|
---|
297 | <IN_NAMESPACE>{STRING} { /* discard strings */
|
---|
298 | Z;
|
---|
299 | }
|
---|
300 |
|
---|
301 | <IN_FCT>{ALMOSTSTRING} { /* discard strings */
|
---|
302 | Z;
|
---|
303 | addExpressionString( yytext );
|
---|
304 | input(); /* discard the '"' */
|
---|
305 | }
|
---|
306 |
|
---|
307 |
|
---|
308 | <IN_TEMPL_ARGS>{ALMOSTSTRING} {
|
---|
309 | X;
|
---|
310 | addExpressionString( yytext );
|
---|
311 | input(); /* discard the '"' */
|
---|
312 | return STRING;
|
---|
313 | }
|
---|
314 |
|
---|
315 | <QT_DEF>{ALMOSTSTRING} {
|
---|
316 | X;
|
---|
317 | yylval.string = qstrdup( yytext + 1 );
|
---|
318 | input(); /* discard the '"' */
|
---|
319 | return STRING;
|
---|
320 | }
|
---|
321 |
|
---|
322 | <QT_DEF>'.' { X;
|
---|
323 | yylval.char_val = yytext[1];
|
---|
324 | return CHAR_VAL;
|
---|
325 | }
|
---|
326 |
|
---|
327 | <QT_DEF>'\\a' { X;
|
---|
328 | yylval.char_val = '\a';
|
---|
329 | return CHAR_VAL;
|
---|
330 | }
|
---|
331 |
|
---|
332 | <QT_DEF>'\\b' { X;
|
---|
333 | yylval.char_val = '\b';
|
---|
334 | return CHAR_VAL;
|
---|
335 | }
|
---|
336 |
|
---|
337 | <QT_DEF>'\\f' { X;
|
---|
338 | yylval.char_val = '\f';
|
---|
339 | return CHAR_VAL;
|
---|
340 | }
|
---|
341 |
|
---|
342 | <QT_DEF>'\\n' { X;
|
---|
343 | yylval.char_val = '\n';
|
---|
344 | return CHAR_VAL;
|
---|
345 | }
|
---|
346 |
|
---|
347 | <QT_DEF>'\\r' { X;
|
---|
348 | yylval.char_val = '\r';
|
---|
349 | return CHAR_VAL;
|
---|
350 | }
|
---|
351 |
|
---|
352 | <QT_DEF>'\\t' { X;
|
---|
353 | yylval.char_val = '\t';
|
---|
354 | return CHAR_VAL;
|
---|
355 | }
|
---|
356 |
|
---|
357 | <QT_DEF>'\\v' { X;
|
---|
358 | yylval.char_val = '\v';
|
---|
359 | return CHAR_VAL;
|
---|
360 | }
|
---|
361 |
|
---|
362 | <QT_DEF>'\\\\' { X;
|
---|
363 | yylval.char_val = '\\';
|
---|
364 | return CHAR_VAL;
|
---|
365 | }
|
---|
366 |
|
---|
367 | <QT_DEF>'\\?' { X;
|
---|
368 | yylval.char_val = '\?';
|
---|
369 | return CHAR_VAL;
|
---|
370 | }
|
---|
371 |
|
---|
372 | <QT_DEF>'\\'' { X;
|
---|
373 | yylval.char_val = '\'';
|
---|
374 | return CHAR_VAL;
|
---|
375 | }
|
---|
376 |
|
---|
377 | <QT_DEF>'\\\"' { X;
|
---|
378 | yylval.char_val = '\"'; /* " */
|
---|
379 | return CHAR_VAL;
|
---|
380 | }
|
---|
381 |
|
---|
382 | <QT_DEF>'\\0' { X;
|
---|
383 | yylval.char_val = '\0';
|
---|
384 | return CHAR_VAL;
|
---|
385 | }
|
---|
386 |
|
---|
387 | <QT_DEF>'\\[0-7]+' { X;
|
---|
388 | yylval.char_val =
|
---|
389 | (char)strtol( &yytext[1], 0, 8 );
|
---|
390 | return CHAR_VAL;
|
---|
391 | }
|
---|
392 |
|
---|
393 | <QT_DEF>'\\x[0-9a-fA-F]+' { X;
|
---|
394 | yylval.char_val =
|
---|
395 | (char)strtol( &yytext[2], 0, 16 );
|
---|
396 | return CHAR_VAL;
|
---|
397 | }
|
---|
398 |
|
---|
399 | <QT_DEF>'\\.' { X;
|
---|
400 | yylval.char_val = ' ';
|
---|
401 | return CHAR_VAL;
|
---|
402 | }
|
---|
403 |
|
---|
404 | <QT_DEF>[0-9]+ { X;
|
---|
405 | yylval.int_val = atoi(yytext);
|
---|
406 | return INT_VAL;
|
---|
407 | }
|
---|
408 |
|
---|
409 | <QT_DEF>[0-9]+\.[0-9]* { X;
|
---|
410 | yylval.double_val = atof(yytext);
|
---|
411 | return DOUBLE_VAL;
|
---|
412 | }
|
---|
413 |
|
---|
414 | <QT_DEF>\.[0-9]+ { X;
|
---|
415 | yylval.double_val = atof(yytext);
|
---|
416 | return DOUBLE_VAL;
|
---|
417 | }
|
---|
418 |
|
---|
419 |
|
---|
420 | ^#define.*\\$ { /* skip multi-line macro-definitions */
|
---|
421 | int c, c1;
|
---|
422 | input(); /* Discard the '\n'. */
|
---|
423 | do {
|
---|
424 | c1=' ';
|
---|
425 | while((c = linput()) != '\n' && c != 0) c1=c;
|
---|
426 | if (c == 0) break;
|
---|
427 | } while(c1=='\\');
|
---|
428 | unput(c); /* put back the '\n' or the EOF */
|
---|
429 | }
|
---|
430 |
|
---|
431 | ^[ \t]*#.* { /* preprocessor commands are skipped */}
|
---|
432 | "//"[^\n]* { /* C++ comment */
|
---|
433 | QCString s = yytext;
|
---|
434 | if ( s.contains( "MOC_SKIP_BEGIN" ) ) {
|
---|
435 | skipLevel++;
|
---|
436 | if ( skipLevel == 1 ) {
|
---|
437 | lastState = YYSTATE;
|
---|
438 | BEGIN SKIP;
|
---|
439 | }
|
---|
440 | } else
|
---|
441 | if ( s.contains( "MOC_SKIP_END" ) ) {
|
---|
442 | if ( skipLevel == 0 ) {
|
---|
443 | moc_warn(" MOC_SKIP_END without MOC_SKIP_BEGIN");
|
---|
444 | } else {
|
---|
445 | skipLevel--;
|
---|
446 | if ( skipLevel == 0 ) {
|
---|
447 | BEGIN lastState;
|
---|
448 | }
|
---|
449 | }
|
---|
450 | }
|
---|
451 | }
|
---|
452 | "/*" { /* C comment */
|
---|
453 | int c = ' ';
|
---|
454 | do {
|
---|
455 | if ( c!= '*' ) {
|
---|
456 | while((c = linput()) != '*' && c != 0)
|
---|
457 | ;
|
---|
458 | }
|
---|
459 | if (c == 0) break;
|
---|
460 | } while(((c = linput())) != '/' && c != 0);
|
---|
461 | if (c == 0)
|
---|
462 | unput(c);
|
---|
463 | }
|
---|
464 |
|
---|
465 | <IN_TEMPL_ARGS>. { addExpressionChar( yytext[0] ); }
|
---|
466 |
|
---|
467 | <IN_TEMPL_ARGS>[ \t\r\b\f]+ {
|
---|
468 | /* spaces are important in template args,
|
---|
469 | e.g. Foo<const int> */
|
---|
470 | addExpressionChar( yytext[0] ); }
|
---|
471 | [ \t\r\b\f]+ ;
|
---|
472 | <IN_CLASS>. ;
|
---|
473 | <IN_NAMESPACE>. ;
|
---|
474 | <IN_FCT>. ;
|
---|
475 | <IN_EXPR>. { addExpressionChar( yytext[0] ); }
|
---|
476 | <IN_DEF_ARG>. ;
|
---|
477 | <IN_ENUM>. { addExpressionChar( yytext[0] ); }
|
---|
478 | <OUTSIDE>. ;
|
---|
479 | <SKIP>. ;
|
---|
480 | <QT_DEF>. {
|
---|
481 | X;
|
---|
482 | return yytext[0];
|
---|
483 | }
|
---|
484 | <GIMME_SEMICOLON>. {
|
---|
485 | X;
|
---|
486 | return ';';
|
---|
487 | }
|
---|
488 | \n {
|
---|
489 | lineNo++;
|
---|
490 | }
|
---|
491 |
|
---|
492 |
|
---|
493 | %%
|
---|
494 |
|
---|
495 | #endif // MOC_YACC_CODE
|
---|