Compare commits

..

No commits in common. "c15a736236b76a8fc58a223bf50c61fb682ae0c6" and "7218e4b4fb8949bf9218d0cc9127bd5097688460" have entirely different histories.

6 changed files with 16 additions and 14 deletions

View File

@ -19,11 +19,12 @@ executable cherry
default-language: Haskell2010
other-modules: ExprType,
Parser,
ExprParser,
TokenType,
Lexer,
TokenParser,
Evaluator,
ParserUtils
ParserUtils,
TokenParser
build-depends: base >= 4.7 && < 5,
containers,

View File

@ -4,9 +4,11 @@ import qualified Data.Map as M
import ExprType
type Env = M.Map String Expr
type Proc = String
-- TODO: create a separated file for builtinProcs
-- TODO: create a BuiltinProc or something like that in data Expr, and make + a builtin proc
-- TODO: create enviroments
base :: Env
base = M.fromList [
@ -15,8 +17,7 @@ base = M.fromList [
eval :: Env -> Expr -> (Env, Expr)
eval env (IntE x) = (env, IntE x)
eval env (VarE v) = (M.insert v nExpr nEnv, nExpr)
where (nEnv, nExpr) = eval env $ env M.! v
eval env (VarE v) = (env, env M.! v)
eval env (SetE v expr) = (M.insert v expr env, NilE)
eval env NilE = (env, NilE)

View File

@ -1,8 +1,8 @@
module Parser where
module ExprParser where
import Text.Parsec
import Text.Parsec.String
import Lexer
import TokenParser
import TokenType
import ExprType

View File

@ -4,9 +4,9 @@ data Expr = IntE Integer
| VarE String
| ProcedureE String [Expr]
| SetE String Expr
| NilE deriving (Show)
| NilE
-- instance Show Expr where
-- show (IntE x) = show x
-- show (VarE x) = x ++ " ; var"
-- show NilE = "nil"
instance Show Expr where
show (IntE x) = show x
show (VarE x) = x ++ " ; var"
show NilE = "nil"

View File

@ -1,7 +1,7 @@
module Main where
import Evaluator
import Parser
import ExprParser
import Control.Monad
import Data.Maybe
import System.Console.Haskeline

View File

@ -1,4 +1,4 @@
module Lexer where
module TokenParser where
import Text.ParserCombinators.Parsec
import ParserUtils