Handle parentheses. Test multiple declarations.

This commit is contained in:
Robbie Gleichman 2016-02-05 22:39:05 -08:00
parent 6cda91bbb1
commit 6f6bca90a0
2 changed files with 20 additions and 6 deletions

View File

@ -12,7 +12,7 @@ import Types(Icon(..), Drawing(..), EdgeEnd(..))
import Translate(translateString)
-- TODO Now --
-- Work on Translate.
-- Increase domain of translate.
-- TODO Later --
-- Add a small black border to lines to help distinguish line crossings.
@ -237,14 +237,27 @@ main1 = do
main2 = mainWith ((apply0NDia 3 # bgFrame 0.1 black) :: Diagram B)
main3 :: IO ()
main3 = do
testDecls = [
"y2 = f x1 x2 x3 x4",
"y = x",
"y = f x",
"y = f (g x)",
"y = f (g x1 x2) x3"
]
translateStringToDrawing :: String -> IO (Diagram B)
translateStringToDrawing s = do
let
(drawing, decl) = translateString "y2 = f x1 x2 x3 x4"
(drawing, decl) = translateString s
print decl
print drawing
placedNodes <- renderDrawing drawing
mainWith ((placedNodes # bgFrame 1 (backgroundC colorScheme)) :: Diagram B)
renderDrawing drawing
main3 :: IO ()
main3 = do
drawings <- mapM translateStringToDrawing testDecls
let vCattedDrawings = vcat drawings
mainWith ((vCattedDrawings # bgFrame 1 (backgroundC colorScheme)) :: Diagram B)
main :: IO ()
main = main3

View File

@ -68,6 +68,7 @@ evalExp :: Exp -> State IDState (IconGraph, NameAndPort)
evalExp x = case x of
Var n -> pure $ evalQName n
App exp1 exp2 -> evalApp exp1 exp2
Paren e -> evalExp e
-- TODO other cases
evalRhs :: Rhs -> (IconGraph, NameAndPort)