Warn about extra spaces between ((s in for((;;))
This commit is contained in:
parent
12d9c1b76d
commit
739eaadbf5
|
@ -2485,19 +2485,31 @@ readForClause = called "for loop" $ do
|
|||
readArithmetic id <|> readRegular id
|
||||
where
|
||||
readArithmetic id = called "arithmetic for condition" $ do
|
||||
try $ string "(("
|
||||
readArithmeticDelimiter '(' "Missing second '(' to start arithmetic for ((;;)) loop"
|
||||
x <- readArithmeticContents
|
||||
char ';' >> spacing
|
||||
y <- readArithmeticContents
|
||||
char ';' >> spacing
|
||||
z <- readArithmeticContents
|
||||
spacing
|
||||
string "))"
|
||||
readArithmeticDelimiter ')' "Missing second ')' to terminate 'for ((;;))' loop condition"
|
||||
spacing
|
||||
optional $ readSequentialSep >> spacing
|
||||
group <- readBraced <|> readDoGroup id
|
||||
return $ T_ForArithmetic id x y z group
|
||||
|
||||
-- For c='(' read "((" and be lenient about spaces
|
||||
readArithmeticDelimiter c msg = do
|
||||
char c
|
||||
startPos <- getPosition
|
||||
sp <- spacing
|
||||
endPos <- getPosition
|
||||
char c <|> do
|
||||
parseProblemAt startPos ErrorC 1137 msg
|
||||
fail ""
|
||||
unless (null sp) $
|
||||
parseProblemAtWithEnd startPos endPos ErrorC 1138 $ "Remove spaces between " ++ [c,c] ++ " in arithmetic for loop."
|
||||
|
||||
readBraced = do
|
||||
(T_BraceGroup _ list) <- readBraceGroup
|
||||
return list
|
||||
|
|
Loading…
Reference in New Issue