File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,7 +42,9 @@ compileSource src out err mode = checkDangerousSource src >>= \case
4242 " Sorry, but your program refers to forbidden language features."
4343 return False
4444 False -> withSystemTempDirectory " buildSource" $ \ tmpdir -> do
45- parenProblem <- not <$> checkParsedCode src err
45+ parenProblem <- case mode of
46+ " codeworld" -> not <$> checkParsedCode src err
47+ _ -> return False
4648 copyFile src (tmpdir </> " program.hs" )
4749 baseArgs <- case mode of
4850 " haskell" -> return haskellCompatibleBuildArgs
@@ -55,9 +57,7 @@ compileSource src out err mode = checkDangerousSource src >>= \case
5557 " codeworld" -> filterOutput output
5658 _ -> output
5759
58- if parenProblem
59- then when (not (B. null filteredOutput)) (B. appendFile err " \n\n " )
60- else B. writeFile err " "
60+ when (not parenProblem) $ B. writeFile err " "
6161 B. appendFile err filteredOutput
6262
6363 let target = tmpdir </> " program.jsexe"
Original file line number Diff line number Diff line change 1- {-# LANGUAGE LambdaCase #-}
2- {-# LANGUAGE OverloadedStrings #-}
3-
41{-
52 Copyright 2017 The CodeWorld Authors. All rights reserved.
63
1916
2017module ParseCode (checkParsedCode ) where
2118
22- import qualified Data.ByteString as B
23- import Data.ByteString.Char8 (pack )
24- import Data.List (intercalate )
25- import Data.List.Split (splitOn )
2619import Data.Generics
2720import Language.Haskell.Exts
2821
@@ -32,7 +25,7 @@ checkParsedCode src err = do
3225 case result of
3326 ParseOk mod -> case getErrors mod of
3427 [] -> return True
35- errors -> writeFile err (intercalate " \n\n " errors) >> return False
28+ errors -> writeFile err (concatMap ( ++ " \n\n " ) errors) >> return False
3629 ParseFailed _ _ -> return True
3730
3831getErrors :: Module SrcSpanInfo -> [String ]
@@ -70,6 +63,7 @@ isGoodPatRhs (PTuple _ _ _) = True
7063isGoodPatRhs _ = False
7164
7265formatLocation :: SrcSpanInfo -> String
73- formatLocation (SrcSpanInfo s _) = " program.hs" ++ " :" ++ show line ++ " :" ++ show col ++ " : "
66+ formatLocation (SrcSpanInfo s _) =
67+ " program.hs" ++ " :" ++ show line ++ " :" ++ show col ++ " : "
7468 where line = srcSpanStartLine s
7569 col = srcSpanStartColumn s
You can’t perform that action at this time.
0 commit comments