Currently the evaluation logic in Evaluator.hs is pretty awkward. This makes implementing control primitives like for a bit cumbersome. Here are some of the problems:
eval method works only on binary expressions with NumLiteral tokens on both sides
evaluating a list involves calling a different method called evaluateList
Here are some initial ideas to fix this:
Rename eval to evalBinOp or something
Have methods for each type of operation, like evalWord, evalExpr, evalList
Have a new method called eval which does pattern matching to determine what kind of evaluation to perform on a token, and then return a logotoken as a return type.
Change the control structures to use eval so that they dont have to be concerned about what is passed in
Currently the evaluation logic in
Evaluator.hs
is pretty awkward. This makes implementing control primitives likefor
a bit cumbersome. Here are some of the problems:eval
method works only on binary expressions withNumLiteral
tokens on both sidesevaluateList
Here are some initial ideas to fix this:
eval
toevalBinOp
or somethingevalWord
,evalExpr
,evalList
eval
which does pattern matching to determine what kind of evaluation to perform on a token, and then return a logotoken as a return type.