Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Good test results printing added.

  • Loading branch information...
commit ff6991bed031523eef7ee2d6e65a3506e0cb900a 1 parent d1ecca5
@graninas authored
View
1  Amoeba/GameLogic/Language/Translating/Actions.hs
@@ -20,3 +20,4 @@ addItem (Item name props) = do
log $ "Adding object template for: " ++ show name
insertObjectTemplate name props
return ""
+addItem t = return $ "addItem: Item expected but got " ++ show t
View
1  Amoeba/GameLogic/Language/Translating/Scheme.hs
@@ -8,4 +8,5 @@ import GameLogic.Language.Translating.Actions
scheme = [ onComment /> skip
, onEmpty /> skip
, onItem /> addItem
+ --, onWorld /> setupWorld
]
View
7 Amoeba/GameLogic/Language/Translating/Translator.hs
@@ -43,20 +43,17 @@ apply' sc t = do
translate _ [] = return ()
translate sc (t:ts) = do
- apply' sc t
+ apply sc t
translate sc ts
-
translateToWorld [] = Left "There are no tokens."
translateToWorld tokens = return $ evalState (runEitherT (translate scheme tokens)) indexingRt
translateToWorld' _ [] = Left "There are no tokens."
translateToWorld' eF tokens = return $ eF (runEitherT (translate scheme tokens)) indexingRt
-
toWorld rawString = do
ts <- RP.parseRawTokens rawString :: Either String [RawToken]
- res <- translateToWorld' execState ts
- return $ trtItemMap res
+ translateToWorld' runState ts
View
5 Amoeba/GameLogic/Language/Translating/Triggers.hs
@@ -5,7 +5,12 @@ import GameLogic.Language.RawToken
onComment (Comment _) = True
onComment _ = False
+
onEmpty EmptyToken = True
onEmpty _ = False
+
onItem (Item n props) = True
onItem _ = False
+
+onWorld (World name props) = True
+onWorld _ = False
View
12 Amoeba/Test/TranslatingTest.hs
@@ -2,19 +2,25 @@ module Main where
import GameLogic.Language.RawToken
import GameLogic.Language.Translating.Translator
+import GameLogic.Language.Translating.Runtime
import GameLogic.Runtime.World
import Control.Monad (liftM)
+import Data.Either.Combinators
+extractItemMap = liftM (trtItemMap . snd)
+extractLog = liftM (trtLog . snd)
+extractResult = liftM fst
main = do
tokens <- readFile "./Data/Raws/World3.arf"
let res = toWorld tokens
- print res
+ putStrLn $ unlines . fromRight' . extractLog $ res
+ putStrLn $ show . fromRight' . extractItemMap $ res
+ putStrLn $ show . fromRight' . extractResult $ res
- tokens2 <- readFile "./Data/Raws/World4_duplicate.arf"
- print $ toWorld tokens2
+
Please sign in to comment.
Something went wrong with that request. Please try again.