This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gengtype]: Allow #define in a struct
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Geoffrey Keating <geoffk at apple dot com>
- Date: Fri, 08 Oct 2004 16:27:43 +0100
- Subject: [gengtype]: Allow #define in a struct
- Organization: Codesourcery LLC
hi,
I want to put a #define inside a struct, but that causes gengtype's parser
to barf. Is this the right way to do it? I couldn't figure out how
cpp commands were dealt with outside of a struct. Whilst there I added
some commented } and ) characters to keep emacs's paren matching code
happy.
built & tested on i686-pc-linuc-gnu, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2004-10-08 Nathan Sidwell <nathan@codesourcery.com>
* gengtype-lex.l: Add commented } & ) characters to unconfuse
editor's paren matching. Allow #define inside a struct.
Index: gengtype-lex.l
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype-lex.l,v
retrieving revision 1.26
diff -c -3 -p -r1.26 gengtype-lex.l
*** gengtype-lex.l 25 Jul 2004 22:17:02 -0000 1.26
--- gengtype-lex.l 8 Oct 2004 10:37:52 -0000
*************** ITYPE {IWORD}({WS}{IWORD})*
*** 270,276 ****
"/*" { BEGIN(in_struct_comment); }
! ^"%{" { BEGIN(in_yacc_escape); }
^"@@".* /* Used for c-parse.in C/ObjC demarcation. */
--- 270,276 ----
"/*" { BEGIN(in_struct_comment); }
! ^"%{" { BEGIN(in_yacc_escape); } /* } */
^"@@".* /* Used for c-parse.in C/ObjC demarcation. */
*************** ITYPE {IWORD}({WS}{IWORD})*
*** 307,313 ****
char *ptr = yytext;
macro = ptr;
! while (*ptr != '(' && !ISSPACE (*ptr))
ptr++;
macro_len = ptr - macro;
while (*ptr == '(' || ISSPACE (*ptr))
--- 307,313 ----
char *ptr = yytext;
macro = ptr;
! while (*ptr != '(' && !ISSPACE (*ptr)) /* )*/
ptr++;
macro_len = ptr - macro;
while (*ptr == '(' || ISSPACE (*ptr))
*************** ITYPE {IWORD}({WS}{IWORD})*
*** 361,366 ****
--- 361,368 ----
return PERCENTPERCENT;
}
+ "#define"[^\n]*\n {lexer_line.line++;}
+
. {
error_at_line (&lexer_line, "unexpected character `%s'", yytext);
}