git @ Cat's Eye Technologies UampirNexol / a5fc8ad
Describe situation of the evaluator code better. Chris Pressey 13 days ago
1 changed file(s) with 13 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
44 module Language.UampirNexol.Eval where
55
66 --
7 -- Evaluator for UampirNexol expressions. The evaluator is not meant to have
8 -- value as something that is run, so much as something that describes
9 -- meanings of (and can thus assign meanings to) UampirNexol expressions.
7 -- Evaluator for UampirNexol expressions.
8 --
9 -- The evaluator is not meant to have value as something that is executed,
10 -- so much as something that describes meanings of (and can thus assign
11 -- meanings to) UampirNexol expressions.
12 --
13 -- The definition of the evaluator given here is also very poor. Better
14 -- would be if the set of Values included functions. A typical UampirNexol
15 -- program is a function taking states to states. Evaluating such an
16 -- expression should result in a function value. But the way we have it
17 -- here, necessarily we need to apply that function to a (state) value.
18 -- We should change that.
1019 --
1120
1221 import qualified Data.Map as Map
3039 let
3140 i = case eval expr env v of
3241 (Const (IntLit this)) -> this
33 other -> error $ "eek: " ++ (show other)
42 other -> error $ "eek: " ++ (show other)
3443 i' = i `mod` 256
3544 z' = if i' == 0 then 1 else 0
3645 n' = if i' > 127 then 1 else 0