diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-06-03 12:02:31 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-06-03 12:02:31 +0200 |
| commit | 99e5658feb48f15f85eaf9680affea2f490459bb (patch) | |
| tree | 61fa812185892845b36792960435f79e0535043f /src/main.hs | |
| parent | e8e86cea2bffe23961f0a1bea8ee770343894858 (diff) | |
| download | computorv2-99e5658feb48f15f85eaf9680affea2f490459bb.tar.gz computorv2-99e5658feb48f15f85eaf9680affea2f490459bb.tar.bz2 computorv2-99e5658feb48f15f85eaf9680affea2f490459bb.zip | |
Refactoring parsing, Fixing builtin, rewrite everything else
Diffstat (limited to 'src/main.hs')
| -rw-r--r-- | src/main.hs | 69 |
1 files changed, 33 insertions, 36 deletions
diff --git a/src/main.hs b/src/main.hs index 569ba28..49aeb00 100644 --- a/src/main.hs +++ b/src/main.hs @@ -1,42 +1,39 @@ import System.IO -import Statement -import Parser.Statement import Parser.Core -import Statement -import Assignment import Expr -import Evaluation -main = promptLoop [] +main = return () -promptLoop :: Context -> IO () -promptLoop context = do - line <- prompt - if line /= "exit" - then loop line context >>= promptLoop - else return () - -loop :: String -> Context -> IO Context -loop line context = do s <- parseIO line - context <- printStatement s context - putStrLn $ show context - return context - -prompt :: IO String -prompt = do putStr "> " - hFlush stdout - getLine - -parseIO :: String -> IO Statement -parseIO input = case parseStrict statementP input of - Nothing -> fail "Couldn't parse input" - Just s -> return s - -printStatement :: Statement -> Context -> IO Context -printStatement (SAssignment a) context = do putStrLn $ show a - return $ update context a -printStatement (SExpr e) context = do putStrLn evalStr - return context - where evalStr = case eval context e of Nothing -> "Couldn't evaluate expression" - Just a -> show a +-- main = promptLoop [] +-- +-- promptLoop :: Context -> IO () +-- promptLoop context = do +-- line <- prompt +-- if line /= "exit" +-- then loop line context >>= promptLoop +-- else return () +-- +-- loop :: String -> Context -> IO Context +-- loop line context = do s <- parseIO line +-- context <- printStatement s context +-- putStrLn $ show context +-- return context +-- +-- prompt :: IO String +-- prompt = do putStr "> " +-- hFlush stdout +-- getLine +-- +-- parseIO :: String -> IO Statement +-- parseIO input = case parseStrict statementP input of +-- Nothing -> fail "Couldn't parse input" +-- Just s -> return s +-- +-- printStatement :: Statement -> Context -> IO Context +-- printStatement (SAssignment a) context = do putStrLn $ show a +-- return $ update context a +-- printStatement (SExpr e) context = do putStrLn evalStr +-- return context +-- where evalStr = case eval context e of Nothing -> "Couldn't evaluate expression" +-- Just a -> show a |
