aboutsummaryrefslogtreecommitdiff
path: root/Smurf.dcl
blob: 53ab7974214c8be5b6f34520ea98bc7605bef3ba (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
56
57
58
59
60
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

from LaTeX import class toLaTeX

:: 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, Stack, State) (Stack, Stack, 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

instance toLaTeX Transition
instance toLaTeX 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