Commit 25cf1919 authored by Julien Lopez's avatar Julien Lopez
Browse files

[TESTS][EVAL] Add the left part of a match to the environment of the right part

parent 7fb71a7f
Syntax:
- "_" as a keyword (?)
Externals:
- Compile the externals to the parser
Eval:
- Solve the evaluation problems
Tests:
- Update tests to check the evaluation of CDuce (depends on externals)
- Update tests to check the evaluation of CDuce (depends on Eval above)
......@@ -77,9 +77,18 @@ let parse_to_lambda expr =
fail_code=0; expected_type="" } in
let rec aux env brs rhs uid =
match brs with
(* match ? with | m & t -> e | ... *)
(* match orig with | m & t -> e | ... *)
| (m, t, e) :: rest ->
let e = _parse_to_lambda env e in
let rec env_match_value map m nbr = match m with
| MVar(vname) -> Hashtbl.add map vname nbr; map, (nbr + 1)
| MInt(_) | MString(_) -> map, nbr
| MPair(m1, m2) ->
let map, nbr = env_match_value map m1 nbr in
env_match_value map m2 nbr in
let map, nbvars = env_match_value (Hashtbl.create page_size) m 0 in
let new_env = mk_env ~parent:(Some env) ~max_size:env.max_size
~map:map nbvars (env.global_size + nbvars) in
let e = _parse_to_lambda new_env e in
aux env rest (Array.append rhs [|Auto_pat.Match (uid, e)|]) (uid + 1)
| [] -> dummy_state, rhs
in
......
......@@ -31,7 +31,7 @@ let rec print_value v = match v with
let str = if Array.length Sys.argv > 1 then load_file Sys.argv.(1)
else (*"let z = 3 in fun firsts x y -> match x,y with
| (a,_),(b,_) -> a,b (* This (* is (* a nested *) *) comment *)
| _ -> x . z (* That doesn't make any sense *)"*) "match x with | _ -> x" in
| _ -> x . z (* That doesn't make any sense *)"*) "let x = 2 in match x with | x -> x" in
let expr = ExprParser.of_string str in
(*printf "Original: %s\nExpr: " str;
print_expr expr;
......
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