mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-08 05:51:09 -07:00
Simplify thenSkip, and use in another location
This commit is contained in:
parent
01f4423465
commit
3e17a20965
1 changed files with 2 additions and 5 deletions
|
@ -373,10 +373,7 @@ parseNoteAtId id c l a = do
|
||||||
parseNoteAtWithEnd start end c l a = addParseNote $ ParseNote start end c l a
|
parseNoteAtWithEnd start end c l a = addParseNote $ ParseNote start end c l a
|
||||||
|
|
||||||
--------- Convenient combinators
|
--------- Convenient combinators
|
||||||
thenSkip main follow = do
|
thenSkip main follow = main <* optional follow
|
||||||
r <- main
|
|
||||||
optional follow
|
|
||||||
return r
|
|
||||||
|
|
||||||
unexpecting s p = try $
|
unexpecting s p = try $
|
||||||
(try p >> fail ("Unexpected " ++ s)) <|> return ()
|
(try p >> fail ("Unexpected " ++ s)) <|> return ()
|
||||||
|
@ -420,7 +417,7 @@ acceptButWarn parser level code note =
|
||||||
|
|
||||||
parsecBracket before after op = do
|
parsecBracket before after op = do
|
||||||
val <- before
|
val <- before
|
||||||
(op val <* optional (after val)) <|> (after val *> fail "")
|
op val `thenSkip` after val <|> (after val *> fail "")
|
||||||
|
|
||||||
swapContext contexts p =
|
swapContext contexts p =
|
||||||
parsecBracket (getCurrentContexts <* setCurrentContexts contexts)
|
parsecBracket (getCurrentContexts <* setCurrentContexts contexts)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue