c
This commit is contained in:
17
sexpr.ml
17
sexpr.ml
@@ -500,7 +500,11 @@ module SExpr = struct
|
||||
append vv x, acc
|
||||
| _ -> raise Not_Sexpr_List
|
||||
|
||||
(* TODO: test aggr_flat_map *)
|
||||
let () = test "SExpr.aggr_flat_map.0" @@ begin fun () ->
|
||||
let a = Cons(Int 1, Cons(Int 2, Nil))
|
||||
and p = Cons(Int 1, Cons(Int 2, Cons(Int 2, Cons(Int 4, Nil)))) in
|
||||
assert (fst (aggr_flat_map (fun aggr x -> Cons(x, Cons((match x with Int(n) -> Int(n + aggr) | x -> x) , Nil)) , aggr + 1) 1 a) = p)
|
||||
end
|
||||
|
||||
(* a "list" here is:
|
||||
* ( e1 . ( e2 . ( e3 . NIL ) ) )
|
||||
@@ -682,6 +686,11 @@ module SExprMacroExp = struct
|
||||
|
||||
let rec eval (ctx: (string * (SExpr.t * SExpr.t)) list) s =
|
||||
let open SExpr in
|
||||
Format.printf "ctx:\n%!";
|
||||
List.iter begin fun vv ->
|
||||
let k,v = vv in
|
||||
Format.printf "- %s = %a%a\n%!" k pp_t (fst v) pp_t (snd v)
|
||||
end ctx;
|
||||
let s, ctx = if is_list s then
|
||||
aggr_flat_map eval ctx s
|
||||
else
|
||||
@@ -721,11 +730,11 @@ module SExprMacroExp = struct
|
||||
end
|
||||
| s -> li1 s, false, ctx
|
||||
and check_expands_while ctx s =
|
||||
let v, c, ctx = check_expands ctx s in
|
||||
let s', c, ctx' = check_expands ctx s in
|
||||
if c then
|
||||
check_expands_while ctx v
|
||||
check_expands_while ctx' s'
|
||||
else
|
||||
v, ctx
|
||||
s', ctx'
|
||||
and match_macro_arg args margs =
|
||||
let open SExpr in
|
||||
match args, margs with
|
||||
|
Reference in New Issue
Block a user