summaryrefslogtreecommitdiff
path: root/compiler/parser/Parser.y.pp
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2012-02-17 15:50:59 +0000
committerIan Lynagh <igloo@earth.li>2012-02-17 17:42:32 +0000
commit7b24c3fffecbf9fc219c10f24d1472d0d03da6a1 (patch)
tree8cee950382b90353ac6fb8eddb7795bed595a3f5 /compiler/parser/Parser.y.pp
parent5940bfd20dc9a6ca9b05b2c9743cdccd3cf45e4a (diff)
downloadhaskell-7b24c3fffecbf9fc219c10f24d1472d0d03da6a1.tar.gz
Allow a header to be specified in a CTYPE pragma
You can now say data {-# CTYPE "some_header.h" "the C type" #-} Foo = ... I think it's rare that this will actually be needed. If the header for a CAPI FFI import includes a void f(ctype x); prototype then ctype must already be defined. However, if the header only has #define f(p) p->j then the type need not be defined. But either way, it seems good practice for us to specify the header that we need.
Diffstat (limited to 'compiler/parser/Parser.y.pp')
-rw-r--r--compiler/parser/Parser.y.pp5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp
index f29364a872..bb370978c4 100644
--- a/compiler/parser/Parser.y.pp
+++ b/compiler/parser/Parser.y.pp
@@ -741,8 +741,9 @@ tycl_hdr :: { Located (Maybe (LHsContext RdrName), LHsType RdrName) }
| type { L1 (Nothing, $1) }
capi_ctype :: { Maybe CType }
-capi_ctype : '{-# CTYPE' STRING '#-}' { Just (CType (getSTRING $2)) }
- | { Nothing }
+capi_ctype : '{-# CTYPE' STRING STRING '#-}' { Just (CType (Just (getSTRING $2)) (getSTRING $3)) }
+ | '{-# CTYPE' STRING '#-}' { Just (CType Nothing (getSTRING $2)) }
+ | { Nothing }
-----------------------------------------------------------------------------
-- Stand-alone deriving