diff options
author | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-07-08 12:01:48 +0200 |
---|---|---|
committer | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-07-08 12:01:48 +0200 |
commit | 562bf90aa4d9d2987c6bb132dbb99184e7e93b1e (patch) | |
tree | 87523b2fccfdef24a2c84f0214eff60fe2bea4f5 /Monitors | |
parent | 6d2519cb84ebd56a7b270bc58b4e352b291624f6 (diff) | |
download | xmobar-562bf90aa4d9d2987c6bb132dbb99184e7e93b1e.tar.gz xmobar-562bf90aa4d9d2987c6bb132dbb99184e7e93b1e.tar.bz2 |
better error handling when parsing weather information
darcs-hash:20070708100148-d6583-a9f7983de441caeccc341c15a7029102e20eaa7b.gz
Diffstat (limited to 'Monitors')
-rw-r--r-- | Monitors/Common.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Monitors/Common.hs b/Monitors/Common.hs index e4c1562..8a51159 100644 --- a/Monitors/Common.hs +++ b/Monitors/Common.hs @@ -30,6 +30,8 @@ module Monitors.Common ( , getNumbers , getNumbersAsString , getAllBut + , getAfterString + , skipTillString , parseTemplate -- ** String Manipulation -- $strings @@ -207,6 +209,16 @@ skipRestOfLine = do many $ noneOf "\n\r" newline +getAfterString :: String -> Parser String +getAfterString s = + do { try $ manyTill skipRestOfLine $ string s + ; v <- manyTill anyChar $ newline + ; return v + } <|> return ("<" ++ s ++ " not found!>") + +skipTillString :: String -> Parser String +skipTillString s = + manyTill skipRestOfLine $ string s -- | Parses the output template string templateStringParser :: Parser (String,String,String) |