aboutsummaryrefslogtreecommitdiff
path: root/Smurf.dcl
blob: 25ea30b073991a15295fa06fb5c2bc7758ea5e67 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
definition module Smurf

from StdOverloaded import
	class zero,
	class toString,
	class toChar, class fromChar,
	class ==

from GenEq import generic gEq

from Data.Maybe import ::Maybe

:: Stm = Push String
       | Input | Output
       | Cat | Head | Tail | Quotify
       | Put | Get | Exec

:: Program :== [Stm]

:: Stack :== [String]
:: Store :== [(String, String)]

:: State = { stack :: Stack
           , store :: Store
           }

:: IO io = IO (io -> .(String, io)) (String io -> io)

:: ListIO = { input  :: [String]
            , output :: [String]
            }

:: Transition = (-->) infix 1 (Program, [String], State) ([String], [String], State)
:: DerivationTree :== [Transition]

derive gEq Stm

instance == Stm
instance toString Stm
instance toChar Stm
instance fromChar Stm

instance zero State
instance toString State

instance zero ListIO

instance toString Transition
instance toString DerivationTree

step :: !Program State u:io u:(IO u:io) -> u:(Maybe (!Program, State), u:io)
run :: !Program State io (IO io) -> (Maybe State, io)

listIO :: IO ListIO
tree :: !Program !State !ListIO (IO ListIO) -> Maybe DerivationTree