gdritter repos simple-befunge / df2279c
Some build modifications Getty Ritter 9 years ago
3 changed file(s) with 25 addition(s) and 28 deletion(s). Collapse all Expand all
1 import Distribution.Simple
1 import Distribution.Simple
22 main = defaultMain
1 name: befunge
1 name: simple-befunge
22 version: 0.1.0.0
3 -- synopsis:
4 -- description:
3 synopsis: A simple interpreter for Befunge-98.
4 description: A simple interpreter for Befunge-98.
55 license: BSD3
66 license-file: LICENSE
77 author: Getty Ritter
88 maintainer: gettylefou@gmail.com
9 -- copyright:
9 copyright: © 2015 Getty Ritter
1010 category: Language
1111 build-type: Simple
12 -- extra-source-files:
1312 cabal-version: >=1.10
13
14 source-repository head
15 type: git
16 location: git://github.com/aisamanra/simple-befunge.git
1417
1518 executable befunge
1619 main-is: Main.hs
17 -- other-modules:
18 -- other-extensions:
1920 build-depends: base >=4.7 && <4.8,
2021 transformers,
2122 mtl,
22
33 module Main where
44
5 import Data.Array (Array, array, (!), (//))
6 import Data.Char (chr, ord)
7 import Data.Maybe (fromMaybe)
8 import Control.Monad (void, forever)
9 import Control.Monad.IO.Class (liftIO)
10 import Control.Monad.State ( StateT(runStateT)
11 , get
12 , put
13 , modify
14 )
15 import System.Exit (exitSuccess)
16 import System.Environment (getArgs)
17 import System.IO (stdout, hFlush)
18 import System.Random (randomIO)
5 import Control.Monad (forever, void)
6 import Control.Monad.IO.Class (liftIO)
7 import Control.Monad.State (StateT (runStateT), get, modify, put)
8 import Data.Array (Array, array, (!), (//))
9 import Data.Char (chr, isDigit, ord)
10 import Data.Maybe (fromMaybe)
11 import System.Environment (getArgs)
12 import System.Exit (exitSuccess)
13 import System.IO (hFlush, stdout)
14 import System.Random (randomIO)
1915
2016 type Board = Array (Int, Int) Char
2117 data Direction = U | R | D | L deriving (Eq, Show, Enum)
3733 debug = do
3834 st <- get
3935 liftIO $ do
40 putStrLn $ "FS {"
41 putStrLn $ " , loc=" ++ show (location st)
42 putStrLn $ " , stk=" ++ show (stack st)
43 putStrLn $ " , dir=" ++ show (direction st)
44 putStrLn $ " }"
36 putStrLn "FS {"
37 putStrLn (" , loc=" ++ show (location st))
38 putStrLn (" , stk=" ++ show (stack st))
39 putStrLn (" , dir=" ++ show (direction st))
40 putStrLn " }"
4541
4642 pop :: FungeM Int
4743 pop = do
140136 n <- liftIO getLine
141137 push (ord (head n))
142138 step '@' = terminate "Finished"
143 step n | n >= '0' && n <= '9' = push (ord n - ord '0')
139 step n | isDigit n = push (ord n - ord '0')
144140 step _ = return ()
145141
146142 run :: FungeM ()