Commit 9fa6c435 authored by Pietro Abate's avatar Pietro Abate

[r2003-01-30 15:35:28 by cvscast] Added the mod integer operation - Beppe...

[r2003-01-30 15:35:28 by cvscast] Added the mod integer operation - Beppe modified memento accordingly

Original author: cvscast
Date: 2003-01-30 15:35:28+00:00
parent 8068398f
......@@ -44,4 +44,16 @@ Beppe 2003-01-23
Add libraries inclusion
======================================================================
Beppe 2003-01-23
Add the following types.
<!--> String
<? T> String
<!cdata> String
======================================================================
\ No newline at end of file
......@@ -137,6 +137,7 @@ EXTEND
| op = [ LIDENT "dump_to_file" ];
e1 = expr LEVEL "no_appl"; e2 = expr -> mk loc (Op (op, [e1;e2]))
| e1 = SELF; LIDENT "div"; e2 = expr -> mk loc (Op ("/", [e1;e2]))
| e1 = SELF; LIDENT "mod"; e2 = expr -> mk loc (Op ("mod", [e1;e2]))
| e1 = SELF; e2 = expr -> mk loc (Apply (e1,e2))
]
......
......@@ -60,6 +60,7 @@ let rec eval env e0 =
| Typed.Op ("*", [e1; e2]) -> eval_mul (eval env e1) (eval env e2)
| Typed.Op ("-", [e1; e2]) -> eval_sub (eval env e1) (eval env e2)
| Typed.Op ("/", [e1; e2]) -> eval_div (eval env e1) (eval env e2)
| Typed.Op ("mod", [e1; e2]) -> eval_mod (eval env e1) (eval env e2)
| Typed.Op ("load_xml", [e]) -> eval_load_xml (eval env e)
| Typed.Op ("load_html", [e]) -> eval_load_html (eval env e)
| Typed.Op ("print_xml", [e]) -> eval_print_xml (eval env e)
......@@ -129,6 +130,10 @@ and eval_div x y = match (x,y) with
| (Integer x, Integer y) -> Integer (Big_int.div_big_int x y)
| _ -> assert false
and eval_mod x y = match (x,y) with
| (Integer x, Integer y) -> Integer (Big_int.mod_big_int x y)
| _ -> assert false
and eval_load_xml e =
Load_xml.load_xml (get_string e)
......
......@@ -860,7 +860,7 @@ and type_op loc op args =
type_int_binop Intervals.add loc1 t1 loc2 t2
| "-", [loc1,t1; loc2,t2] ->
type_int_binop Intervals.sub loc1 t1 loc2 t2
| ("*" | "/"), [loc1,t1; loc2,t2] ->
| ("*" | "/" | "mod"), [loc1,t1; loc2,t2] ->
type_int_binop (fun i1 i2 -> Intervals.any) loc1 t1 loc2 t2
| "@", [loc1,t1; loc2,t2] ->
check loc1 t1 Sequence.any
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment