How to expand all macros of a script? #1423
Answered
by
CosmicToast
MaxGyver83
asked this question in
Q&A
-
Is there a simple way to expand all macros of a script? Like |
Beta Was this translation helpful? Give feedback.
Answered by
CosmicToast
Mar 9, 2024
Replies: 1 comment 1 reply
-
You can just parse the source script and macex on it. # test.janet
(do
(print "hi")
(%= 1 2)) # test2.janet
(def src (parse-all (slurp "test.janet")))
(pp src)
(pp (macex src)) janet test2.janet
# => @[(do (print "hi") (%= 1 2))]
# => @[(do (print "hi") (set 1 (<function %> 1 2)))] |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
MaxGyver83
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can just parse the source script and macex on it.
Though note that it won't be super readable, and won't apply to modules (I'm pretty sure anyway).
Here's an example: