Permalink
Browse files

Polishing.

darcs-hash:20080201045938-ec8c9-9d33b01717d42c1f386bf0436a0fc9dcea884de5.gz
  • Loading branch information...
1 parent ecffc91 commit 75b8587018c382cd2b4a854310ff44dd4626fbf3 @Eelis committed Feb 1, 2008
Showing with 13 additions and 8 deletions.
  1. +1 −0 prelude/terse.hpp
  2. +2 −0 prelude/type_strings.hpp
  3. +1 −1 src/Bot.hs
  4. +3 −3 src/ErrorFilters.hs
  5. +2 −2 src/EvalCxx.hsc
  6. +0 −2 src/Testsuite.hs
  7. +4 −0 src/Util.hs
View
@@ -51,6 +51,7 @@ typedef ::std::string str;
#define numlim ::std::numeric_limits
// Boost:
+#define opt ::boost::optional
#define lcast ::boost::lexical_cast
#define foreach BOOST_FOREACH
using boost::next;
View
@@ -4,6 +4,8 @@
#ifndef TYPE_STRINGS_HPP
#define TYPE_STRINGS_HPP
+#include "lvalue_rvalue.hpp"
+
#include <tr1/array>
#include <list>
View
@@ -63,7 +63,7 @@ main :: IO ()
main = do
opts <- getArgs
if Help `elem` opts then putStrLn help else do
- cfg <- readTypedFile $ maybe "bot-config" id $ findMaybe (\o -> case o of Config cf -> Just cf; _ -> Nothing) opts
+ cfg <- readTypedFile $ findMaybe (\o -> case o of Config cf -> Just cf; _ -> Nothing) opts `orElse` "bot-config"
full_evaluate $ do_censor cfg "abc" -- So that any mkRegex failures occur before we start connecting.
putStrLn $ "Connecting to " ++ server cfg ++ ":" ++ show (port cfg)
withResource (connect (server cfg) (fromIntegral $ port cfg)) $ \h -> do
View
@@ -7,7 +7,7 @@ import Text.Regex (matchRegex, mkRegex, subRegex)
import Data.List (intersperse)
import Data.Char (isAlphaNum)
import Text.ParserCombinators.Parsec
- (string, sepBy, parse, char, try, getInput, (<|>), satisfy, spaces, manyTill, anyChar, noneOf, option, count, CharParser, notFollowedBy)
+ (string, sepBy, parse, char, try, getInput, (<|>), satisfy, spaces, manyTill, anyChar, noneOf, option, count, CharParser, notFollowedBy, choice)
import Text.ParserCombinators.Parsec.Prim (GenParser)
import Text.ParserCombinators.Parsec.Language (haskell)
import Text.ParserCombinators.Parsec.Token (charLiteral, stringLiteral)
@@ -54,7 +54,7 @@ class ExactParse a st | a -> st where exact :: a -> CharParser st String
instance ExactParse Char st where exact c = string [c]
instance ExactParse String st where exact = string
-instance ExactParse [String] st where exact l = foldr1 (<|>) (try . string . l)
+instance ExactParse [String] st where exact l = choice (try . string . l)
instance ExactParse (CharParser st String) st where exact = id
instance ExactParse (CharParser st Char) st where exact = ((:[]) .)
@@ -167,7 +167,7 @@ with_subst (k, v) =
-- With-substitution would fail if the following occurred in an error: "... T const ... [with T = int&]" (because it would be replaced with "... int& const ...". Fortunately, g++ places cv-qualifiers on the left side in these cases. For example, see the error message for: "template <typename T> std::string f(T const &); void g() { int i = 3; !f<int&>(i); }".
cleanup_types :: String -> String
-cleanup_types s = either (const s) cleanup_types $ parse (foldr1 (<|>) (try . replacers) >>> getInput) "" s
+cleanup_types s = either (const s) cleanup_types $ parse (choice (try . replacers) >>> getInput) "" s
cc1plus e = maybe e' (!!1) $ matchRegex (mkRegex "\\b(error|warning): ([^\n]*)") e'
where e' = cleanup_types e
View
@@ -97,7 +97,7 @@ supervise pid = alloca $ \wstatp -> do
wait wstatp >>= \s -> when (s /= WaitStopped sigSTOP) $ fail $ "first ptraced event not sigSTOP, but " ++ show s
Ptrace.tracesysgood pid
Ptrace.syscall pid
- ($ Nothing) $ fix $ \sv current_syscall -> do
+ flip fix Nothing $ \sv current_syscall -> do
wstat <- wait wstatp
case wstat of
WaitNoChild -> return ChildVanished
@@ -186,7 +186,7 @@ instance Show EvaluationResult where
_ -> "g++: " ++ show r
prog_env :: [(String, String)]
-prog_env = [("GLIBCXX_DEBUG_MESSAGE_LENGTH","0")]
+prog_env = [("GLIBCXX_DEBUG_MESSAGE_LENGTH", "0")]
evaluate :: FilePath -> [String] -> String -> Bool -> IO EvaluationResult
evaluate gxx_path gxx_flags code also_run = do
View
@@ -6,8 +6,6 @@ import Control.Monad.Error ()
import Text.Regex (matchRegex, mkRegex)
import Data.List (sort, isPrefixOf)
-import Prelude hiding (catch, (.))
-
esc :: Char
esc = '\x1b'
View
@@ -91,5 +91,9 @@ sortByProperty f = sortBy $ \x y -> compare (f x) (f y)
strip :: String -> String
strip = dropWhile isSpace . reverse . dropWhile isSpace . reverse
+orElse :: Maybe a -> a -> a
+orElse (Just x) _ = x
+orElse Nothing x = x
+
putNewLn :: IO ()
putNewLn = putStrLn ""

0 comments on commit 75b8587

Please sign in to comment.