Restored work-around for hangs when trying to use disk-based handlers
[tangerine.git] / tools / cxref / parse.l
blob9a9e29aa8a642aa1c8df7c717e92fa955828629d
1 W                       [ \t]
2 N                       (\r*\n)
3 D                       [0-9]
4 S                       [-+]
5 L                       [a-zA-Z_$]
6 H                       [a-fA-F0-9]
7 E                       [Ee]{S}?{D}+
8 FS                      (f|F|l|L)
9 IS                      ((u|U|l|L)+|([iI]8|[iI]16|[iI]32|[iI]64))
11 %x START_COMMENT     COMMENT     SPECIAL_COMMENT
12 %x START_COMMENT_CPP COMMENT_CPP SPECIAL_COMMENT_CPP
13 %x CPP CPP_START
14 %x CPP_INCLUDE CPP_INC_FILE CPP_INC_FLAGS
15 %x CPP_DEFINE CPP_DEFINE_ARGP CPP_DEFINE_BODY CPP_DEFINE_ARGS
16 %x GNU_LABEL GNU_VA_ARG GNU_ATTRIBUTE GNU_TYPEOF
17 %x CHAR_VARYING
20 /***************************************
21   $Header$
23   C Cross Referencing & Documentation tool. Version 1.5f.
25   C lexical analyser
26   CPP processing, including GNU extensions, using yylval as a string.
27   ******************/ /******************
28   Written by Andrew M. Bishop
30   This file Copyright 1995,96,97,98,99,2000,01,02,03,04 Andrew M. Bishop
31   It may be distributed under the GNU Public License, version 2, or
32   any higher version.  See section COPYING of the GNU Public license
33   for conditions under which this file may be redistributed.
34   ***************************************/
36 #include <string.h>
37 #include <unistd.h>
39 #include "parse-yy.h"
40 #include "parse-yacc.h"
41 #include "cxref.h"
42 #include "memory.h"
44 /*+ The name of the current file. +*/
45 char* parse_file=NULL;
47 /*+ The current line number in the file. +*/
48 int parse_line=0;
51 /*+ If we are in a header file then ignore the comments. +*/
52 extern int in_header;
54 /*+ One of the options controlling how comments are processed, +*/
55 extern int option_all_comments,       /*+ use all comments not just the specially formattted ones. +*/
56            option_block_comments,     /*+ remove the leading block comment marker. +*/
57            option_no_comments;        /*+ ignore all comments. +*/
59 /*+ Flag that indicates if the comment warnings are to be issued. +*/
60 extern int option_warn;
63 /*+ The flags that come out of GCC when a file is included. +*/
64 static int inc_file_flags=0;
66 /*+ The name of a file seen in a CPP_INC_FILE state. +*/
67 static char *inc_file=NULL;
69 /*+ The value of the thing that is defined (but only if it is simple). +*/
70 static char* define_value=NULL;
72 /*+ The lex state at the time that a comment is seen. +*/
73 static int comment_init_state=0;
75 /*+ To get around the GCC __builtin_va_arg keyword, skip over matched () counted by this. +*/
76 static int gnu_va_arg_depth=0;
78 /*+ To get around the GCC __attribute__ keyword, skip over matched () counted by this. +*/
79 static int gnu_att_depth=0;
81 /*+ To get around the GCC __typeof__ keyword, skip over matched () counted by this. +*/
82 static int gnu_typ_depth=0;
84 /*+ If we see a comment immediately after a ',', ';', '};', '},' or ')' then push it before. +*/
85 static int push_past=0;
92  /* Comments, could be embedded in a preprocessor directive. */
94 <INITIAL>"/*"                     { comment_init_state = INITIAL        ; BEGIN(START_COMMENT); }
95 <CPP_START>"/*"                   { comment_init_state = CPP_START      ; BEGIN(START_COMMENT); }
96 <CPP>"/*"                         { comment_init_state = CPP            ; BEGIN(START_COMMENT); }
97 <CPP_DEFINE>"/*"                  { comment_init_state = CPP_DEFINE     ; BEGIN(START_COMMENT); }
98 <CPP_INCLUDE>"/*"                 { comment_init_state = CPP_INCLUDE    ; BEGIN(START_COMMENT); }
99 <CPP_DEFINE_ARGP>"/*"             { comment_init_state = CPP_DEFINE_ARGP; BEGIN(START_COMMENT); }
100 <CPP_DEFINE_ARGS>"/*"             { comment_init_state = CPP_DEFINE_ARGS; BEGIN(START_COMMENT); }
101 <CPP_DEFINE_BODY>"/*"             { comment_init_state = CPP_DEFINE_BODY; BEGIN(START_COMMENT); }
102 <CPP_INC_FILE>"/*"                { comment_init_state = CPP_INC_FILE   ; BEGIN(START_COMMENT); }
103 <CPP_INC_FLAGS>"/*"               { comment_init_state = CPP_INC_FLAGS  ; BEGIN(START_COMMENT); }
105 <INITIAL>"//"                     { comment_init_state = INITIAL        ; BEGIN(START_COMMENT_CPP); }
106 <CPP_START>"//"                   { comment_init_state = CPP_START      ; BEGIN(START_COMMENT_CPP); }
107 <CPP>"//"                         { comment_init_state = CPP            ; BEGIN(START_COMMENT_CPP); }
108 <CPP_DEFINE>"//"                  { comment_init_state = CPP_DEFINE     ; BEGIN(START_COMMENT_CPP); }
109 <CPP_INCLUDE>"//"                 { comment_init_state = CPP_INCLUDE    ; BEGIN(START_COMMENT_CPP); }
110 <CPP_DEFINE_ARGP>"//"             { comment_init_state = CPP_DEFINE_ARGP; BEGIN(START_COMMENT_CPP); }
111 <CPP_DEFINE_ARGS>"//"             { comment_init_state = CPP_DEFINE_ARGS; BEGIN(START_COMMENT_CPP); }
112 <CPP_DEFINE_BODY>"//"             { comment_init_state = CPP_DEFINE_BODY; BEGIN(START_COMMENT_CPP); }
113 <CPP_INC_FILE>"//"                { comment_init_state = CPP_INC_FILE   ; BEGIN(START_COMMENT_CPP); }
114 <CPP_INC_FLAGS>"//"               { comment_init_state = CPP_INC_FLAGS  ; BEGIN(START_COMMENT_CPP); }
116  /* Check for special or normal C style comments. */
118 <START_COMMENT>"*"+               { BEGIN(SPECIAL_COMMENT); }
119 <START_COMMENT>"+"+               { BEGIN(SPECIAL_COMMENT); }
120 <START_COMMENT>[*+ \t]*"*/"       { BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
121 <START_COMMENT>{N}                { if(option_all_comments) SeenComment(yytext,0); parse_line++;
122                                     if(option_all_comments) BEGIN(SPECIAL_COMMENT); else BEGIN(COMMENT); }
123 <START_COMMENT>[^*+]              { if(option_all_comments) SeenComment(yytext,0);
124                                     if(option_all_comments) BEGIN(SPECIAL_COMMENT); else BEGIN(COMMENT); }
126  /* Check for special or normal C++ style comments. */
128 <START_COMMENT_CPP>"*"+           { BEGIN(SPECIAL_COMMENT_CPP); }
129 <START_COMMENT_CPP>"+"+           { BEGIN(SPECIAL_COMMENT_CPP); }
130 <START_COMMENT_CPP>{N}            { BEGIN(comment_init_state); unput('\n'); while(push_past) {push_past--;unput(yylval[push_past]);} }
131 <START_COMMENT_CPP>[^*+]          { if(option_all_comments) BEGIN(SPECIAL_COMMENT_CPP); else BEGIN(COMMENT_CPP); }
133 <COMMENT>{N}                      { parse_line++; }
134 <COMMENT>.                        { }
135 <COMMENT>[+*]+/"*/"               { if(option_warn&WARN_COMMENT) fprintf(stderr,"%s:%d: Warning unbalanced cxref comment; starts simple, ends special.\n",parse_file,parse_line); }
136 <COMMENT>"*/"                     { BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
138 <COMMENT_CPP>{N}                  { BEGIN(comment_init_state); unput('\n'); while(push_past) {push_past--;unput(yylval[push_past]);} }
139 <COMMENT_CPP>.*                   { /* Found EOF before newline! */ }
141  /* Handle special C style comments. */
143 <SPECIAL_COMMENT>{N}                { if(!option_no_comments) SeenComment(yytext,0); parse_line++; }
144  /* The following three lines are optimised for run-time speed.
145     They replace the following pattern which has variable trailing context:
146     <SPECIAL_COMMENT>{N}{W}*[+*|:]/({W}|{N})
147  */
148 <SPECIAL_COMMENT>{N}{W}*[+*|:]/{W}  { parse_line++;
149                                       if(option_block_comments) yytext[0]='\n',yytext[1]=0;
150                                       if(!option_no_comments) SeenComment(yytext,0); }
151 <SPECIAL_COMMENT>{N}{W}*[+*|:]/\n   { parse_line++;
152                                       if(option_block_comments) yytext[0]='\n',yytext[1]=0;
153                                       if(!option_no_comments) SeenComment(yytext,0); }
154 <SPECIAL_COMMENT>{N}{W}*[+*|:]/\r\n { parse_line++;
155                                       if(option_block_comments) yytext[0]='\n',yytext[1]=0;
156                                       if(!option_no_comments) SeenComment(yytext,0); }
157 <SPECIAL_COMMENT>[^\r\n*+]+         { if(!option_no_comments) SeenComment(yytext,0); }
158 <SPECIAL_COMMENT>.                  { if(!option_no_comments) SeenComment(yytext,0); }
160 <SPECIAL_COMMENT>{W}*"*"+"*/"       { if(!option_no_comments) SeenComment(NULL,1);
161                                       BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
162 <SPECIAL_COMMENT>{W}*"+"+"*/"       { if(!option_no_comments) SeenComment(NULL,2);
163                                       if(!in_header && comment_init_state==CPP_DEFINE_ARGS) SeenDefineFuncArgComment();
164                                       if(!in_header && comment_init_state==CPP_DEFINE_BODY) SeenDefineComment();
165                                       if(!in_header && comment_init_state==CPP_INCLUDE)     SeenIncludeComment();
166                                       BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
167 <SPECIAL_COMMENT>"*/"               { if(!option_all_comments && option_warn&WARN_COMMENT)
168                                          fprintf(stderr,"%s:%d: Warning unbalanced cxref comment; starts special, ends simple.\n",parse_file,parse_line);
169                                       if(option_all_comments) SeenComment(NULL,3); else if(!option_no_comments) SeenComment(NULL,2);
170                                       if(!in_header && comment_init_state==CPP_DEFINE_ARGS) SeenDefineFuncArgComment();
171                                       if(!in_header && comment_init_state==CPP_DEFINE_BODY) SeenDefineComment();
172                                       if(!in_header && comment_init_state==CPP_INCLUDE)     SeenIncludeComment();
173                                       BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
175  /* Handle special C++ style comments. */
177 <SPECIAL_COMMENT_CPP>[^\r\n]+     { if(!option_no_comments) SeenComment(yytext,0); }
178 <SPECIAL_COMMENT_CPP>.            { if(!option_no_comments) SeenComment(yytext,0); }
179 <SPECIAL_COMMENT_CPP>{W}*{N}      { if(!option_no_comments) SeenComment(NULL,2);
180                                     if(!in_header && comment_init_state==CPP_DEFINE_ARGS) SeenDefineFuncArgComment();
181                                     if(!in_header && comment_init_state==CPP_DEFINE_BODY) SeenDefineComment();
182                                     if(!in_header && comment_init_state==CPP_INCLUDE)     SeenIncludeComment();
183                                     BEGIN(comment_init_state); unput('\n'); while(push_past) {push_past--;unput(yylval[push_past]);} }
185  /* Preprocessor directives, only valid at the top level. */
187 #{W}*                           { BEGIN(CPP_START); }
189 <CPP_START>{D}+{W}+             { parse_line=atoi(yytext); BEGIN(CPP_INC_FILE);}
190 <CPP_START>define{W}+           { BEGIN(CPP_DEFINE); }
191 <CPP_START>include{W}+          { BEGIN(CPP_INCLUDE); }
192 <CPP_START>[a-z]+               { BEGIN(CPP); }
193 <CPP_START>.|\n                 { BEGIN(INITIAL); /* Ignore bad pre-processor output */ }
195  /* Preprocessor directives not #define or #include. */
197 <CPP>.                          { }
198 <CPP>\\{N}                      { parse_line++; }
199 <CPP>{N}                        { parse_line++; BEGIN(INITIAL); }
201  /* Preprocessor directive #define. */
203 <CPP_DEFINE>{L}({L}|{D})*                   { if(!in_header) SeenDefine(yytext); BEGIN(CPP_DEFINE_ARGP); }
204 <CPP_DEFINE>\\{N}                           { parse_line++; }
205 <CPP_DEFINE>{W}+                            { }
206 <CPP_DEFINE>.|\n                            { BEGIN(INITIAL); /* Ignore bad pre-processor output */ }
208 <CPP_DEFINE_ARGP>"("                        { BEGIN(CPP_DEFINE_ARGS); }
209 <CPP_DEFINE_ARGP>{N}                        { parse_line++; BEGIN(INITIAL); }
210 <CPP_DEFINE_ARGP>[^\r\n(]                   { define_value=NULL; BEGIN(CPP_DEFINE_BODY); }
211 <CPP_DEFINE_ARGP>\\{N}                      { parse_line++; }
212 <CPP_DEFINE_ARGP>.                          { BEGIN(INITIAL); /* Ignore bad pre-processor output */ }
214 <CPP_DEFINE_ARGS>{L}({L}|{D})*              { if(!in_header) SeenDefineFunctionArg(yytext); }
215 <CPP_DEFINE_ARGS>{L}({L}|{D})*"..."         { if(!in_header) SeenDefineFunctionArg(yytext); }
216 <CPP_DEFINE_ARGS>"..."                      { if(!in_header) SeenDefineFunctionArg(yytext); }
217 <CPP_DEFINE_ARGS>","                        { }
218 <CPP_DEFINE_ARGS>{W}+                       { }
219 <CPP_DEFINE_ARGS>\\{N}                      { parse_line++; }
220 <CPP_DEFINE_ARGS>")"                        { define_value=(char*)1; BEGIN(CPP_DEFINE_BODY); }
221 <CPP_DEFINE_ARGS>.|\n                       { BEGIN(INITIAL); /* Ignore bad pre-processor output */ }
223 <CPP_DEFINE_BODY>{L}({L}|{D})*              { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
224 <CPP_DEFINE_BODY>0[xX]{H}+{IS}?             { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
225 <CPP_DEFINE_BODY>0{D}+{IS}?                 { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
226 <CPP_DEFINE_BODY>{S}?{D}+{IS}?              { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
227 <CPP_DEFINE_BODY>{S}?{D}+{E}{FS}?           { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
228 <CPP_DEFINE_BODY>{S}?{D}*"."{D}+({E})?{FS}? { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
229 <CPP_DEFINE_BODY>{S}?{D}+"."{D}*({E})?{FS}? { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
230 <CPP_DEFINE_BODY>\'(\\.|[^'\r\n])*\'        { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
231 <CPP_DEFINE_BODY>\"(\\.|[^"\r\n])*\"        { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
232 <CPP_DEFINE_BODY>.                          { }
233 <CPP_DEFINE_BODY>\\{N}                      { parse_line++; }
234 <CPP_DEFINE_BODY>{N}                        { parse_line++; if(define_value>(char*)1) SeenDefineValue(define_value); BEGIN(INITIAL); }
236  /* Preprocessor directive #include. */
238 <CPP_INCLUDE>[<"][^>"]+[>"]     { SeenInclude(yytext); }
239 <CPP_INCLUDE>.                  { }
240 <CPP_INCLUDE>\\{N}              { parse_line++; }
241 <CPP_INCLUDE>{N}                { parse_line++; BEGIN(INITIAL); }
243 <CPP_INC_FILE>"\""[^"]+"\""     { inc_file=CopyString(yytext+1); inc_file[strlen(inc_file)-1]=0;
244                                   inc_file_flags=0;
245                                   if(!parse_file) inc_file_flags=-1;
246                                   if(!parse_file) parse_file=inc_file;
247                                   GetCurrentComment();
248                                   BEGIN(CPP_INC_FLAGS); }
249 <CPP_INC_FILE>.|\n              { BEGIN(INITIAL); /* Ignore bad pre-processor output */ }
251 <CPP_INC_FLAGS>{W}+{D}+         { inc_file_flags+=1<<atoi(yytext); }
252 <CPP_INC_FLAGS>{W}*{N}          { if(inc_file_flags&6 || inc_file_flags==-1 || *inc_file=='<')
253                                      parse_file=SeenFileChange(inc_file,inc_file_flags);
254                                   BEGIN(INITIAL); }
255 <CPP_INC_FLAGS>.                { BEGIN(INITIAL); /* Ignore bad pre-processor output */ }
257  /* GNU C strangeness. */
259 ("__alignof"|"__alignof__")        { yylval="alignof"  ; return(SIZEOF);   }
261 ("__signed"|"__signed__")          { yylval="signed"   ; return(SIGNED);   }
262 ("__unsigned"|"__unsigned__")      { yylval="unsigned" ; return(UNSIGNED); }
264 ("__volatile"|"__volatile__")      { yylval="volatile" ; return(VOLATILE); }
265 ("__const"|"__const__")            { yylval="const"    ; return(CONST);    }
267 ("__inline"|"__inline__")          { yylval="inline"   ; return(INLINE);   }
269 ("asm"|"__asm"|"__asm__")          { yylval="asm"      ; return(ASM);      }
271 "__label__"                        { BEGIN(GNU_LABEL); }
272 <GNU_LABEL>[^;]+                   { }
273 <GNU_LABEL>";"                     { BEGIN(INITIAL); }
275 "__builtin_va_arg"                 { gnu_va_arg_depth=0; BEGIN(GNU_VA_ARG); yylval="__builtin_va_arg"; return(IDENTIFIER); }
276 <GNU_VA_ARG>"("                    { gnu_va_arg_depth++; if(gnu_va_arg_depth==1) { yylval="("; return('('); } }
277 <GNU_VA_ARG>[^()]+                 { }
278 <GNU_VA_ARG>")"                    { if(--gnu_va_arg_depth==0) { BEGIN(INITIAL); yylval=")"; return(')'); } }
280 ("__attribute"|"__attribute__")    { gnu_att_depth=0; BEGIN(GNU_ATTRIBUTE); }
281 <GNU_ATTRIBUTE>"("                 { gnu_att_depth++; }
282 <GNU_ATTRIBUTE>[^()]+              { }
283 <GNU_ATTRIBUTE>")"                 { if(--gnu_att_depth==0) BEGIN(INITIAL); }
285 ("typeof"|"__typeof"|"__typeof__") { gnu_typ_depth=0; BEGIN(GNU_TYPEOF); }
286 <GNU_TYPEOF>"("                    { gnu_typ_depth++; }
287 <GNU_TYPEOF>[^()]+                 { }
288 <GNU_TYPEOF>")"                    { if(--gnu_typ_depth==0) {BEGIN(INITIAL); yylval="typeof"; return(TYPE_NAME);} }
290 "__extension__"                    { }
292 ("__restrict"|"__restrict__")      { }
294 "__FUNCTION__"                     { yylval="__FUNCTION__"; return(STRING_LITERAL); }
296 "__builtin_va_list"                { yylval="__builtin_va_list" ; return(TYPE_NAME); }
298  /* VOS char_varying type */
300 "char_varying"{W}*"("{W}*{D}+{W}*")" { yylval=CopyString(yytext); BEGIN(CHAR_VARYING); return(CHAR); }
301 <CHAR_VARYING>.|\n                   { unput(*yytext); yylval=""; BEGIN(INITIAL); return('*'); }
303  /* C language keywords. */
305 "auto"                  { yylval="auto"    ; return(AUTO);     }
306 "break"                 { yylval="break"   ; return(BREAK);    }
307 "case"                  { yylval="case"    ; return(CASE);     }
308 "char"                  { yylval="char"    ; return(CHAR);     }
309 "const"                 { yylval="const"   ; return(CONST);    }
310 "continue"              { yylval="continue"; return(CONTINUE); }
311 "default"               { yylval="default" ; return(DEFAULT);  }
312 "do"                    { yylval="do"      ; return(DO);       }
313 "double"                { yylval="double"  ; return(DOUBLE);   }
314 "else"                  { yylval="else"    ; return(ELSE);     }
315 "enum"                  { yylval="enum"    ; return(ENUM);     }
316 "extern"                { yylval="extern"  ; return(EXTERN);   }
317 "float"                 { yylval="float"   ; return(FLOAT);    }
318 "for"                   { yylval="for"     ; return(FOR);      }
319 "goto"                  { yylval="goto"    ; return(GOTO);     }
320 "if"                    { yylval="if"      ; return(IF);       }
321 "int"                   { yylval="int"     ; return(INT);      }
322 "inline"                { yylval="inline"  ; return(INLINE);   }
323 "long"                  { yylval="long"    ; return(LONG);     }
324 "register"              { yylval="register"; return(REGISTER); }
325 "return"                { yylval="return"  ; return(RETURN);   }
326 "short"                 { yylval="short"   ; return(SHORT);    }
327 "signed"                { yylval="signed"  ; return(SIGNED);   }
328 "sizeof"                { yylval="sizeof"  ; return(SIZEOF);   }
329 "static"                { yylval="static"  ; return(STATIC);   }
330 "struct"                { yylval="struct"  ; return(STRUCT);   }
331 "switch"                { yylval="switch"  ; return(SWITCH);   }
332 "typedef"               { yylval="typedef" ; return(TYPEDEF);  }
333 "union"                 { yylval="union"   ; return(UNION);    }
334 "unsigned"              { yylval="unsigned"; return(UNSIGNED); }
335 "void"                  { yylval="void"    ; return(VOID);     }
336 "volatile"              { yylval="volatile"; return(VOLATILE); }
337 "while"                 { yylval="while"   ; return(WHILE);    }
339  /* C language operators. */
341 "..."                   { yylval="...";  return(ELLIPSES);     }
342 ">>="                   { yylval=">>=";  return(RIGHT_ASSIGN); }
343 "<<="                   { yylval="<<=";  return(LEFT_ASSIGN);  }
344 "+="                    { yylval="+=";   return(ADD_ASSIGN); }
345 "-="                    { yylval="-=";   return(SUB_ASSIGN); }
346 "*="                    { yylval="*=";   return(MUL_ASSIGN); }
347 "/="                    { yylval="/=";   return(DIV_ASSIGN); }
348 "%="                    { yylval="%=";   return(MOD_ASSIGN); }
349 "&="                    { yylval="&=";   return(AND_ASSIGN); }
350 "^="                    { yylval="^=";   return(XOR_ASSIGN); }
351 "|="                    { yylval="|=";   return(OR_ASSIGN);  }
352 ">>"                    { yylval=">>";   return(RIGHT_SHIFT);}
353 "<<"                    { yylval="<<";   return(LEFT_SHIFT); }
354 "++"                    { yylval="++";   return(INC_OP); }
355 "--"                    { yylval="--";   return(DEC_OP); }
356 "->"                    { yylval="->";   return(PTR_OP); }
357 "&&"                    { yylval="&&";   return(AND_OP); }
358 "||"                    { yylval="||";   return(OR_OP); }
359 "<="                    { yylval="<=";   return(LE_OP); }
360 ">="                    { yylval=">=";   return(GE_OP); }
361 "=="                    { yylval="==";   return(EQ_OP); }
362 "!="                    { yylval="!=";   return(NE_OP); }
363 ";"{W}*("/*"|"//")      { yylval="; ";   push_past=2;
364                           comment_init_state=INITIAL; BEGIN(yytext[strlen(yytext)-1]=='*'?START_COMMENT:START_COMMENT_CPP); }
365 ";"                     { yylval=";";    return(';'); }
366 "{"                     { yylval="{";    return('{'); }
367 "};"{W}*("/*"|"//")     { yylval="}; ";  push_past=3;
368                           comment_init_state=INITIAL; BEGIN(yytext[strlen(yytext)-1]=='*'?START_COMMENT:START_COMMENT_CPP); }
369 "},"{W}*("/*"|"//")     { yylval="}, ";  push_past=3;
370                           comment_init_state=INITIAL; BEGIN(yytext[strlen(yytext)-1]=='*'?START_COMMENT:START_COMMENT_CPP); }
371 "}"                     { yylval="}";    return('}'); }
372 ","{W}*("/*"|"//")      { yylval=", ";   push_past=2;
373                           comment_init_state=INITIAL; BEGIN(yytext[strlen(yytext)-1]=='*'?START_COMMENT:START_COMMENT_CPP); }
374 ","                     { yylval=",";    return(','); }
375 ":"                     { yylval=":";    return(':'); }
376 "="                     { yylval="=";    return('='); }
377 "("                     { yylval="(";    return('('); }
378 ")"{W}*("/*"|"//")      { yylval=") ";   push_past=2;
379                           comment_init_state=INITIAL; BEGIN(yytext[strlen(yytext)-1]=='*'?START_COMMENT:START_COMMENT_CPP); }
380 ")"                     { yylval=")";    return(')'); }
381 "["                     { yylval="[";    return('['); }
382 "]"                     { yylval="]";    return(']'); }
383 "."                     { yylval=".";    return('.'); }
384 "&"                     { yylval="&";    return('&'); }
385 "!"                     { yylval="!";    return('!'); }
386 "~"                     { yylval="~";    return('~'); }
387 "-"                     { yylval="-";    return('-'); }
388 "+"                     { yylval="+";    return('+'); }
389 "*"                     { yylval="*";    return('*'); }
390 "/"                     { yylval="/";    return('/'); }
391 "%"                     { yylval="%";    return('%'); }
392 "<"                     { yylval="<";    return('<'); }
393 ">"                     { yylval=">";    return('>'); }
394 "^"                     { yylval="^";    return('^'); }
395 "|"                     { yylval="|";    return('|'); }
396 "?"                     { yylval="?";    return('?'); }
398  /* Variable / Function / Type names */
400 {L}({L}|{D})*           {
401                           yylval=CopyString(yytext);
402                           if(IsAScopeVariable(yytext))
403                              return(IDENTIFIER);
404                           else
405                              if(IsATypeName(yytext))
406                                 return(TYPE_NAME);
407                              else
408                                 return(IDENTIFIER);
409                         }
411  /* Literals */
413 0[xX]{H}+{IS}?                { yylval=CopyString(yytext); return(LITERAL); }
414 0[xX]{H}+"."{H}?[pP]{D}+{FS}? { yylval=CopyString(yytext); return(LITERAL); }
415 0{D}+{IS}?                    { yylval=CopyString(yytext); return(LITERAL); } 
416 {D}+{IS}?                     { yylval=CopyString(yytext); return(LITERAL); }
417 '(\\.|[^\\'])+'               { yylval=CopyString(yytext); return(LITERAL); }
418 "L"'(\\.|[^\\'])+'            { yylval=CopyString(yytext); return(LITERAL); }
420 {D}+{E}{FS}?                  { yylval=CopyString(yytext); return(LITERAL); }
421 {D}*"."{D}+({E})?{FS}?        { yylval=CopyString(yytext); return(LITERAL); }
422 {D}+"."{D}*({E})?{FS}?        { yylval=CopyString(yytext); return(LITERAL); }
424 \"(\\.|[^\\"])*\"             { yylval=CopyString(yytext); return(STRING_LITERAL); }
425 "L"\"(\\.|[^\\"])*\"          { yylval=CopyString(yytext); return(STRING_LITERAL); }
427  /* Other text. */
429 {N}                     { parse_line++; }
430 .                       { /* Ignore bad characters */ }
434 /*++++++++++++++++++++++++++++++++++++++
435   Reset the Lexer, ready for the next file.
436   ++++++++++++++++++++++++++++++++++++++*/
438 void ResetLexer(void)
440  parse_file=NULL;
441  parse_line=0;
442  inc_file_flags=0;
443  inc_file=NULL;
444  define_value=NULL;
445  comment_init_state=INITIAL;
446  gnu_va_arg_depth=0;
447  gnu_att_depth=0;
448  gnu_typ_depth=0;
449  push_past=0;
450  BEGIN(INITIAL);