JanetDocsPlaygroundI'm feeling luckyGitHub sign in

dofile



    function
    boot.janet on line 2500, column 1

    (dofile path &keys {:read read :parser parser :source src 
    :evaluator evaluator :expander expander :env env :exit exit})

    Evaluate a file and return the resulting environment. :env, 
    :expander, :evaluator, :read, and :parser are passed through to the 
    underlying run-context call. If exit is true, any top level errors 
    will trigger a call to (os/exit 1) after printing the error.


1 exampleSign in to add an example
Loading...
# Gathers all of the calls of "declare-" into a table from the project.janet file at path
(defn capture-declares [path] 
    (def *capture* @{})
    (defn append-capture [name & arg]
      (update *capture* name (fn [val] (array/push (or val @[]) ;arg))))
    (defn only-captures [form] 
      (when (string/has-prefix? "declare-" (string (form 0)))
        (append-capture (form 0) (slice form 1))
        form)
      nil)
    (dofile path :expander only-captures)
    *capture*)
yumaikasPlayground