Ditched the stunted concept and added better warnings
This commit is contained in:
parent
a25cc75afa
commit
45b98f408c
|
@ -789,7 +789,12 @@ readBraceGroup = do
|
||||||
prop_readWhileClause = isOk readWhileClause "while [[ -e foo ]]; do sleep 1; done"
|
prop_readWhileClause = isOk readWhileClause "while [[ -e foo ]]; do sleep 1; done"
|
||||||
readWhileClause = do
|
readWhileClause = do
|
||||||
(T_While id) <- g_While
|
(T_While id) <- g_While
|
||||||
|
pos <- getPosition
|
||||||
condition <- readTerm
|
condition <- readTerm
|
||||||
|
return () `attempting` (do
|
||||||
|
eof
|
||||||
|
parseProblemAt pos ErrorC "Condition missing 'do'. Did you forget it or the ; or \\n before i?"
|
||||||
|
)
|
||||||
statements <- readDoGroup
|
statements <- readDoGroup
|
||||||
return $ T_WhileExpression id condition statements
|
return $ T_WhileExpression id condition statements
|
||||||
|
|
||||||
|
@ -807,14 +812,32 @@ readDoGroup = do
|
||||||
(eof >> return []) <|>
|
(eof >> return []) <|>
|
||||||
do
|
do
|
||||||
commands <- readCompoundList
|
commands <- readCompoundList
|
||||||
disregard g_Done <|> eof -- stunted support
|
disregard g_Done <|> (do
|
||||||
|
eof
|
||||||
|
case hasFinal "done" commands of
|
||||||
|
Nothing -> parseProblemAt pos ErrorC "Couldn't find a 'done' for this 'do'"
|
||||||
|
Just (id) -> addNoteFor id $ Note ErrorC "Put a ; or \\n before the done"
|
||||||
|
)
|
||||||
return commands
|
return commands
|
||||||
<|> do
|
<|> do
|
||||||
parseProblemAt pos ErrorC "Can't find the 'done' for this 'do'"
|
parseProblemAt pos ErrorC "Can't find the 'done' for this 'do'"
|
||||||
fail "No done"
|
fail "No done"
|
||||||
|
|
||||||
|
hasFinal s [] = Nothing
|
||||||
|
hasFinal s f =
|
||||||
|
case last f of
|
||||||
|
T_Pipeline _ m@(_:_) ->
|
||||||
|
case last m of
|
||||||
|
T_Redirecting _ [] (T_SimpleCommand _ _ m@(_:_)) ->
|
||||||
|
case last m of
|
||||||
|
T_NormalWord _ [T_Literal id str] ->
|
||||||
|
if str == s then Just id else Nothing
|
||||||
|
_ -> Nothing
|
||||||
|
_ -> Nothing
|
||||||
|
_ -> Nothing
|
||||||
|
|
||||||
|
|
||||||
prop_readForClause = isOk readForClause "for f in *; do rm \"$f\"; done"
|
prop_readForClause = isOk readForClause "for f in *; do rm \"$f\"; done"
|
||||||
prop_readForClause2 = isOk readForClause "for f in *; do ..."
|
|
||||||
prop_readForClause3 = isOk readForClause "for f; do foo; done"
|
prop_readForClause3 = isOk readForClause "for f; do foo; done"
|
||||||
readForClause = do
|
readForClause = do
|
||||||
(T_For id) <- g_For
|
(T_For id) <- g_For
|
||||||
|
@ -822,7 +845,11 @@ readForClause = do
|
||||||
name <- readVariableName
|
name <- readVariableName
|
||||||
spacing
|
spacing
|
||||||
values <- readInClause <|> (readSequentialSep >> return [])
|
values <- readInClause <|> (readSequentialSep >> return [])
|
||||||
group <- readDoGroup <|> (allspacing >> eof >> return []) -- stunted support
|
group <- readDoGroup <|> (
|
||||||
|
allspacing >>
|
||||||
|
eof >>
|
||||||
|
parseProblem ErrorC "Missing 'do'" >>
|
||||||
|
return [])
|
||||||
return $ T_ForIn id name values group
|
return $ T_ForIn id name values group
|
||||||
|
|
||||||
readInClause = do
|
readInClause = do
|
||||||
|
|
Loading…
Reference in New Issue