simplify and fix
This commit is contained in:
22
sexpr.ml
22
sexpr.ml
@@ -682,23 +682,13 @@ module SExprMacroExp = struct
|
||||
|
||||
let rec eval (ctx: (string * (SExpr.t * SExpr.t)) list) s =
|
||||
let open SExpr in
|
||||
let sli, ctx = match s with
|
||||
Cons(l,r) ->
|
||||
(* Cons(1, Cons(2, Nil))
|
||||
l: Cons(1, Nil)
|
||||
r: Cons(Cons(2, Nil), Nil)
|
||||
append r l: Cons(1, Cons(Cons(2, Nil), Nil))
|
||||
*)
|
||||
let l, ctx = eval ctx l in
|
||||
let r, ctx = eval ctx r in
|
||||
begin match append r l with
|
||||
Cons(l, Cons(r, Nil)) -> li1 @@ Cons(l,r)
|
||||
| Nil -> Nil
|
||||
| x -> raise (FIXME x)
|
||||
end, ctx
|
||||
| s -> li1 s, ctx
|
||||
let s, ctx = if is_list s then
|
||||
aggr_flat_map eval ctx s
|
||||
else
|
||||
s, ctx
|
||||
in
|
||||
aggr_flat_map check_expands_while ctx sli
|
||||
let s, ctx = check_expands_while ctx s in
|
||||
s, ctx
|
||||
(* expr -> list(new exprs) * bool:changed * ctx *)
|
||||
and check_expands ctx s =
|
||||
let open SExpr in
|
||||
|
Reference in New Issue
Block a user