diff --git a/example.lsp b/example.lsp index 30a4d2a..bda5a78 100644 --- a/example.lsp +++ b/example.lsp @@ -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 diff --git a/sexpr.ml b/sexpr.ml index e01c7cb..88a70e0 100644 --- a/sexpr.ml +++ b/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