-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSys.hs
35 lines (26 loc) · 1.15 KB
/
Sys.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module Sys where
import Absmyjs
import Data.List
import qualified Data.Map as M
import qualified Memory as Mem
import qualified Env as Env
import Types
append v2 v1 = StringVal $ (show v1) ++ (show v2)
sfLog params = do
let toPrint = StringVal $ (intercalate " " (map show params)) ++ "\n" in do
Env.modify (append toPrint) "output"
return UndefinedVal
qIdentResolve (QIdent identList) = _qIdentResolve identList
where _qIdentResolve [] = []
_qIdentResolve (id:ids) =
case id of
IdentPart (IIdentBare (Ident ident)) ->
(LiteralExpr (StringLiteral ident)):(_qIdentResolve ids)
IdentPart (IIdentIndexed (Ident ident) exp) ->
(LiteralExpr (StringLiteral ident)):exp:(_qIdentResolve ids)
paramsToList (ParamNameList ids) = map (\(Ident i) -> i) ids
isSysFunc name = name == "log"
callSysFunc (BuiltinFunctionVal name) params = case name of
"log" -> sfLog params
sysFunc name = BuiltinFunctionVal $ case name of
"log" -> "log"