git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Require imports to appear before other declarations
3ca5543Phil Freeman
src/Language/PureScript/Parser/Declarations.hs+7−3
@@ -234,7 +234,6 @@ parseDeclaration = positioned (P.choice
234 , parseValueDeclaration
234 , parseValueDeclaration
235 , parseExternDeclaration
235 , parseExternDeclaration
236 , parseFixityDeclaration
236 , parseFixityDeclaration
237− , parseImportDeclaration
238 , parseTypeClassDeclaration
237 , parseTypeClassDeclaration
239 , parseTypeInstanceDeclaration
238 , parseTypeInstanceDeclaration
240 , parseDerivingInstanceDeclaration
239 , parseDerivingInstanceDeclaration
@@ -258,7 +257,13 @@ parseModule = do
258 name <- moduleName
257 name <- moduleName
259 exports <- P.optionMaybe $ parens $ commaSep1 parseDeclarationRef
258 exports <- P.optionMaybe $ parens $ commaSep1 parseDeclarationRef
260 reserved "where"
259 reserved "where"
260+ decls <- mark $ do
261+ -- TODO: extract a module header structure here, and provide a
262+ -- parseModuleHeader function. This should allow us to speed up rebuilds
263+ -- by only parsing as far as the module header. See PR #2054.
264+ imports <- P.many (same *> parseImportDeclaration)
261− decls <- mark (P.many (same *> parseDeclaration))
265+ decls <- P.many (same *> parseDeclaration)
266+ return (imports ++ decls)
262 _ <- P.eof
267 _ <- P.eof
263 end <- P.getPosition
268 end <- P.getPosition
264 let ss = SourceSpan (P.sourceName start) (C.toSourcePos start) (C.toSourcePos end)
269 let ss = SourceSpan (P.sourceName start) (C.toSourcePos start) (C.toSourcePos end)
@@ -572,4 +577,3 @@ parseBinderNoParens = P.choice
572--
577--
573parseGuard :: TokenParser Guard
578parseGuard :: TokenParser Guard
574parseGuard = pipe *> C.indented *> parseValue
579parseGuard = pipe *> C.indented *> parseValue
575−