diff --git a/Eval.hs b/Eval.hs index b5f605122c67053860f36612a8769c48e4763388..7f9a370a0949bc451c42545d646b43d407119c1d 100644 --- a/Eval.hs +++ b/Eval.hs @@ -39,7 +39,11 @@ eval env expr = let (eval', evalFull') = (eval env, evalFull env) in case expr o _ -> expr evalControl1 :: Environment -> Expr -> Expr -evalControl1 env (Control _ (currentExpr:exprs)) = let output = eval env currentExpr in Control output exprs +evalControl1 env (Control last (currentExpr:exprs)) = let output = eval env currentExprFull in Control output exprs + where + currentExprFull = case currentExpr of + (FuncCall func [] args) -> FuncCall func [last] args + _ -> currentExpr evalFull = eval --evalFull env (Set xs) = Set (map (eval env) xs) -- evaluates expression fully (not just weak head normal form) diff --git a/Parser.y b/Parser.y index 030a148fcbe77c70594bebb70d4237544c66492b..8be3046a4cf79c55f8acf8a3bd313b7f1ca9e2b2 100644 --- a/Parser.y +++ b/Parser.y @@ -47,6 +47,7 @@ SetFuncCalls : SetFuncCall {[$1]} | SetFuncCall';' SetFuncCalls {$1:$3} SetFuncCall : filter '['SetName']' '('Func')' {FuncCall (PredefFunc Filter) [Var $3] [$6]} + | filter '('Func')' {FuncCall (PredefFunc Filter) [] [$3]} Func : '\\' '(' VarNames ')' "->" Expr {FuncDef [] $3 $6} diff --git a/sampleprogram.txt b/sampleprogram.txt index f7c9aacf95505e416def94eba4ca81d2b2eee682..25021ecea2a8e47b355fd3e9fd1d7d07293e7a6e 100644 --- a/sampleprogram.txt +++ b/sampleprogram.txt @@ -2,4 +2,4 @@ SampleSet .out -filter[SampleSet](\(r) -> r[0] == "hello") \ No newline at end of file +filter (\(r) -> r[0] == "hello") \ No newline at end of file