dont eval macro def args
This commit is contained in:
16
sexpr.ml
16
sexpr.ml
@@ -692,15 +692,23 @@ module SExprMacroExp = struct
|
||||
|
||||
let rec eval (ctx: (string * (SExpr.t * SExpr.t)) list) s =
|
||||
let open SExpr in
|
||||
let s, ch1, ctx = if is_list s then begin
|
||||
let aggr_eval ctx s = begin
|
||||
let s, (ch,ctx) = aggr_flat_map (fun aggr s ->
|
||||
let ch1, ctx = aggr in
|
||||
let s, ch2, ctx = eval ctx s in
|
||||
s, ((ch1 || ch2), ctx)
|
||||
) (false, ctx) s in
|
||||
s, ch, ctx
|
||||
end else
|
||||
s, false, ctx
|
||||
end in
|
||||
let s, ch1, ctx = match s with
|
||||
Cons(Id ":macro", Cons(name, Cons(margs, rr))) ->
|
||||
let rr, ch, ctx = aggr_eval ctx rr in
|
||||
Cons(Id ":macro", Cons(name, Cons(margs, rr))), ch, ctx
|
||||
| s when is_list s -> begin
|
||||
aggr_eval ctx s
|
||||
end
|
||||
| _ ->
|
||||
s, false, ctx
|
||||
in
|
||||
let s, ch2, ctx = check_expands ctx s in
|
||||
s, (ch1 || ch2), ctx
|
||||
@@ -747,8 +755,6 @@ module SExprMacroExp = struct
|
||||
| Cons(Id ":c-atm", Cons(Str _, Nil))
|
||||
| Cons(Id ":c-atm", Cons(Id _, Nil)) ->
|
||||
Nil, true, ctx
|
||||
| Cons(Id ":c-atm", Cons(x, Nil)) when is_list x ->
|
||||
Nil, true, ctx
|
||||
| Cons(Id i, r) when String.starts_with ~prefix:":" i ->
|
||||
let i = String.sub i 1 ((String.length i) - 1) in
|
||||
check_expands_macro i ctx r s
|
||||
|
Reference in New Issue
Block a user