@@ -327,13 +327,19 @@ spaces =
327327
328328forcedWS :: IParser String
329329forcedWS =
330− choice
331− [ (++) <$> spaces <*> (concat <$> many nl_space)
332− , concat <$> many1 nl_space
333− ]
334− where
335− nl_space =
336− try ((++) <$> (concat <$> many1 newline) <*> spaces)
330+ do ws <- many1 (spaces <|> newline)
331+ column <- sourceColumn <$> getPosition
332+ if column == 1
333+ then fail badWhiteSpaceMessage
334+ else return (concat ws)
335+
336+
337+badWhiteSpaceMessage :: String
338+badWhiteSpaceMessage =
339+ "I need whitespace, but got stuck on what looks like a new declaration.\n"
340+ ++ "\n"
341+ ++ "You are either missing some stuff in the declaration above or just need to add\n"
342+ ++ "some spaces here:"
337343
338344
339345-- Just eats whitespace until the next meaningful character.
@@ -347,11 +353,21 @@ whitespace =
347353 option "" forcedWS
348354
349355
350−freshLine :: IParser [[String]]
356+freshLine :: IParser String
351357freshLine =
352− try (many1 newline >> many space_nl) <|> try (many1 space_nl) <?> Syntax.freshLine
353− where
354− space_nl = try $ spaces >> many1 newline
358+ try (
359+ do ws <- many1 (spaces <|> newline)
360+ column <- sourceColumn <$> getPosition
361+ if column == 1
362+ then return (concat ws)
363+ else fail badFreshLineMessage
364+ ) <?> Syntax.freshLine
365+
366+
367+badFreshLineMessage :: String
368+badFreshLineMessage =
369+ "I need a fresh line to start a new declaration. This means a new line that\n"
370+ ++ "starts with stuff, not with spaces or comments."
355371
356372
357373newline :: IParser String