MAJOR MIlESTONE: FACTORIAL PROGRAM FROM SRC TO EXECUTION
This commit is contained in:
@@ -20,6 +20,56 @@ letrecExample = [coreProg|
|
|||||||
in fst (snd (snd (snd a)));
|
in fst (snd (snd (snd a)));
|
||||||
|
|
||||||
main = f 3 4;
|
main = f 3 4;
|
||||||
|
|]
|
||||||
|
|
||||||
|
idExample :: Program
|
||||||
|
idExample = [coreProg|
|
||||||
|
main = id 3;
|
||||||
|
|]
|
||||||
|
|
||||||
|
indExample1 = [coreProg|
|
||||||
|
main = twice twice id 3;
|
||||||
|
|]
|
||||||
|
|
||||||
|
indExample2 = [coreProg|
|
||||||
|
main = twice twice twice id 3;
|
||||||
|
|]
|
||||||
|
|
||||||
|
indExample3 = [coreProg|
|
||||||
|
main = letrec x = 2
|
||||||
|
y = f x x
|
||||||
|
in g y y;
|
||||||
|
|
||||||
|
f a b = b;
|
||||||
|
g a b = a;
|
||||||
|
|]
|
||||||
|
|
||||||
|
negExample1 = [coreProg|
|
||||||
|
main = negate# (id 3);
|
||||||
|
|]
|
||||||
|
|
||||||
|
negExample2 = [coreProg|
|
||||||
|
main = negate# 3;
|
||||||
|
|]
|
||||||
|
|
||||||
|
negExample3 = [coreProg|
|
||||||
|
main = twice negate# 3;
|
||||||
|
|]
|
||||||
|
|
||||||
|
arithExample1 = [coreProg|
|
||||||
|
main = (+#) 3 (negate# 2);
|
||||||
|
|]
|
||||||
|
|
||||||
|
arithExample2 = [coreProg|
|
||||||
|
main = negate# ((+#) 2 ((*#) 5 3));
|
||||||
|
|]
|
||||||
|
|
||||||
|
ifExample = [coreProg|
|
||||||
|
main = if# True 2 3;
|
||||||
|
|]
|
||||||
|
|
||||||
|
facExample = [coreProg|
|
||||||
|
fac n = if# ((==#) n 0) 1 ((*#) n (fac ((-#) n 1)))
|
||||||
|
main = fac 3;
|
||||||
|]
|
|]
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ $graphic = [$small $large $symbol $digit $special \:\"\']
|
|||||||
|
|
||||||
$octit = 0-7
|
$octit = 0-7
|
||||||
$hexit = [0-9 A-F a-f]
|
$hexit = [0-9 A-F a-f]
|
||||||
$namechar = [$alpha $digit \']
|
$namechar = [$alpha $digit \' \#]
|
||||||
$symchar = [$symbol \:]
|
$symchar = [$symbol \:]
|
||||||
$nl = [\n\r]
|
$nl = [\n\r]
|
||||||
$white_no_nl = $white # $nl
|
$white_no_nl = $white # $nl
|
||||||
|
|||||||
86
src/TIM.hs
86
src/TIM.hs
@@ -422,92 +422,6 @@ hdbgProg p hio = do
|
|||||||
TiState [resAddr] _ h _ sts = last p'
|
TiState [resAddr] _ h _ sts = last p'
|
||||||
res = hLookupUnsafe resAddr h
|
res = hLookupUnsafe resAddr h
|
||||||
|
|
||||||
-- letrecExample :: Program
|
|
||||||
-- letrecExample = Program
|
|
||||||
-- [ ScDef "pair" ["x","y","f"] $ "f" :$ "x" :$ "y"
|
|
||||||
-- , ScDef "fst" ["p"] $ "p" :$ "K"
|
|
||||||
-- , ScDef "snd" ["p"] $ "p" :$ "K1"
|
|
||||||
-- , ScDef "f" ["x","y"] $
|
|
||||||
-- Let Rec
|
|
||||||
-- [ "a" := "pair" :$ "x" :$ "b"
|
|
||||||
-- , "b" := "pair" :$ "y" :$ "a"
|
|
||||||
-- ]
|
|
||||||
-- ("fst" :$ ("snd" :$ ("snd" :$ ("snd" :$ "a"))))
|
|
||||||
-- , ScDef "main" [] $ "f" :$ IntE 3 :$ IntE 4
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- idExample :: Program
|
|
||||||
-- idExample = Program
|
|
||||||
-- [ ScDef "main" [] $ "id" :$ IntE 3
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- indExample1 :: Program
|
|
||||||
-- indExample1 = Program
|
|
||||||
-- [ ScDef "main" [] $ "twice" :$ "twice" :$ "id" :$ IntE 3
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- indExample2 :: Program
|
|
||||||
-- indExample2 = Program
|
|
||||||
-- [ ScDef "main" [] $ "twice" :$ "twice" :$ "twice" :$ "id" :$ IntE 3
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- indExample3 :: Program
|
|
||||||
-- indExample3 = Program
|
|
||||||
-- [ ScDef "main" [] $
|
|
||||||
-- Let Rec
|
|
||||||
-- [ "x" := IntE 2
|
|
||||||
-- , "y" := "f" :$ "x" :$ "x"
|
|
||||||
-- ]
|
|
||||||
-- ("g" :$ "y" :$ "y")
|
|
||||||
-- , ScDef "f" ["a","b"] $ "b"
|
|
||||||
-- , ScDef "g" ["a","b"] $ "a"
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- negExample1 :: Program
|
|
||||||
-- negExample1 = Program
|
|
||||||
-- [ ScDef "main" [] $
|
|
||||||
-- "negate#" :$ ("id" :$ IntE 3)
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- negExample2 :: Program
|
|
||||||
-- negExample2 = Program
|
|
||||||
-- [ ScDef "main" [] $
|
|
||||||
-- "negate#" :$ IntE 3
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- negExample3 :: Program
|
|
||||||
-- negExample3 = Program
|
|
||||||
-- [ ScDef "main" [] $
|
|
||||||
-- "twice" :$ "negate#" :$ IntE 3
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- arithExample1 :: Program
|
|
||||||
-- arithExample1 = Program
|
|
||||||
-- [ ScDef "main" [] $
|
|
||||||
-- "+#" :$ (IntE 3) :$ ("negate#" :$ (IntE 2))
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- arithExample2 :: Program
|
|
||||||
-- arithExample2 = Program
|
|
||||||
-- [ ScDef "main" [] $
|
|
||||||
-- "negate#" :$ ("+#" :$ (IntE 2) :$ ("*#" :$ IntE 5 :$ IntE 3))
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- ifExample :: Program
|
|
||||||
-- ifExample = Program
|
|
||||||
-- [ ScDef "main" [] $
|
|
||||||
-- "if#" :$ "True" :$ IntE 2 :$ IntE 3
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
-- facExample :: Program
|
|
||||||
-- facExample = Program
|
|
||||||
-- [ ScDef "fac" ["n"] $
|
|
||||||
-- "if#" :$ ("==#" :$ "n" :$ IntE 0)
|
|
||||||
-- :$ (IntE 1)
|
|
||||||
-- :$ ("*#" :$ "n" :$ ("fac" :$ ("-#" :$ "n" :$ IntE 1)))
|
|
||||||
-- , ScDef "main" [] $ "fac" :$ IntE 3
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
|
|
||||||
instance Pretty TiState where
|
instance Pretty TiState where
|
||||||
|
|||||||
Reference in New Issue
Block a user