From 33024f3130ebfb54fb41383205111a9e5f97280e Mon Sep 17 00:00:00 2001 From: hallgren Date: Fri, 17 Jan 2014 13:58:48 +0000 Subject: [PATCH] haskell-bind: change the type of CRuntimeFFI.getConcr Change the type of getConcr from getConcr :: PGF -> Language -> Concr to getConcr :: PGF -> Language -> Maybe Concr This is to prevent programs from crashing later if you try to select a concrete syntax that is not present in a grammar. --- src/runtime/haskell-bind/CRuntimeFFI.hsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/haskell-bind/CRuntimeFFI.hsc b/src/runtime/haskell-bind/CRuntimeFFI.hsc index f1ee62db5..7554170ed 100644 --- a/src/runtime/haskell-bind/CRuntimeFFI.hsc +++ b/src/runtime/haskell-bind/CRuntimeFFI.hsc @@ -72,11 +72,11 @@ readPGF filepath = return PGF {pgfPool = pool, pgf = pgf} -getConcr :: PGF -> Language -> Concr +getConcr :: PGF -> Language -> Maybe Concr getConcr p (CId lang) = unsafePerformIO $ BS.useAsCString lang $ \lng -> do cnc <- pgf_get_language (pgf p) lng - return (Concr cnc p) + return (if cnc==nullPtr then Nothing else Just (Concr cnc p))