diff --git a/sexpr.ml b/sexpr.ml index 4bcd027..e01c7cb 100644 --- a/sexpr.ml +++ b/sexpr.ml @@ -718,12 +718,37 @@ module SExprMacroExp = struct in Nil, false, ctx end - | Cons(Id ":c-eq", Cons(l, Cons(r, Nil))) -> begin - if l = r then - Nil, true, ctx - else - Cons(Nil, Nil), true, ctx - end + | Cons(Id ":atm-to-str", Cons(Id x, Nil)) + | Cons(Id ":atm-to-str", Cons(Str x, Nil)) -> + li1 (Str x), true, ctx + | Cons(Id ":atm-to-str", Cons(Int x, Nil)) -> + li1 (Str (Int.to_string x)), true, ctx + | Cons(Id ":atm-to-str", Cons(Flt x, Nil)) -> + li1 (Str (Float.to_string x)), true, ctx + | Cons(Id ":str-cat", Cons(Str l, Cons(Str r, Nil))) -> + li1 (Str (l ^ r)), true, ctx + | Cons(Id ":c-eq", Cons(l, Cons(r, Nil))) when l = r -> + Nil, true, ctx + | Cons(Id ":c-int", Cons(Int _, Nil)) -> + Nil, true, ctx + | Cons(Id ":c-float", Cons(Flt _, Nil)) -> + Nil, true, ctx + | Cons(Id ":c-num", Cons(Int _, Nil)) + | Cons(Id ":c-num", Cons(Flt _, Nil)) -> + Nil, true, ctx + | Cons(Id ":c-str", Cons(Str _, Nil)) -> + Nil, true, ctx + | Cons(Id ":c-id", Cons(Id _, Nil)) -> + Nil, true, ctx + | Cons(Id ":c-list", Cons(x, Nil)) when is_list x -> + Nil, true, ctx + | Cons(Id ":c-atm", Cons(Int _, Nil)) + | Cons(Id ":c-atm", Cons(Flt _, Nil)) + | 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