default.txt 911 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env hy
  2. (import os.path)
  3. (import hy.compiler)
  4. (import hy.core)
  5. ;; absolute path for Hy core
  6. (setv *core-path* (os.path.dirname hy.core.--file--))
  7. (defn collect-macros [collected-names opened-file]
  8. (while True
  9. (try
  10. (let [data (read opened-file)]
  11. (if (and (in (first data)
  12. '(defmacro defmacro/g! defn))
  13. (not (.startswith (second data) "_")))
  14. (.add collected-names (second data))))
  15. (except [e EOFError] (break)))))
  16. (defmacro core-file [filename]
  17. `(open (os.path.join *core-path* ~filename)))
  18. (defmacro contrib-file [filename]
  19. `(open (os.path.join *core-path* ".." "contrib" ~filename)))
  20. (defn collect-core-names []
  21. (doto (set)
  22. (.update hy.core.language.*exports*)
  23. (.update hy.core.shadow.*exports*)
  24. (collect-macros (core-file "macros.hy"))
  25. (collect-macros (core-file "bootstrap.hy"))))