1
0
mirror of https://github.com/janet-lang/janet synced 2025-07-06 03:52:54 +00:00

Strip whitespace in boot.dst

This commit is contained in:
Calvin Rose 2018-05-18 22:18:34 -04:00
parent c2199646be
commit 5b62630a9b

View File

@ -62,7 +62,7 @@
(defn one? [x] (== x 1)) (defn one? [x] (== x 1))
(defn integer? [x] (= (type x) :integer)) (defn integer? [x] (= (type x) :integer))
(defn real? [x] (= (type x) :real)) (defn real? [x] (= (type x) :real))
(defn number? [x] (defn number? [x]
(def t (type x)) (def t (type x))
(if (= t :integer) true (= t :real))) (if (= t :integer) true (= t :real)))
(defn fiber? [x] (= (type x) :fiber)) (defn fiber? [x] (= (type x) :fiber))
@ -77,10 +77,10 @@
(defn array? [x] (= (type x) :array)) (defn array? [x] (= (type x) :array))
(defn tuple? [x] (= (type x) :tuple)) (defn tuple? [x] (= (type x) :tuple))
(defn boolean? [x] (= (type x) :boolean)) (defn boolean? [x] (= (type x) :boolean))
(defn bytes? [x] (defn bytes? [x]
(def t (type x)) (def t (type x))
(if (= t :string) true (if (= t :symbol) true (= t :buffer)))) (if (= t :string) true (if (= t :symbol) true (= t :buffer))))
(defn dictionary? [x] (defn dictionary? [x]
(def t (type x)) (def t (type x))
(if (= t :table) true (= t :struct))) (if (= t :table) true (= t :struct)))
(defn indexed? [x] (defn indexed? [x]
@ -959,12 +959,12 @@ onvalue."
(when tail (file.write stdout " (tailcall)")) (when tail (file.write stdout " (tailcall)"))
(file.write stdout "\n")))) (file.write stdout "\n"))))
(defn eval (defn eval
"Evaluates a string in the current environment. If more control over the "Evaluates a string in the current environment. If more control over the
environment is needed, use run-context." environment is needed, use run-context."
[str] [str]
(var state (string str)) (var state (string str))
(defn chunks [buf] (defn chunks [buf]
(def ret state) (def ret state)
(:= state nil) (:= state nil)
(if ret (if ret
@ -987,14 +987,15 @@ environment is needed, use run-context."
(defn checkmodule (defn checkmodule
[f testpath] [f testpath]
(if f f (do (if f f (do
(def p (string.replace-all "?" normname testpath))
(def p (string.replace-all "?" normname testpath)) (def p (string.replace-all "?" normname testpath))
(file.open p)))) (file.open p))))
(reduce checkmodule nil module.paths)) (reduce checkmodule nil module.paths))
(def require (def require
"Require a module with the given name. Will search all of the paths in "Require a module with the given name. Will search all of the paths in
module.paths, then the path as a raw file path. Returns the new environment module.paths, then the path as a raw file path. Returns the new environment
returned from compiling and running the file." returned from compiling and running the file."
(do (do
(def cache @{}) (def cache @{})
(def loading @{}) (def loading @{})
@ -1041,7 +1042,7 @@ symbols into the current environment, prepending a given prefix as needed.
(use the :as or :prefix option to set a prefix). If no prefix is provided, (use the :as or :prefix option to set a prefix). If no prefix is provided,
use the name of the module as a prefix." use the name of the module as a prefix."
(def upath (string (ast.unwrap path))) (def upath (string (ast.unwrap path)))
(def argm (map (fn [x] (def argm (map (fn [x]
(if (and (symbol? x) (= (get x 0) 58)) (if (and (symbol? x) (= (get x 0) 58))
x x
(string x))) (string x)))