home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Amiga / Programmation / c / Docs / cxref-1.4a.lha / parse.l < prev    next >
Encoding:
Text File  |  1997-12-07  |  21.1 KB  |  425 lines

  1. W                       [ \t]
  2. N                       \r*\n
  3. D                       [0-9]
  4. L                       [a-zA-Z_]
  5. H                       [a-fA-F0-9]
  6. E                       [Ee][+-]?{D}+
  7. FS                      (f|F|l|L)
  8. IS                      (u|U|l|L)*
  9.  
  10. %x START_COMMENT     COMMENT     SPECIAL_COMMENT
  11. %x START_COMMENT_CPP COMMENT_CPP SPECIAL_COMMENT_CPP
  12. %x CPP CPP_START
  13. %x CPP_INCLUDE CPP_INC_FILE CPP_INC_FLAGS
  14. %x CPP_DEFINE CPP_DEFINE_ARGP CPP_DEFINE_BODY CPP_DEFINE_ARGS
  15. %x GNU_LABEL GNU_ATTRIBUTE GNU_EXTENSION GNU_TYPEOF
  16.  
  17. %{
  18. /***************************************
  19.   $Header: /home/amb/cxref/RCS/parse.l 1.23 1997/11/20 19:57:40 amb Exp $
  20.  
  21.   C Cross Referencing & Documentation tool. Version 1.4a.
  22.  
  23.   C lexical analyser
  24.   CPP processing, including GNU extensions, using yylval as a string.
  25.   ******************/ /******************
  26.   Written by Andrew M. Bishop
  27.  
  28.   This file Copyright 1995,96,97 Andrew M. Bishop
  29.   It may be distributed under the GNU Public License, version 2, or
  30.   any higher version.  See section COPYING of the GNU Public license
  31.   for conditions under which this file may be redistributed.
  32.   ***************************************/
  33.  
  34. #include "parse-yy.h"
  35. #include "parse-yacc.h"
  36. #include "cxref.h"
  37. #include "memory.h"
  38.  
  39. /*+ The name of the current file. +*/
  40. char* parse_file=NULL;
  41.  
  42. /*+ The current line number in the file. +*/
  43. int parse_line=0;
  44.  
  45.  
  46. /*+ If we are in a header file then ignore the comments. +*/
  47. extern int in_header;
  48.  
  49. /*+ One of the options controlling how comments are processed, +*/
  50. extern int option_all_comments,       /*+ use all comments not just the specially formattted ones. +*/
  51.            option_block_comments,     /*+ remove the leading block comment marker. +*/
  52.            option_no_comments;        /*+ ignore all comments. +*/
  53.  
  54. /*+ Flag that indicates if the comment warnings are to be issued. +*/
  55. extern int option_warn;
  56.  
  57.  
  58. /*+ The flags that come out of GCC when a file is included. +*/
  59. static int inc_file_flags=0;
  60.  
  61. /*+ The value of the thing that is defined (but only if it is simple). +*/
  62. static char* define_value=NULL;
  63.  
  64. /*+ The lex state at the time that a comment is seen. +*/
  65. static int comment_init_state=INITIAL;
  66.  
  67. /*+ To get around the GCC __attribute__ keyword, skip over matched () counted by this. +*/
  68. static int gnu_att_depth=0;
  69.  
  70. /*+ To get around the GCC __typeof__ keyword, skip over matched () counted by this. +*/
  71. static int gnu_typ_depth=0;
  72.  
  73. /*+ If we see a comment immediately after a ',', ';', '};', '},' or ')' then push it before. +*/
  74. static int push_past=0;
  75.  
  76.  
  77. /*++++++++++++++++++++++++++++++++++++++
  78.   Reset the Lexer, ready for the next file.
  79.   ++++++++++++++++++++++++++++++++++++++*/
  80.  
  81. void ResetLexer(void)
  82. {
  83.  parse_file=NULL;
  84.  parse_line=0;
  85.  inc_file_flags=0;
  86.  define_value=NULL;
  87.  comment_init_state=INITIAL;
  88.  gnu_att_depth=0;
  89.  gnu_typ_depth=0;
  90.  push_past=0;
  91.  
  92.  SeenComment((char*)3);
  93. }
  94.  
  95. %}
  96.  
  97. %%
  98.  
  99.  /* Comments, could be embedded in a preprocessor directive. */
  100.  
  101. <INITIAL>("/*"|"//")              { comment_init_state = INITIAL        ; BEGIN(yytext[1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  102. <CPP_START>("/*"|"//")            { comment_init_state = CPP_START      ; BEGIN(yytext[1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  103. <CPP>("/*"|"//")                  { comment_init_state = CPP            ; BEGIN(yytext[1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  104. <CPP_DEFINE>("/*"|"//")           { comment_init_state = CPP_DEFINE     ; BEGIN(yytext[1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  105. <CPP_INCLUDE>("/*"|"//")          { comment_init_state = CPP_INCLUDE    ; BEGIN(yytext[1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  106. <CPP_DEFINE_ARGP>("/*"|"//")      { comment_init_state = CPP_DEFINE_ARGP; BEGIN(yytext[1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  107. <CPP_DEFINE_ARGS>("/*"|"//")      { comment_init_state = CPP_DEFINE_ARGS; BEGIN(yytext[1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  108. <CPP_DEFINE_BODY>("/*"|"//")      { comment_init_state = CPP_DEFINE_BODY; BEGIN(yytext[1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  109. <CPP_INC_FILE>("/*"|"//")         { comment_init_state = CPP_INC_FILE   ; BEGIN(yytext[1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  110. <CPP_INC_FLAGS>("/*"|"//")        { comment_init_state = CPP_INC_FLAGS  ; BEGIN(yytext[1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  111.  
  112. <START_COMMENT>"*"+               { BEGIN(SPECIAL_COMMENT); }
  113. <START_COMMENT>"+"+               { BEGIN(SPECIAL_COMMENT); }
  114. <START_COMMENT>[*+ \t]*"*/"       { BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
  115. <START_COMMENT>{N}                { if(option_all_comments) SeenComment(yytext); parse_line++;
  116.                                     if(option_all_comments) BEGIN(SPECIAL_COMMENT); else BEGIN(COMMENT); }
  117. <START_COMMENT>[^*+]              { if(option_all_comments) SeenComment(yytext);
  118.                                     if(option_all_comments) BEGIN(SPECIAL_COMMENT); else BEGIN(COMMENT); }
  119.  
  120. <START_COMMENT_CPP>"*"+           { BEGIN(SPECIAL_COMMENT_CPP); }
  121. <START_COMMENT_CPP>"+"+           { BEGIN(SPECIAL_COMMENT_CPP); }
  122. <START_COMMENT_CPP>{N}            { if(comment_init_state==CPP_INCLUDE || comment_init_state==CPP_DEFINE) comment_init_state=INITIAL;
  123.                                     parse_line++; BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
  124. <START_COMMENT_CPP>[^*+]          { if(option_all_comments) BEGIN(SPECIAL_COMMENT_CPP); else BEGIN(COMMENT_CPP); }
  125.  
  126. <COMMENT>{N}                      { parse_line++; }
  127. <COMMENT>.                        { }
  128. <COMMENT>[+*]+/"*/"               { if(option_warn&COMMENT) fprintf(stderr,"%s:%d: Warning unbalanced cxref comment; starts simple, ends special.\n",parse_file,parse_line); }
  129. <COMMENT>"*/"                     { BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
  130.  
  131. <COMMENT_CPP>.*{N}                { if(comment_init_state==CPP_INCLUDE || comment_init_state==CPP_DEFINE) comment_init_state=INITIAL;
  132.                                     parse_line++; BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
  133.  
  134. <SPECIAL_COMMENT>{N}              { if(!option_no_comments) SeenComment(yytext); parse_line++; }
  135. <SPECIAL_COMMENT>{N}{W}*[+*|:]/({W}|{N}) { parse_line++;
  136.                                     if(option_block_comments) yytext[0]='\n',yytext[1]=0;
  137.                                     if(!option_no_comments) SeenComment(yytext); }
  138. <SPECIAL_COMMENT>[^\r\n*+]+       { if(!option_no_comments) SeenComment(yytext); }
  139. <SPECIAL_COMMENT>.                { if(!option_no_comments) SeenComment(yytext); }
  140.  
  141. <SPECIAL_COMMENT>{W}*"*"+"*/"     { if(!option_no_comments) SeenComment((char*)0);
  142.                                     BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
  143. <SPECIAL_COMMENT>{W}*"+"+"*/"     { if(!option_no_comments) SeenComment((char*)1);
  144.                                     if(!in_header && comment_init_state==CPP_DEFINE_ARGS) SeenDefineFuncArgComment();
  145.                                     if(!in_header && comment_init_state==CPP_DEFINE_BODY) SeenDefineComment();
  146.                                     if(!in_header && comment_init_state==CPP_INCLUDE)     SeenIncludeComment();
  147.                                     BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
  148. <SPECIAL_COMMENT>"*/"             { if(!option_all_comments && option_warn&COMMENT)
  149.                                        fprintf(stderr,"%s:%d: Warning unbalanced cxref comment; starts special, ends simple.\n",parse_file,parse_line);
  150.                                     if(option_all_comments) SeenComment((char*)2); else if(!option_no_comments) SeenComment((char*)1);
  151.                                     if(!in_header && comment_init_state==CPP_DEFINE_ARGS) SeenDefineFuncArgComment();
  152.                                     if(!in_header && comment_init_state==CPP_DEFINE_BODY) SeenDefineComment();
  153.                                     if(!in_header && comment_init_state==CPP_INCLUDE)     SeenIncludeComment();
  154.                                     BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
  155.  
  156. <SPECIAL_COMMENT_CPP>[^\r\n]+     { if(!option_no_comments) SeenComment(yytext); }
  157. <SPECIAL_COMMENT_CPP>.            { if(!option_no_comments) SeenComment(yytext); }
  158. <SPECIAL_COMMENT_CPP>{W}*{N}      { if(!option_no_comments) SeenComment((char*)1);
  159.                                     if(!in_header && comment_init_state==CPP_DEFINE_ARGS) SeenDefineFuncArgComment();
  160.                                     if(!in_header && comment_init_state==CPP_DEFINE_BODY) SeenDefineComment();
  161.                                     if(!in_header && comment_init_state==CPP_INCLUDE)     SeenIncludeComment();
  162.                                     if(comment_init_state==CPP_INCLUDE || comment_init_state==CPP_DEFINE) comment_init_state=INITIAL;
  163.                                     parse_line++; BEGIN(comment_init_state); while(push_past) {push_past--;unput(yylval[push_past]);} }
  164.  
  165.  /* Preprocessor directives, only valid at the top level. */
  166.  
  167. #{W}*                           { BEGIN(CPP_START); }
  168.  
  169. <CPP_START>{D}+{W}+             { parse_line=atoi(yytext); BEGIN(CPP_INC_FILE);}
  170. <CPP_START>define{W}+           { BEGIN(CPP_DEFINE); }
  171. <CPP_START>include{W}+          { BEGIN(CPP_INCLUDE); }
  172. <CPP_START>[a-z]+               { BEGIN(CPP); }
  173.  
  174. <CPP>.                          { }
  175. <CPP>\\{N}                      { parse_line++; }
  176. <CPP>{N}                        { parse_line++; BEGIN(INITIAL); }
  177.  
  178. <CPP_DEFINE>{L}({L}|{D})*       { if(!in_header) SeenDefine(yytext); BEGIN(CPP_DEFINE_ARGP); }
  179. <CPP_DEFINE>\\{N}               { parse_line++; }
  180. <CPP_DEFINE>{W}+                { }
  181.  
  182. <CPP_DEFINE_ARGP>"("            { BEGIN(CPP_DEFINE_ARGS); }
  183. <CPP_DEFINE_ARGP>{N}            { parse_line++; BEGIN(INITIAL); }
  184. <CPP_DEFINE_ARGP>[^\r\n(]       { define_value=NULL; BEGIN(CPP_DEFINE_BODY); }
  185. <CPP_DEFINE_ARGP>\\{N}          { parse_line++; }
  186.  
  187. <CPP_DEFINE_ARGS>{L}({L}|{D})*       { if(!in_header) SeenDefineFunctionArg(yytext); }
  188. <CPP_DEFINE_ARGS>{L}({L}|{D})*"..."  { if(!in_header) SeenDefineFunctionArg(yytext); }
  189. <CPP_DEFINE_ARGS>","                 { }
  190. <CPP_DEFINE_ARGS>{W}+                { }
  191. <CPP_DEFINE_ARGS>\\{N}               { parse_line++; }
  192. <CPP_DEFINE_ARGS>")"                 { define_value=(char*)1; BEGIN(CPP_DEFINE_BODY); }
  193.  
  194. <CPP_DEFINE_BODY>{L}({L}|{D})*               { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
  195. <CPP_DEFINE_BODY>0[xX]{H}+{IS}?              { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
  196. <CPP_DEFINE_BODY>0{D}+{IS}?                  { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
  197. <CPP_DEFINE_BODY>{D}+{IS}?                   { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
  198. <CPP_DEFINE_BODY>{D}+{E}{FS}?                { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
  199. <CPP_DEFINE_BODY>{D}*"."{D}+({E})?{FS}?      { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
  200. <CPP_DEFINE_BODY>{D}+"."{D}*({E})?{FS}?      { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
  201. <CPP_DEFINE_BODY>\'(\\.|[^'\r\n])*\'         { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
  202. <CPP_DEFINE_BODY>\"(\\.|[^"\r\n])*\"         { if(!in_header) {if(!define_value) define_value=CopyString(yytext); else define_value=(char*)1;} }
  203. <CPP_DEFINE_BODY>.                           { }
  204. <CPP_DEFINE_BODY>\\{N}                       { parse_line++; }
  205. <CPP_DEFINE_BODY>{N}                         { parse_line++; if(define_value>(char*)1) SeenDefineValue(define_value); BEGIN(INITIAL); }
  206.  
  207. <CPP_INCLUDE>[<"][^>"]+[>"]     { SeenInclude(yytext); }
  208. <CPP_INCLUDE>.                  { }
  209. <CPP_INCLUDE>\\{N}              { parse_line++; }
  210. <CPP_INCLUDE>{N}                { parse_line++; BEGIN(INITIAL); }
  211.  
  212. <CPP_INC_FILE>"\""[^"]+"\""     { parse_file=CopyString(yytext+1); parse_file[strlen(parse_file)-1]=0;
  213.                                   SeenComment((char*)3);
  214.                                   inc_file_flags=0; BEGIN(CPP_INC_FLAGS); }
  215. <CPP_INC_FLAGS>{W}+{D}+         { inc_file_flags+=1<<atoi(yytext); }
  216. <CPP_INC_FLAGS>{W}*{N}          { if(inc_file_flags&6) SeenFileChange(parse_file,inc_file_flags);
  217.                                   BEGIN(INITIAL); }
  218.  
  219.  /* GNU C strangeness. */
  220.  
  221. "__alignof__"                  { yylval="alignof"  ; return(SIZEOF);   }
  222.  
  223. ("__signed"|"__signed__")      { yylval="signed"   ; return(SIGNED);   }
  224. ("__unsigned"|"__unsigned__")  { yylval="unsigned" ; return(UNSIGNED); }
  225.  
  226. ("__volatile"|"__volatile__")  { yylval="volatile" ; return(VOLATILE); }
  227. ("__const"|"__const__")        { yylval="const"    ; return(CONST);    }
  228.  
  229.  /* olsen: the following two clash with SAS/C keywords. */
  230.  
  231.  /* ("__inline"|"__inline__")      { yylval="inline"   ; return(INLINE);   } */
  232.  
  233.  /* ("asm"|"__asm"|"__asm__")      { yylval="asm"      ; return(ASM);      } */
  234.  
  235. ("__inline__")      { yylval="inline"   ; return(INLINE);   }
  236.  
  237. ("asm"|"__asm__")      { yylval="asm"      ; return(ASM);      }
  238.  
  239. "__label__"                { BEGIN(GNU_LABEL); }
  240. <GNU_LABEL>[^;]+           { }
  241. <GNU_LABEL>";"             { BEGIN(INITIAL); }
  242.  
  243. "__attribute__"            { gnu_att_depth=0; BEGIN(GNU_ATTRIBUTE); }
  244. <GNU_ATTRIBUTE>"("         { gnu_att_depth++; }
  245. <GNU_ATTRIBUTE>[^()]+      { }
  246. <GNU_ATTRIBUTE>")"         { if(--gnu_att_depth==0) BEGIN(INITIAL); }
  247.  
  248. "__typeof__"               { gnu_typ_depth=0; BEGIN(GNU_TYPEOF); }
  249. <GNU_TYPEOF>"("            { gnu_typ_depth++; }
  250. <GNU_TYPEOF>[^()]+         { }
  251. <GNU_TYPEOF>")"            { if(--gnu_typ_depth==0) {BEGIN(INITIAL); yylval="typeof"; return(TYPE_NAME);} }
  252.  
  253. "__extension__"            { }
  254.  
  255.  /* olsen: special SAS/C keywords */
  256.  
  257. "__a0"    { }
  258. "__a1"    { }
  259. "__a2"    { }
  260. "__a3"    { }
  261. "__a4"    { }
  262. "__a5"    { }
  263. "__a6"    { }
  264. "__a7"    { }
  265. "__actual"    { }
  266. "__aligned"    { }
  267. "__asm"    { }
  268. "__chip"    { }
  269. "__d0"    { }
  270. "__d1"    { }
  271. "__d2"    { }
  272. "__d3"    { }
  273. "__d4"    { }
  274. "__d5"    { }
  275. "__d6"    { }
  276. "__d7"    { }
  277. "__far"    { }
  278. "__fp0"    { }
  279. "__fp1"    { }
  280. "__fp2"    { }
  281. "__fp3"    { }
  282. "__fp4"    { }
  283. "__fp5"    { }
  284. "__fp6"    { }
  285. "__fp7"    { }
  286. "__inline"    { }
  287. "__interrupt"    { }
  288. "__near"    { }
  289. "__pascal"    { }
  290. "__ref"    { }
  291. "__regargs"    { }
  292. "__saveds"    { }
  293. "__stackext"    { }
  294. "__stdargs"    { }
  295.  
  296.  /* C language keywords. */
  297.  
  298. "auto"                  { yylval="auto"    ; return(AUTO);     }
  299. "break"                 { yylval="break"   ; return(BREAK);    }
  300. "case"                  { yylval="case"    ; return(CASE);     }
  301. "char"                  { yylval="char"    ; return(CHAR);     }
  302. "const"                 { yylval="const"   ; return(CONST);    }
  303. "continue"              { yylval="continue"; return(CONTINUE); }
  304. "default"               { yylval="default" ; return(DEFAULT);  }
  305. "do"                    { yylval="do"      ; return(DO);       }
  306. "double"                { yylval="double"  ; return(DOUBLE);   }
  307. "else"                  { yylval="else"    ; return(ELSE);     }
  308. "enum"                  { yylval="enum"    ; return(ENUM);     }
  309. "extern"                { yylval="extern"  ; return(EXTERN);   }
  310. "float"                 { yylval="float"   ; return(FLOAT);    }
  311. "for"                   { yylval="for"     ; return(FOR);      }
  312. "goto"                  { yylval="goto"    ; return(GOTO);     }
  313. "if"                    { yylval="if"      ; return(IF);       }
  314. "int"                   { yylval="int"     ; return(INT);      }
  315. "inline"                { yylval="inline"  ; return(INLINE);   }
  316. "long"                  { yylval="long"    ; return(LONG);     }
  317. "register"              { yylval="register"; return(REGISTER); }
  318. "return"                { yylval="return"  ; return(RETURN);   }
  319. "short"                 { yylval="short"   ; return(SHORT);    }
  320. "signed"                { yylval="signed"  ; return(SIGNED);   }
  321. "sizeof"                { yylval="sizeof"  ; return(SIZEOF);   }
  322. "static"                { yylval="static"  ; return(STATIC);   }
  323. "struct"                { yylval="struct"  ; return(STRUCT);   }
  324. "switch"                { yylval="switch"  ; return(SWITCH);   }
  325. "typedef"               { yylval="typedef" ; return(TYPEDEF);  }
  326. "union"                 { yylval="union"   ; return(UNION);    }
  327. "unsigned"              { yylval="unsigned"; return(UNSIGNED); }
  328. "void"                  { yylval="void"    ; return(VOID);     }
  329. "volatile"              { yylval="volatile"; return(VOLATILE); }
  330. "while"                 { yylval="while"   ; return(WHILE);    }
  331.  
  332.  /* C language operators. */
  333.  
  334. "..."                   { yylval="...";  return(ELLIPSES);     }
  335. ">>="                   { yylval=">>=";  return(RIGHT_ASSIGN); }
  336. "<<="                   { yylval="<<=";  return(LEFT_ASSIGN);  }
  337. "+="                    { yylval="+=";   return(ADD_ASSIGN); }
  338. "-="                    { yylval="-=";   return(SUB_ASSIGN); }
  339. "*="                    { yylval="*=";   return(MUL_ASSIGN); }
  340. "/="                    { yylval="/=";   return(DIV_ASSIGN); }
  341. "%="                    { yylval="%=";   return(MOD_ASSIGN); }
  342. "&="                    { yylval="&=";   return(AND_ASSIGN); }
  343. "^="                    { yylval="^=";   return(XOR_ASSIGN); }
  344. "|="                    { yylval="|=";   return(OR_ASSIGN);  }
  345. ">>"                    { yylval=">>";   return(RIGHT_SHIFT);}
  346. "<<"                    { yylval="<<";   return(LEFT_SHIFT); }
  347. "++"                    { yylval="++";   return(INC_OP); }
  348. "--"                    { yylval="--";   return(DEC_OP); }
  349. "->"                    { yylval="->";   return(PTR_OP); }
  350. "&&"                    { yylval="&&";   return(AND_OP); }
  351. "||"                    { yylval="||";   return(OR_OP); }
  352. "<="                    { yylval="<=";   return(LE_OP); }
  353. ">="                    { yylval=">=";   return(GE_OP); }
  354. "=="                    { yylval="==";   return(EQ_OP); }
  355. "!="                    { yylval="!=";   return(NE_OP); }
  356. ";"{W}*("/*"|"//")      { yylval="; ";   push_past=2;
  357.                           comment_init_state=INITIAL; BEGIN(yytext[strlen(yytext)-1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  358. ";"                     { yylval=";";    return(';'); }
  359. "{"                     { yylval="{";    return('{'); }
  360. "};"{W}*("/*"|"//")     { yylval="}; ";  push_past=3;
  361.                           comment_init_state=INITIAL; BEGIN(yytext[strlen(yytext)-1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  362. "},"{W}*("/*"|"//")     { yylval="}, ";  push_past=3;
  363.                           comment_init_state=INITIAL; BEGIN(yytext[strlen(yytext)-1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  364. "}"                     { yylval="}";    return('}'); }
  365. ","{W}*("/*"|"//")      { yylval=", ";   push_past=2;
  366.                           comment_init_state=INITIAL; BEGIN(yytext[strlen(yytext)-1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  367. ","                     { yylval=",";    return(','); }
  368. ":"                     { yylval=":";    return(':'); }
  369. "="                     { yylval="=";    return('='); }
  370. "("                     { yylval="(";    return('('); }
  371. ")"{W}*("/*"|"//")      { yylval=") ";   push_past=2;
  372.                           comment_init_state=INITIAL; BEGIN(yytext[strlen(yytext)-1]=='*'?START_COMMENT:START_COMMENT_CPP); }
  373. ")"                     { yylval=")";    return(')'); }
  374. "["                     { yylval="[";    return('['); }
  375. "]"                     { yylval="]";    return(']'); }
  376. "."                     { yylval=".";    return('.'); }
  377. "&"                     { yylval="&";    return('&'); }
  378. "!"                     { yylval="!";    return('!'); }
  379. "~"                     { yylval="~";    return('~'); }
  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.  
  391.  /* Variable / Function / Type names */
  392.  
  393. {L}({L}|{D})*           {
  394.                           yylval=CopyString(yytext);
  395.                           if(IsAScopeVariable(yytext))
  396.                              return(IDENTIFIER);
  397.                           else
  398.                              if(IsATypeName(yytext))
  399.                                 return(TYPE_NAME);
  400.                              else
  401.                                 return(IDENTIFIER);
  402.                         }
  403.  
  404.  /* Literals */
  405.  
  406. 0[xX]{H}+{IS}?          { yylval=CopyString(yytext); return(LITERAL); }
  407. 0{D}+{IS}?              { yylval=CopyString(yytext); return(LITERAL); } 
  408. {D}+{IS}?               { yylval=CopyString(yytext); return(LITERAL); }
  409. '(\\.|[^\\'])+'         { yylval=CopyString(yytext); return(LITERAL); }
  410. "L"'(\\.|[^\\'])+'      { yylval=CopyString(yytext); return(LITERAL); }
  411.  
  412. {D}+{E}{FS}?            { yylval=CopyString(yytext); return(LITERAL); }
  413. {D}*"."{D}+({E})?{FS}?  { yylval=CopyString(yytext); return(LITERAL); }
  414. {D}+"."{D}*({E})?{FS}?  { yylval=CopyString(yytext); return(LITERAL); }
  415.  
  416. \"(\\.|[^\\"])*\"       { yylval=CopyString(yytext); return(STRING_LITERAL); }
  417. "L"\"(\\.|[^\\"])*\"    { yylval=CopyString(yytext); return(STRING_LITERAL); }
  418.  
  419.  /* Other text. */
  420.  
  421. {N}                     { parse_line++; }
  422. .                       { /* Ignore bad characters */ }
  423.  
  424. %%
  425.