packages feed

amrun 0.0 → 0.0.0.1

raw patch · 2 files changed

+6/−2 lines, 2 files

Files

amrun.cabal view
@@ -1,5 +1,5 @@ Name:                amrun-Version:             0.0+Version:             0.0.0.1 Synopsis:            Interpreter for AM Description:         The package contains an interpreter for the AM-Language that is introduced in the basic programming course \"Algorithmisches Denken und imperative Programmierung\" (WS 2011/12 and later) at the University of Bonn. License:             GPL
src/amrun.hs view
@@ -147,10 +147,14 @@    Just c -> return c    Nothing ->       case oneArgCmd of-       Just c -> do{arg <- (pcParser <?> "command argument"); return (c arg);}+       Just c -> do+                   sign <- if cmd == "LIT" then neg else return 1+                   arg <- (pcParser <?> "command argument")+                   return (c (sign*arg))        Nothing -> unexpected (cmd ++ " is not a command.")                    }   where+    neg = spaces >> (try (char '-' >> ((many1 space >> fail "spaces after '-', expected digit") <|> return (-1))) <|> return 1)     readCmd cmd = case cmd of                    "ADD" -> Just ADD                    "MUL" -> Just MUL