dont eval macro def args

This commit is contained in:
2025-08-31 01:15:23 +02:00
parent bd4711b250
commit e2a49ae8a1
2 changed files with 14 additions and 9 deletions

View File

@@ -6,17 +6,16 @@
(:macro seq (hd .. tl)
(:t (':seq hd) (':seq tl)))
(:macro @ (k)
(:macro @ ( (k(:c-atm _)) )
(:t k ":"))
(:macro @ (k v)
(:macro @ ( (k(:c-atm _)) v )
(:t k ": " v))
(:macro @ (k v .. other)
(:macro @ ( (k(:c-atm _)) v .. other)
(k v)
other)
(name "Complex CI/CD Pipeline")
(on

View File

@@ -692,14 +692,22 @@ 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
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
@@ -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