2module Parse.Module (moduleDef, 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)
14moduleDef :: IParser ([String], [String])
16 try (reserved "module")
18 names <- dotSep1 capVar <?> "name of module"
20 exports <- option [] varList
21 whitespace <?> "reserved word 'where'"
23 return (names, exports)
25imports :: IParser Imports
26imports = option [] ((:) <$> import' <*> many (try (freshLine >> import')))
28import' :: IParser (String, ImportMethod)
32 open <- optionMaybe (reserved "open")
34 name <- intercalate "." <$> dotSep1 capVar
36 Just _ -> return (name, Hiding [])
37 Nothing -> let how = try (whitespace >> (as' <|> importing'))
38 in (,) name <$> option (Importing []) how
40 as' :: IParser ImportMethod
41 as' = reserved "as" >> whitespace >> As <$> capVar <?> "alias for module"
43 importing' :: IParser ImportMethod
44 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