be like pablo because pablo
This commit is contained in:
parent
ee6a10e7a5
commit
79b9649979
1 changed files with 20 additions and 19 deletions
39
semantics.ml
39
semantics.ml
|
@ -31,28 +31,29 @@ let rec analyze_expr env ua t = function
|
||||||
raise
|
raise
|
||||||
(SemanticsError
|
(SemanticsError
|
||||||
( Printf.sprintf
|
( Printf.sprintf
|
||||||
"Expected %d arguments but given %d"
|
"Function \"%s\" expects %d arguments but %d was given"
|
||||||
|
c.func
|
||||||
(List.length tl)
|
(List.length tl)
|
||||||
(List.length c.args)
|
(List.length c.args)
|
||||||
, c.pos ));
|
, c.pos ));
|
||||||
( Call
|
let args =
|
||||||
( c.func
|
List.map2
|
||||||
, List.map2
|
(fun t e ->
|
||||||
(fun t e ->
|
let e2, t2 = analyze_expr env ua t e in
|
||||||
let e2, t2 = analyze_expr env ua t e in
|
if t2 = t
|
||||||
if t2 = t
|
then e2
|
||||||
then e2
|
else
|
||||||
else
|
errt
|
||||||
errt
|
t
|
||||||
t
|
t2
|
||||||
t2
|
(match e with
|
||||||
(match e with
|
| Syntax.Val v -> v.pos
|
||||||
| Syntax.Val v -> v.pos
|
| Syntax.Var v -> v.pos
|
||||||
| Syntax.Var v -> v.pos
|
| Syntax.Call c -> c.pos))
|
||||||
| Syntax.Call c -> c.pos))
|
tl
|
||||||
tl
|
c.args
|
||||||
c.args )
|
in
|
||||||
, ret_t )
|
Call (c.func, args), ret_t
|
||||||
| _ -> raise (SemanticsError ("\"" ^ c.func ^ "\" isn't a function", c.pos)))
|
| _ -> raise (SemanticsError ("\"" ^ c.func ^ "\" isn't a function", c.pos)))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Reference in a new issue