mirror of
https://github.com/janet-lang/janet
synced 2024-11-28 02:59:54 +00:00
Format boot.janet with janet-format.
This commit is contained in:
parent
181f0341f5
commit
c75b088ff8
@ -948,12 +948,12 @@
|
|||||||
(def call-buffer @[])
|
(def call-buffer @[])
|
||||||
(while true
|
(while true
|
||||||
(forv i 0 ninds
|
(forv i 0 ninds
|
||||||
(let [old-key (in iterkeys i)
|
(let [old-key (in iterkeys i)
|
||||||
ii (in inds i)
|
ii (in inds i)
|
||||||
new-key (next ii old-key)]
|
new-key (next ii old-key)]
|
||||||
(if (= nil new-key)
|
(if (= nil new-key)
|
||||||
(do (set done true) (break))
|
(do (set done true) (break))
|
||||||
(do (set (iterkeys i) new-key) (array/push call-buffer (in ii new-key))))))
|
(do (set (iterkeys i) new-key) (array/push call-buffer (in ii new-key))))))
|
||||||
(if done (break))
|
(if done (break))
|
||||||
(array/push res (f ;call-buffer))
|
(array/push res (f ;call-buffer))
|
||||||
(array/clear call-buffer))))
|
(array/clear call-buffer))))
|
||||||
@ -1591,8 +1591,8 @@
|
|||||||
(each x ind
|
(each x ind
|
||||||
(def y (f x))
|
(def y (f x))
|
||||||
(cond
|
(cond
|
||||||
is-new (do (set is-new false) (set category y) (set span @[x]) (array/push ret span))
|
is-new (do (set is-new false) (set category y) (set span @[x]) (array/push ret span))
|
||||||
(= y category) (array/push span x)
|
(= y category) (array/push span x)
|
||||||
(do (set category y) (set span @[x]) (array/push ret span))))
|
(do (set category y) (set span @[x]) (array/push ret span))))
|
||||||
ret)
|
ret)
|
||||||
|
|
||||||
@ -1842,7 +1842,7 @@
|
|||||||
(when isarr
|
(when isarr
|
||||||
(array/push anda (get-length-sym s))
|
(array/push anda (get-length-sym s))
|
||||||
(def pattern-len
|
(def pattern-len
|
||||||
(if-let [ rest-idx (find-index (fn [x] (= x '&)) pattern) ]
|
(if-let [rest-idx (find-index (fn [x] (= x '&)) pattern)]
|
||||||
rest-idx
|
rest-idx
|
||||||
(length pattern)))
|
(length pattern)))
|
||||||
(array/push anda [<= pattern-len (get-length-sym s)]))
|
(array/push anda [<= pattern-len (get-length-sym s)]))
|
||||||
@ -2282,9 +2282,9 @@
|
|||||||
(def source-code (file/read f :all))
|
(def source-code (file/read f :all))
|
||||||
(var index 0)
|
(var index 0)
|
||||||
(repeat (dec line)
|
(repeat (dec line)
|
||||||
(if-not index (break))
|
(if-not index (break))
|
||||||
(set index (string/find "\n" source-code index))
|
(set index (string/find "\n" source-code index))
|
||||||
(if index (++ index)))
|
(if index (++ index)))
|
||||||
(when index
|
(when index
|
||||||
(def line-end (string/find "\n" source-code index))
|
(def line-end (string/find "\n" source-code index))
|
||||||
(eprint " " (string/slice source-code index line-end))
|
(eprint " " (string/slice source-code index line-end))
|
||||||
@ -2586,8 +2586,8 @@
|
|||||||
(while (parser/has-more p)
|
(while (parser/has-more p)
|
||||||
(array/push ret (parser/produce p)))
|
(array/push ret (parser/produce p)))
|
||||||
(if (= :error (parser/status p))
|
(if (= :error (parser/status p))
|
||||||
(error (parser/error p))
|
(error (parser/error p))
|
||||||
ret)))
|
ret)))
|
||||||
|
|
||||||
(def load-image-dict
|
(def load-image-dict
|
||||||
``A table used in combination with `unmarshal` to unmarshal byte sequences created
|
``A table used in combination with `unmarshal` to unmarshal byte sequences created
|
||||||
@ -3027,7 +3027,7 @@
|
|||||||
|
|
||||||
# Parse state
|
# Parse state
|
||||||
(var cursor 0) # indexes into string for parsing
|
(var cursor 0) # indexes into string for parsing
|
||||||
(var stack @[]) # return value for this block.
|
(var stack @[]) # return value for this block.
|
||||||
|
|
||||||
# Traversal helpers
|
# Traversal helpers
|
||||||
(defn c [] (get str cursor))
|
(defn c [] (get str cursor))
|
||||||
@ -3146,38 +3146,40 @@
|
|||||||
(= b (chr "_")) (delim :underline)
|
(= b (chr "_")) (delim :underline)
|
||||||
(= b (chr "`")) (delim :code)
|
(= b (chr "`")) (delim :code)
|
||||||
(= b (chr "*"))
|
(= b (chr "*"))
|
||||||
(if (= (chr "*") (get line (+ i 1)))
|
(if (= (chr "*") (get line (+ i 1)))
|
||||||
(do (++ i)
|
(do (++ i)
|
||||||
(delim :bold))
|
(delim :bold))
|
||||||
(delim :italics))
|
(delim :italics))
|
||||||
(do (++ token-length) (buffer/push token b))))
|
(do (++ token-length) (buffer/push token b))))
|
||||||
(endtoken)
|
(endtoken)
|
||||||
(tuple/slice tokens))
|
(tuple/slice tokens))
|
||||||
|
|
||||||
(set parse-blocks (fn parse-blocks [indent]
|
(set
|
||||||
(var new-indent indent)
|
parse-blocks
|
||||||
(var p-start nil)
|
(fn parse-blocks [indent]
|
||||||
(var p-end nil)
|
(var new-indent indent)
|
||||||
(defn p-line []
|
(var p-start nil)
|
||||||
(unless p-start
|
(var p-end nil)
|
||||||
(set p-start cursor))
|
(defn p-line []
|
||||||
(skipline)
|
(unless p-start
|
||||||
(set p-end cursor)
|
(set p-start cursor))
|
||||||
(set new-indent (skipwhite)))
|
(skipline)
|
||||||
(defn finish-p []
|
(set p-end cursor)
|
||||||
(when (and p-start (> p-end p-start))
|
(set new-indent (skipwhite)))
|
||||||
(push (tokenize-line (getslice p-start p-end)))
|
(defn finish-p []
|
||||||
(set p-start nil)))
|
(when (and p-start (> p-end p-start))
|
||||||
(while (and (c) (>= new-indent indent))
|
(push (tokenize-line (getslice p-start p-end)))
|
||||||
(cond
|
(set p-start nil)))
|
||||||
(nl?) (do (finish-p) (c++) (set new-indent (skipwhite)))
|
(while (and (c) (>= new-indent indent))
|
||||||
(ul?) (do (finish-p) (set new-indent (parse-list ul? :ul new-indent)))
|
(cond
|
||||||
(ol?) (do (finish-p) (set new-indent (parse-list ol? :ol new-indent)))
|
(nl?) (do (finish-p) (c++) (set new-indent (skipwhite)))
|
||||||
(fcb?) (do (finish-p) (set new-indent (parse-fcb new-indent)))
|
(ul?) (do (finish-p) (set new-indent (parse-list ul? :ul new-indent)))
|
||||||
(>= new-indent (+ 4 indent)) (do (finish-p) (set new-indent (parse-icb new-indent)))
|
(ol?) (do (finish-p) (set new-indent (parse-list ol? :ol new-indent)))
|
||||||
(p-line)))
|
(fcb?) (do (finish-p) (set new-indent (parse-fcb new-indent)))
|
||||||
(finish-p)
|
(>= new-indent (+ 4 indent)) (do (finish-p) (set new-indent (parse-icb new-indent)))
|
||||||
new-indent))
|
(p-line)))
|
||||||
|
(finish-p)
|
||||||
|
new-indent))
|
||||||
|
|
||||||
# Handle first line specially for defn, defmacro, etc.
|
# Handle first line specially for defn, defmacro, etc.
|
||||||
(when (= (chr "(") (in str 0))
|
(when (= (chr "(") (in str 0))
|
||||||
@ -3314,10 +3316,10 @@
|
|||||||
(do
|
(do
|
||||||
(def [fullpath mod-kind] (module/find (string sym)))
|
(def [fullpath mod-kind] (module/find (string sym)))
|
||||||
(if-let [mod-env (in module/cache fullpath)]
|
(if-let [mod-env (in module/cache fullpath)]
|
||||||
(print-module-entry {:module true
|
(print-module-entry {:module true
|
||||||
:kind mod-kind
|
:kind mod-kind
|
||||||
:source-map [fullpath nil nil]
|
:source-map [fullpath nil nil]
|
||||||
:doc (in mod-env :doc)})
|
:doc (in mod-env :doc)})
|
||||||
(print "symbol " sym " not found."))))
|
(print "symbol " sym " not found."))))
|
||||||
(print-module-entry x)))
|
(print-module-entry x)))
|
||||||
|
|
||||||
@ -3600,8 +3602,8 @@
|
|||||||
(def ,chan (,ev/chan))
|
(def ,chan (,ev/chan))
|
||||||
(def ,res @[])
|
(def ,res @[])
|
||||||
(,wait-for-fibers ,chan
|
(,wait-for-fibers ,chan
|
||||||
,(seq [[i body] :pairs bodies]
|
,(seq [[i body] :pairs bodies]
|
||||||
~(,ev/go (fn [] (put ,res ,i ,body)) nil ,chan)))
|
~(,ev/go (fn [] (put ,res ,i ,body)) nil ,chan)))
|
||||||
,res))))
|
,res))))
|
||||||
|
|
||||||
(compwhen (dyn 'net/listen)
|
(compwhen (dyn 'net/listen)
|
||||||
@ -3683,7 +3685,7 @@
|
|||||||
(try
|
(try
|
||||||
(dofile path :evaluator flycheck-evaluator ;(kvs kwargs))
|
(dofile path :evaluator flycheck-evaluator ;(kvs kwargs))
|
||||||
([e f]
|
([e f]
|
||||||
(debug/stacktrace f e "")))
|
(debug/stacktrace f e "")))
|
||||||
(table/clear module/cache)
|
(table/clear module/cache)
|
||||||
(merge-into module/cache old-modcache)
|
(merge-into module/cache old-modcache)
|
||||||
nil)
|
nil)
|
||||||
@ -3701,7 +3703,7 @@
|
|||||||
(defn- run-main
|
(defn- run-main
|
||||||
[env subargs arg]
|
[env subargs arg]
|
||||||
(when-let [entry (in env 'main)
|
(when-let [entry (in env 'main)
|
||||||
main (or (get entry :value) (in (get entry :ref) 0))]
|
main (or (get entry :value) (in (get entry :ref) 0))]
|
||||||
(def guard (if (get env :debug) :ydt :y))
|
(def guard (if (get env :debug) :ydt :y))
|
||||||
(defn wrap-main [&]
|
(defn wrap-main [&]
|
||||||
(main ;subargs))
|
(main ;subargs))
|
||||||
@ -3873,8 +3875,8 @@
|
|||||||
(file/read stdin :line buf))
|
(file/read stdin :line buf))
|
||||||
(def env (make-env))
|
(def env (make-env))
|
||||||
(when-let [profile.janet (dyn *profilepath*)]
|
(when-let [profile.janet (dyn *profilepath*)]
|
||||||
(def new-env (dofile profile.janet :exit true))
|
(def new-env (dofile profile.janet :exit true))
|
||||||
(merge-module env new-env "" false))
|
(merge-module env new-env "" false))
|
||||||
(when debug-flag
|
(when debug-flag
|
||||||
(put env *debug* true)
|
(put env *debug* true)
|
||||||
(put env *redef* true))
|
(put env *redef* true))
|
||||||
|
Loading…
Reference in New Issue
Block a user