OSDN Git Service

2003-07-30 Chris Demetriou <cgd@broadcom.com>
[pf3gnuchains/gcc-fork.git] / gcc / gengtype-lex.l
index 4f81a68..ad70ba8 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- indented-text -*- */
 /* Process source files and output type information.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -20,36 +20,37 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
 %{
+#include "bconfig.h"
+#include "coretypes.h"
+#include "system.h"
+
 #define malloc xmalloc
 #define realloc xrealloc
 
-#include "hconfig.h"
-#include "system.h"
-#include <ctype.h>
 #include "gengtype.h"
 #include "gengtype-yacc.h"
 
-static void update_lineno PARAMS ((const char *l, size_t len));
+#undef YY_USE_PROTOS
+#define YY_DECL int yylex ()
+
+static void update_lineno (const char *l, size_t len);
 
 struct fileloc lexer_line;
 int lexer_toplevel_done;
 
 static void 
-update_lineno (l, len)
-     const char *l;
-     size_t len;
+update_lineno (const char *l, size_t len)
 {
   while (len-- > 0)
     if (*l++ == '\n')
       lexer_line.line++;
 }
 
-#define IDchar(c) (isalnum(c) || (c) == '_')
 %}
 
-ID     [[:alpha:]][[:alnum:]_]*
+ID     [[:alpha:]_][[:alnum:]_]*
 WS     [[:space:]]+
-IWORD  short|long|(un)?signed|char|int|HOST_WIDE_INT|bool|size_t
+IWORD  short|long|(un)?signed|char|int|HOST_WIDE_INT|bool|size_t|CHAR_BITFIELD
 ITYPE  {IWORD}({WS}{IWORD})*
 
 %x in_struct in_struct_comment in_comment in_yacc_escape
@@ -67,20 +68,20 @@ ITYPE       {IWORD}({WS}{IWORD})*
   int union_p;
 
   tagstart = yytext + strlen (" typedef ");
-  while (isspace (*tagstart))
+  while (ISSPACE (*tagstart))
     tagstart++;
   union_p = tagstart[0] == 'u';
   tagstart += strlen ("union ");
-  while (isspace (*tagstart))
+  while (ISSPACE (*tagstart))
     tagstart++;
-  for (taglen = 1; IDchar (tagstart[taglen]); taglen++)
+  for (taglen = 1; ISIDNUM (tagstart[taglen]); taglen++)
     ;
   for (namestart = tagstart + taglen; 
-       ! IDchar (*namestart);
+       ! ISIDNUM (*namestart);
        namestart++)
     if (*namestart == '*')
       is_pointer = 1;
-  for (namelen = 1; IDchar (namestart[namelen]); namelen++)
+  for (namelen = 1; ISIDNUM (namestart[namelen]); namelen++)
     ;
   t = find_structure (xmemdup (tagstart, taglen, taglen+1), union_p);
   if (is_pointer)
@@ -97,17 +98,17 @@ ITYPE       {IWORD}({WS}{IWORD})*
   char *typestart;
   size_t typelen;
 
-  for (namestart = yytext + yyleng - 2; isspace (*namestart); namestart--)
+  for (namestart = yytext + yyleng - 2; ISSPACE (*namestart); namestart--)
     ;
-  for (namelen = 1; !isspace (namestart[-namelen]); namelen++)
+  for (namelen = 1; !ISSPACE (namestart[-namelen]); namelen++)
     ;
   namestart -= namelen - 1;
   for (typestart = yytext + strlen (" typedef "); 
-       isspace(*typestart);
+       ISSPACE(*typestart);
        typestart++)
     ;
   for (typelen = namestart - typestart; 
-       isspace(typestart[typelen-1]); 
+       ISSPACE(typestart[typelen-1]); 
        typelen--)
     ;
 
@@ -121,9 +122,9 @@ ITYPE       {IWORD}({WS}{IWORD})*
   size_t namelen;
   struct type *t;
 
-  for (namestart = yytext + yyleng - 7; isspace (*namestart); namestart--)
+  for (namestart = yytext + yyleng - 7; ISSPACE (*namestart); namestart--)
     ;
-  for (namelen = 1; !isspace (namestart[-namelen]); namelen++)
+  for (namelen = 1; !ISSPACE (namestart[-namelen]); namelen++)
     ;
   namestart -= namelen - 1;
 
@@ -136,9 +137,9 @@ ITYPE       {IWORD}({WS}{IWORD})*
   size_t namelen;
   struct type *t;
 
-  for (namestart = yytext + yyleng - 7; !IDchar (*namestart); namestart--)
+  for (namestart = yytext + yyleng - 7; !ISIDNUM (*namestart); namestart--)
     ;
-  for (namelen = 1; IDchar (namestart[-namelen]); namelen++)
+  for (namelen = 1; ISIDNUM (namestart[-namelen]); namelen++)
     ;
   namestart -= namelen - 1;
 
@@ -156,7 +157,7 @@ ITYPE       {IWORD}({WS}{IWORD})*
   typedef_p = yytext[1] == 't';
   if (typedef_p)
     for (tagstart = yytext + strlen (" typedef "); 
-        isspace(*tagstart);
+        ISSPACE(*tagstart);
         tagstart++)
       ;
   else
@@ -164,9 +165,9 @@ ITYPE       {IWORD}({WS}{IWORD})*
 
   union_p = tagstart[0] == 'u';
   tagstart += strlen ("union ");
-  while (isspace (*tagstart))
+  while (ISSPACE (*tagstart))
     tagstart++;
-  for (taglen = 1; IDchar (tagstart[taglen]); taglen++)
+  for (taglen = 1; ISIDNUM (tagstart[taglen]); taglen++)
     ;
 
   yylval.t = find_structure (xmemdup (tagstart, taglen, taglen + 1), union_p);
@@ -202,14 +203,17 @@ ITYPE     {IWORD}({WS}{IWORD})*
 "struct"/[^[:alnum:]_]         { return STRUCT; }
 "enum"/[^[:alnum:]_]           { return ENUM; }
 "ptr_alias"/[^[:alnum:]_]      { return ALIAS; }
-"param_is"/[^[:alnum:]_]       { return PARAM_IS; }
 [0-9]+                         { return NUM; }
+"param"[0-9]*"_is"/[^[:alnum:]_]               { 
+  yylval.s = xmemdup (yytext, yyleng, yyleng+1);
+  return PARAM_IS;
+}
 
 {IWORD}({WS}{IWORD})*/[^[:alnum:]_]            |
 "ENUM_BITFIELD"{WS}?"("{WS}?{ID}{WS}?")"       {
   size_t len;
 
-  for (len = yyleng; isspace (yytext[len-1]); len--)
+  for (len = yyleng; ISSPACE (yytext[len-1]); len--)
     ;
 
   yylval.t = create_scalar_type (yytext, len);
@@ -285,7 +289,7 @@ ITYPE       {IWORD}({WS}{IWORD})*
 "%}"           { BEGIN(in_struct); }
 "%"            {
   error_at_line (&lexer_line, 
-                "unterminated %{; unexpected EOF");
+                "unterminated %%{; unexpected EOF");
 }
 }
 
@@ -299,15 +303,13 @@ ITYPE     {IWORD}({WS}{IWORD})*
 %%
 
 void
-yyerror (s)
-     const char *s;
+yyerror (const char *s)
 {
   error_at_line (&lexer_line, s);
 }
 
 void
-parse_file (fname)
-      char *fname;
+parse_file (const char *fname)
 {
   yyin = fopen (fname, "r");
   lexer_line.file = fname;