ewe 0.1.0.38 → 0.1.0.40
raw patch · 5 files changed
+121/−19 lines, 5 files
Files
- dist/build/ewe/ewe-tmp/Language/EWE/Parser.hs +28/−0
- dist/build/ewe/ewe-tmp/Language/EWE/Scanner.hs +67/−0
- ewe.cabal +1/−1
- src/Language/EWE/VM.hs +13/−8
- src/Main.hs +12/−10
dist/build/ewe/ewe-tmp/Language/EWE/Parser.hs view
@@ -585,6 +585,34 @@ {-# LINE 1 "templates/GenericTemplate.hs" #-} {-# LINE 1 "templates/GenericTemplate.hs" #-} {-# LINE 1 "<command-line>" #-}+{-# LINE 8 "<command-line>" #-}+# 1 "/usr/include/stdc-predef.h" 1 3 4++# 17 "/usr/include/stdc-predef.h" 3 4++++++++++++++++++++++++# 8 "<command-line>" 2 {-# LINE 1 "templates/GenericTemplate.hs" #-} -- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
dist/build/ewe/ewe-tmp/Language/EWE/Scanner.hs view
@@ -33,6 +33,39 @@ {-# LINE 1 "templates/wrappers.hs" #-} {-# LINE 1 "templates/wrappers.hs" #-} {-# LINE 1 "<command-line>" #-}+++++++# 1 "/usr/include/stdc-predef.h" 1 3 4++# 17 "/usr/include/stdc-predef.h" 3 4++++++++++++++++++++++++# 6 "<command-line>" 2 {-# LINE 1 "templates/wrappers.hs" #-} -- ----------------------------------------------------------------------------- -- Alex wrapper code.@@ -362,6 +395,40 @@ {-# LINE 1 "templates/GenericTemplate.hs" #-} {-# LINE 1 "templates/GenericTemplate.hs" #-} {-# LINE 1 "<command-line>" #-}++++++++# 1 "/usr/include/stdc-predef.h" 1 3 4++# 17 "/usr/include/stdc-predef.h" 3 4++++++++++++++++++++++++# 7 "<command-line>" 2 {-# LINE 1 "templates/GenericTemplate.hs" #-} -- ----------------------------------------------------------------------------- -- ALEX TEMPLATE
ewe.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: ewe-version: 0.1.0.38+version: 0.1.0.40 synopsis: An language using in Programming Languages teaching description: Another implemention of the EWE programming language originally created and developed by Kent D. Lee. EWE is an extension of the RAM programming language. RAM was created by Sethi. homepage: http://github.com/jfcmacro/ewe
src/Language/EWE/VM.hs view
@@ -104,7 +104,7 @@ state { mem = inMem (mRef mr (ge state)) i (mem state) , pc = incrPC state }-execInstr (IMMS mr s) st = +execInstr (IMMS mr s) st = let base = mRef mr (ge st) total = base + length s st' = moveStrInMem s base total st@@ -206,20 +206,25 @@ execIRS :: String -> Instr -> StateVM -> StateVM execIRS s (IRS mr1 mr2) state = let ge' = ge state+ m = mem state startP = mRef mr1 ge'- lenStr = mRef mr2 ge'- state' = moveStrInMem s startP (startP + lenStr) state- in if lenStr >= 0- then state' { pc = incrPC state }+ lenP = mRef mr2 ge'+ (m', v) = outMem lenP m+ state' = state { mem = m' }+ state'' = moveStrInMem s startP (startP + v) state'+ in if v >= 0+ then state'' { pc = incrPC state } else error "IRS len is negative" moveStrInMem :: String -> Int -> Int -> StateVM -> StateVM moveStrInMem [] st en state- | st <= en = moveStrInMem [] (st+1) en (state { mem = inMem st 0 (mem state) })+ | st <= en = moveStrInMem [] (st+1) en+ (state { mem = inMem st 0 (mem state) }) | otherwise = state moveStrInMem (c:cs) st en state- | st <= en = moveStrInMem cs (st+1) en (state { mem = inMem st (ord c) (mem state) })- | otherwise = state+ | st <= en = moveStrInMem cs (st+1) en+ (state { mem = inMem st (ord c) (mem state) })+ | otherwise = state { mem = inMem st 0 (mem state) } execIWS :: Instr -> StateVM -> (StateVM, String) execIWS (IWS mr) state =
src/Main.hs view
@@ -38,22 +38,22 @@ options = [ Option ['v'] ["version"] (NoArg (\opts -> opts { optShowVersion = True }))- "show version number"+ "shows a version number and quits " , Option ['h', '?'] ["help"] (NoArg (\opts -> opts { optShowHelp = True }))- "show help menu"+ "shows help menu and quits" , Option ['n'] ["noexec"] (NoArg (\opts -> opts { optNoExec = False }))- "execute the current file with ewe-vm"+ "not execute the current file with ewe-vm" , Option ['p'] ["parser"] (NoArg (\opts -> opts { optParserOut = True }))- "show parser info"+ "shows parser info" , Option ['s'] ["scanner"] (NoArg (\opts -> opts { optScanOut = True }))- "show scan info"+ "shows scan info" , Option ['d'] ["debug"] (NoArg (\opts -> opts { optDebug = True }))- "show debug info"+ "shows debug info" ] compilerOpts :: [String] -> IO (Options, [String])@@ -77,7 +77,7 @@ showHelp :: IO () showHelp = do- hPutStrLn stderr $ show (usageInfo header options) + mapM_ (hPutStrLn stderr) (lines $ usageInfo header options) exitSuccess where header = "Usage: ewe [OPTION...] files..." @@ -98,7 +98,6 @@ pRes = pEWE s errorParser = either (\_ -> True) (\_ -> False) pRes (passGrammar,errGram) = either (\_ -> (False,[])) checkGrammar pRes- when (optShowHelp opts) (showHelp) when (optScanOut opts) (showScannerOutput scanout) when (optParserOut opts) (showParserOutput pRes) when (not passGrammar) (showErrorGrammar errGram)@@ -119,8 +118,11 @@ processStaticOptions :: Options -> IO () processStaticOptions opts = if optShowVersion opts- then hPutStrLn stdout $ "ewe version: " ++ (showVersion version)- else return ()+ then do hPutStrLn stdout $ "ewe version: " ++ (showVersion version)+ exitSuccess + else if optShowHelp opts+ then showHelp+ else return () main :: IO () main = do