From: Duncan C. <dun...@us...> - 2004-12-08 00:08:46
|
Update of /cvsroot/gtk2hs/gtk2hs/tools/c2hs/chs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16252/tools/c2hs/chs Modified Files: CHS.hs Log Message: Apply a couple of patches that we had in our old c2hs tree to our new one. This makes c2hs understand hierarchical module names and fixes the handling of typedef'ed C types. Also make GConfValue.chs & GConfClient.chs work with our new c2hs. It's not entirely obvious to me if this is an improvement in c2hs or a regression. Index: CHS.hs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/tools/c2hs/chs/CHS.hs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CHS.hs 21 Nov 2004 21:05:35 -0000 1.1 +++ CHS.hs 8 Dec 2004 00:08:20 -0000 1.2 @@ -755,14 +755,32 @@ parseImport pos toks = do (qual, modid, toks') <- case toks of - CHSTokIdent _ ide :toks -> return (False, ide, toks) - CHSTokQualif _: CHSTokIdent _ ide:toks -> return (True , ide, toks) + CHSTokIdent _ ide :toks -> + let (ide', toks') = rebuildModuleId ide toks + in return (False, ide', toks') + CHSTokQualif _: CHSTokIdent _ ide:toks -> + let (ide', toks') = rebuildModuleId ide toks + in return (True , ide', toks') _ -> syntaxError toks - chi <- loadCHI . identToLexeme $ modid + chi <- loadCHI . moduleNameToFileName . identToLexeme $ modid toks'' <- parseEndHook toks' frags <- parseFrags toks'' return $ CHSHook (CHSImport qual modid chi pos) : frags +-- Qualified module names do not get lexed as a single token so we need to +-- reconstruct it from a sequence of identifer and dot tokens. +-- +rebuildModuleId ide (CHSTokDot _ : CHSTokIdent _ ide' : toks) = + let catIdent ide ide' = onlyPosIdent (posOf ide) --FIXME: unpleasent hack + (identToLexeme ide ++ '.' : identToLexeme ide') + in rebuildModuleId (catIdent ide ide') toks +rebuildModuleId ide toks = (ide, toks) + +moduleNameToFileName :: String -> FilePath +moduleNameToFileName = map dotToSlash + where dotToSlash '.' = '/' + dotToSlash c = c + parseContext :: Position -> [CHSToken] -> CST s [CHSFrag] parseContext pos toks = do (olib , toks'' ) <- parseOptLib toks |