Added better message for missing ]/]]

This commit is contained in:
Vidar Holen 2012-11-27 01:28:42 -08:00
parent 100fff4835
commit bb7e844125
1 changed files with 7 additions and 1 deletions

View File

@ -429,8 +429,14 @@ readCondition = do
then "You need spaces after the opening [ and before the closing ]."
else "You need spaces after the opening [[ and before the closing ]]."
condition <- readConditionContents single
cpos <- getPosition
close <- (try $ string "]]") <|> (string "]")
close <- (try $ string "]]") <|> (string "]") <|> do
let match = (if single then "]" else "]]")
parseProblemAt opos ErrorC $ "Couldn't find matching " ++ match ++ "."
parseProblem ErrorC $ "Expected " ++ match
fail "condition"
when (open == "[[" && close /= "]]") $ parseProblemAt cpos ErrorC "Did you mean ]] ?"
when (open == "[" && close /= "]" ) $ parseProblemAt opos ErrorC "Did you mean [[ ?"
return $ T_Condition id (if single then SingleBracket else DoubleBracket) condition