File tree Expand file tree Collapse file tree 4 files changed +12
-15
lines changed
src/Language/PureScript/Parser Expand file tree Collapse file tree 4 files changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ data Directive
2121 = Help
2222 | Quit
2323 | Reset
24- | Import
2524 | Browse
2625 | Load
2726 | Type
@@ -36,7 +35,6 @@ commands :: Directive -> [String]
3635commands Help = [" ?" , " help" ]
3736commands Quit = [" quit" ]
3837commands Reset = [" reset" ]
39- commands Import = [" import" ]
4038commands Browse = [" browse" ]
4139commands Load = [" load" , " module" ]
4240commands Type = [" type" ]
6664 [ (Help , " " , " Show this help menu" )
6765 , (Quit , " " , " Quit PSCi" )
6866 , (Reset , " " , " Reset" )
69- , (Import , " <module>" , " Import <module> for use in PSCI" )
7067 , (Browse , " <module>" , " Browse <module>" )
7168 , (Load , " <file>" , " Load <file> for importing" )
7269 , (Type , " <expr>" , " Show the type of <expr>" )
Original file line number Diff line number Diff line change @@ -227,7 +227,6 @@ completionContext (':' : cmd) word =
227227 dstr = takeWhile (not . isSpace) cmd
228228
229229 context :: D. Directive -> Maybe CompletionContext
230- context D. Import = Just Module
231230 context D. Browse = Just Module
232231 context D. Load = Just $ FilePath word
233232 context D. Quit = Nothing
@@ -473,9 +472,10 @@ handleShowImportedModules = do
473472 where
474473 showModules = return . unlines . sort . map showModule
475474 showModule (mn, declType, asQ) =
476- case asQ of
475+ " import " ++ case asQ of
477476 Just mn' -> " qualified " ++ N. runModuleName mn ++ " as " ++ N. runModuleName mn'
478477 Nothing -> N. runModuleName mn ++ " " ++ showDeclType declType
478+
479479 showDeclType D. Unqualified = " "
480480 showDeclType (D. Qualifying refs) = refsList refs
481481 showDeclType (D. Hiding refs) = " hiding " ++ refsList refs
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ parseCommand :: String -> Either String C.Command
3838parseCommand cmdString =
3939 case cmdString of
4040 (' :' : cmd) -> parseDirective cmd
41- _ -> parseRest (psciLet <|> psciExpression) cmdString
41+ _ -> parseRest (psciImport <|> psciLet <|> psciExpression) cmdString
4242 where
4343 parseRest :: P. TokenParser a -> String -> Either String a
4444 parseRest p s = either (Left . show ) Right $ do
@@ -60,7 +60,6 @@ parseCommand cmdString =
6060 Just D. Help -> return C. Help
6161 Just D. Quit -> return C. Quit
6262 Just D. Reset -> return C. Reset
63- Just D. Import -> C. Import <$> parseRest P. parseImportDeclarationTail arg
6463 Just D. Browse -> C. Browse <$> parseRest P. moduleName arg
6564 Just D. Load -> return $ C. LoadFile (trim arg)
6665 Just D. Show -> return $ C. Show (trim arg)
@@ -86,3 +85,6 @@ parseCommand cmdString =
8685 where
8786 manyDecls :: P. TokenParser [P. Declaration ]
8887 manyDecls = C. mark (many1 (C. same *> P. parseDeclaration))
88+
89+ psciImport :: P. TokenParser C. Command
90+ psciImport = C. Import <$> P. parseImportDeclaration'
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ module Language.PureScript.Parser.Declarations (
2424 parseGuard ,
2525 parseBinder ,
2626 parseBinderNoParens ,
27- parseImportDeclarationTail ,
27+ parseImportDeclaration' ,
2828) where
2929
3030import Prelude hiding (lex )
@@ -147,15 +147,13 @@ parseFixityDeclaration = do
147147
148148parseImportDeclaration :: TokenParser Declaration
149149parseImportDeclaration = do
150- reserved " import"
151- indented
152- (mn, declType, asQ) <- parseImportDeclarationTail
150+ (mn, declType, asQ) <- parseImportDeclaration'
153151 return $ ImportDeclaration mn declType asQ
154152
155- -- |
156- -- The part of an import statement following the 'import'.
157- parseImportDeclarationTail :: TokenParser ( ModuleName , ImportDeclarationType , ( Maybe ModuleName ))
158- parseImportDeclarationTail =
153+ parseImportDeclaration' :: TokenParser ( ModuleName , ImportDeclarationType , ( Maybe ModuleName ))
154+ parseImportDeclaration' = do
155+ reserved " import "
156+ indented
159157 qualImport <|> stdImport
160158 where
161159 stdImport = do
You can’t perform that action at this time.
0 commit comments