Skip to content

How to expand all macros of a script? #1423

Answered by CosmicToast
MaxGyver83 asked this question in Q&A
Discussion options

You must be logged in to vote

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:

# 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)))]

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MaxGyver83
Comment options

Answer selected by MaxGyver83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants