Skip to content

Commit

Permalink
A little user-interface cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
luqui committed Jul 6, 2009
1 parent 64244cd commit 1afc640
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions experiments/interp-stack/interpreter.hs
Expand Up @@ -6,6 +6,7 @@ import InterpStack.HOAS
import Debug.Trace import Debug.Trace
import System.IO import System.IO
import System.Environment import System.Environment
import Data.List (intercalate)


data IVal data IVal
= IInt !Int = IInt !Int
Expand Down Expand Up @@ -90,11 +91,23 @@ layer x = buildExp (eInterp_ % nil_) :% quote x


iter n = foldr (.) id . replicate n iter n = foldr (.) id . replicate n


interps = [ "lazyNF" --> lazyNFInterp
, "depthLazyNF" --> depthLazyNFInterp
, "embedded" --> embeddedInterp
]
where (-->) = (,)

main = do main = do
[interpStr, n] <- getArgs args <- getArgs
let interp = case interpStr of (interpStr, n) <- case args of
"lazyNF" -> lazyNFInterp [interpStr, n] -> return (interpStr,n)
"depthLazyNF" -> depthLazyNFInterp _ -> fail $ "Usage: interpreter <interp> <height>, where interp is one of ["
"embedded" -> embeddedInterp ++ choices ++ "], and height is the height of the interpreter stack"
interp <- case lookup interpStr interps of
Just i -> return i
Nothing -> fail $ "Not a valid interpreter. Valid choices are " ++ choices
hSetBuffering stdout NoBuffering hSetBuffering stdout NoBuffering
print . eval interp . iter (read n) layer . buildExp $ program_ print . eval interp . iter (read n) layer . buildExp $ program_

where
choices = intercalate "," . map fst $ interps

0 comments on commit 1afc640

Please sign in to comment.