2module Parse.Module (moduleDef, getModuleName, imports) where
4import Control.Applicative ((<$>), (<*>))
5import Data.List (intercalate)
6import Text.Parsec hiding (newline,spaces)
9import SourceSyntax.Module (Module(..), ImportMethod(..), Imports)
11varList :: IParser [String]
12varList = parens $ commaSep1 (var <|> parens symOp)
14getModuleName :: String -> Maybe String
16 case iParse getModuleName source of
17 Right name -> Just name
22 (names, _) <- moduleDef
23 return (intercalate "." names)
25moduleDef :: IParser ([String], [String])
27 try (reserved "module")
29 names <- dotSep1 capVar <?> "name of module"
31 exports <- option [] varList
32 whitespace <?> "reserved word 'where'"
34 return (names, exports)
36imports :: IParser Imports
37imports = option [] ((:) <$> import' <*> many (try (freshLine >> import')))
39import' :: IParser (String, ImportMethod)
43 open <- optionMaybe (reserved "open")
45 name <- intercalate "." <$> dotSep1 capVar
47 Just _ -> return (name, Hiding [])
48 Nothing -> let how = try (whitespace >> (as' <|> importing'))
49 in (,) name <$> option (As name) how
51 as' :: IParser ImportMethod
52 as' = reserved "as" >> whitespace >> As <$> capVar <?> "alias for module"
54 importing' :: IParser ImportMethod
55 importing' = Importing <$> varList <?> "listing of imported values (x,y,z)"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list