prlg/app/Builtins.hs
2022-11-12 23:25:50 +01:00

39 lines
1,005 B
Haskell

module Builtins where
import Code
import Control.Monad.Trans.State.Lazy
import qualified Data.Map as M
import Env
import qualified Operators as O
import Debug.Trace
hello :: BuiltinFunc
hello = BuiltinFunc $ trace "hllo prlg"
addBuiltins :: PrlgEnv ()
addBuiltins = do
a1 <- findStruct "a" 1
a <- findAtom "a"
b <- findAtom "b"
c <- findAtom "c"
b0 <- findStruct "b" 0
any1 <- findStruct "any" 1
eq2 <- findStruct "=" 2
hello0 <- findStruct "hello" 0
modify $ \s ->
s
{ defs =
M.fromList
[ (eq2, [[U (LocalRef 0 Nothing), U (LocalRef 0 Nothing), NoGoal]])
, (a1, [[U (Atom a), NoGoal], [U (Atom b), NoGoal]])
, ( b0
, [ [Goal, U (Struct a1), U (Atom c), LastCall]
, [Goal, U (Struct a1), U (Atom b), LastCall]
])
, (any1, [[U (VoidRef Nothing), NoGoal]])
, (hello0, [[Builtin hello]])
]
, ops = [(O.xfy "," 1000), (O.xfx "=" 700)]
}