@@ -34,24 +34,24 @@ toValue (name, tipe, desc) =
3434docParse :: String -> Either String (String, [(String, String, String)])
3535docParse = setupParser $ do
3636 optional freshLine
37− (names, exports) <- option (["Main"],[]) (moduleDef `followedBy` freshLine)
38− info <- many (docs exports <|> try skip <|> end)
37+ (names, exports) <- option (["Main"],[]) moduleDef
38+ info <- many (annotation exports <|> try skip <|> end)
3939 return (intercalate "." names, catMaybes info)
4040 where
4141 skip = manyTill anyChar simpleNewline >> return Nothing
4242 end = many1 anyChar >> return Nothing
4343
44−docs :: [String] -> IParser (Maybe (String, String, String))
45−docs exports = export <$> try annotation
44+annotation :: [String] -> IParser (Maybe (String, String, String))
45+annotation exports =
46+ try ((\c n t -> export (n,t,c)) <$> comment <*> name <*> tipe)
4647 where
47− tipe comment = tuple <$> name <*> tipe
48− where name = do v <- lowVar <|> parens symOp
49− whitespace ; hasType ; whitespace ; return v
50− tipe = manyTill anyChar (try (freshLine >> notFollowedBy (string " ")))
51− tuple n t = (n,t,comment)
48+ comment = concatMap clip <$> many lineComment
49+ clip str = case str of { ' ':rest -> rest ; _ -> str } ++ "\n"
5250
53− annotation = tipe =<< option "" (concatMap clip <$> many1 lineComment)
54− where clip str = case str of { ' ':rest -> rest ; _ -> str } ++ "\n"
51+ name = do v <- lowVar <|> parens symOp
52+ whitespace ; hasType ; whitespace ; return v
53+
54+ tipe = manyTill anyChar (try (simpleNewline >> notFollowedBy (string " ")))
5555
5656 export info@(name,_,_) =
5757 if null exports || name `elem` exports then Just info else Nothing