Skip to content

Instantly share code, notes, and snippets.

@vyzo
Last active April 25, 2019 20:49
Show Gist options
  • Save vyzo/378ffd068b191c669606b25683d7c9bd to your computer and use it in GitHub Desktop.
Save vyzo/378ffd068b191c669606b25683d7c9bd to your computer and use it in GitHub Desktop.
import nesting for gerbil
(import (for-syntax :std/misc/list))
(export group-in)
(defsyntax-for-import (group-in stx)
(def (expand-path top mod)
(syntax-case mod ()
((nested mod ...)
(map (lambda (mod) (stx-identifier top top "/" mod))
(flatten (map (cut expand-path #'nested <>) #'(mod ...)))))
(id
(identifier? #'id)
(stx-identifier top top "/" #'id))))
(syntax-case stx ()
((_ top mod ...)
(cons begin: (flatten (map (cut expand-path #'top <>) #'(mod ...)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment