Patch the lexer to ignore _Pragma().

This commit is contained in:
dholland 2011-10-13 22:11:26 +00:00
parent abf757a85d
commit 8d8599d24d
2 changed files with 38 additions and 1 deletions

View file

@ -1,6 +1,7 @@
$NetBSD: distinfo,v 1.8 2011/10/13 21:30:00 dholland Exp $
$NetBSD: distinfo,v 1.9 2011/10/13 22:11:26 dholland Exp $
SHA1 (cxref-1.6d.tgz) = b984d85da7b7fa39794932e6fe85a0657f6240bb
RMD160 (cxref-1.6d.tgz) = 3760f2f074ec26b6702efbd38f24f0bb231488e0
Size (cxref-1.6d.tgz) = 415744 bytes
SHA1 (patch-aa) = 0696dc7e2c027ebbbfb6747ff36ec9f9a36b7a88
SHA1 (patch-src_parse_l) = 38638d7ac187ddebec2fb446f38adaace3ef3712

View file

@ -0,0 +1,36 @@
$NetBSD: patch-src_parse_l,v 1.1 2011/10/13 22:11:26 dholland Exp $
Recognize and ignore _Pragma(), needed for -current's headers.
--- src/parse.l~ 2011-06-18 09:45:04.000000000 +0000
+++ src/parse.l
@@ -14,6 +14,7 @@ IS ((u|U|l|L)+|([iI
%x CPP_INCLUDE CPP_INC_FILE CPP_INC_FLAGS
%x CPP_DEFINE CPP_DEFINE_ARGP CPP_DEFINE_BODY CPP_DEFINE_ARGS
%x GNU_LABEL GNU_VA_ARG GNU_ATTRIBUTE GNU_TYPEOF GNU_OFFSETOF
+%x C99_PRAGMA
%{
/***************************************
@@ -83,6 +84,9 @@ static int gnu_typ_depth=0;
/*+ To get around the GCC __offsetof keyword, skip over matched () counted by this. +*/
static int gnu_offset_depth=0;
+/*+ To get around the C99 _Pragma keyword, skip over matched () counted by this. +*/
+static int c99_prag_depth=0;
+
/*+ If we see a comment immediately after a ',', ';', '};', '},' or ')' then push it before. +*/
static int push_past=0;
@@ -311,6 +315,11 @@ static int push_past=0;
"_Complex" { }
"_Bool" { yylval="_Bool"; return(BOOL); }
+("_Pragma") { c99_prag_depth=0; BEGIN(C99_PRAGMA); }
+<C99_PRAGMA>"(" { c99_prag_depth++; }
+<C99_PRAGMA>[^()]+ { }
+<C99_PRAGMA>")" { if(--c99_prag_depth==0) { BEGIN(INITIAL); } }
+
/* C language keywords. */
"auto" { yylval="auto" ; return(AUTO); }