Improve messages for missing 'then' statements.
This commit is contained in:
parent
1a0e208cc3
commit
9dadce96c0
|
@ -1483,9 +1483,8 @@ readIfPart = do
|
||||||
allspacing
|
allspacing
|
||||||
condition <- readTerm
|
condition <- readTerm
|
||||||
|
|
||||||
optional (do
|
ifNextToken (g_Fi <|> g_Elif) $
|
||||||
try . lookAhead $ g_Fi
|
parseProblemAt pos ErrorC 1049 "Did you forget the 'then' for this 'if'?"
|
||||||
parseProblemAt pos ErrorC 1049 "Did you forget the 'then' for this 'if'?")
|
|
||||||
|
|
||||||
called "then clause" $ do
|
called "then clause" $ do
|
||||||
g_Then `orFail` parseProblem ErrorC 1050 "Expected 'then'."
|
g_Then `orFail` parseProblem ErrorC 1050 "Expected 'then'."
|
||||||
|
@ -1504,6 +1503,10 @@ readElifPart = called "elif clause" $ do
|
||||||
parseProblemAt pos ErrorC 1075 "Use 'elif' instead of 'else if'."
|
parseProblemAt pos ErrorC 1075 "Use 'elif' instead of 'else if'."
|
||||||
allspacing
|
allspacing
|
||||||
condition <- readTerm
|
condition <- readTerm
|
||||||
|
|
||||||
|
ifNextToken (g_Fi <|> g_Elif) $
|
||||||
|
parseProblemAt pos ErrorC 1049 "Did you forget the 'then' for this 'elif'?"
|
||||||
|
|
||||||
g_Then
|
g_Then
|
||||||
acceptButWarn g_Semi ErrorC 1052 "No semicolons directly after 'then'."
|
acceptButWarn g_Semi ErrorC 1052 "No semicolons directly after 'then'."
|
||||||
allspacing
|
allspacing
|
||||||
|
@ -1522,6 +1525,11 @@ readElsePart = called "else clause" $ do
|
||||||
verifyNotEmptyIf "else"
|
verifyNotEmptyIf "else"
|
||||||
readTerm
|
readTerm
|
||||||
|
|
||||||
|
ifNextToken parser action =
|
||||||
|
optional $ do
|
||||||
|
try . lookAhead $ parser
|
||||||
|
action
|
||||||
|
|
||||||
prop_readSubshell = isOk readSubshell "( cd /foo; tar cf stuff.tar * )"
|
prop_readSubshell = isOk readSubshell "( cd /foo; tar cf stuff.tar * )"
|
||||||
readSubshell = called "explicit subshell" $ do
|
readSubshell = called "explicit subshell" $ do
|
||||||
id <- getNextId
|
id <- getNextId
|
||||||
|
|
Loading…
Reference in New Issue