stash work
This commit is contained in:
parent
f02532ee40
commit
d253dc3d3e
|
@ -33,7 +33,7 @@
|
||||||
(array? seq) (array/slice 1 len))))
|
(array? seq) (array/slice 1 len))))
|
||||||
|
|
||||||
(defn some? [val] (not (nil? val)))
|
(defn some? [val] (not (nil? val)))
|
||||||
|
|
||||||
(defn apply-kw-parser [kw tokens]
|
(defn apply-kw-parser [kw tokens]
|
||||||
(let [token (first tokens)]
|
(let [token (first tokens)]
|
||||||
#(if (= kw (get token :type)) (println "Matched " kw))
|
#(if (= kw (get token :type)) (println "Matched " kw))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(def reserved-words
|
(def reserved-words
|
||||||
"List of Ludus reserved words."
|
"List of Ludus reserved words."
|
||||||
## see ludus-spec repo for more info
|
## see ludus-spec repo for more info
|
||||||
{"as" :as ## impl for `import`# not yet for patterns
|
{"as" :as ## impl
|
||||||
"do" :do ## impl
|
"do" :do ## impl
|
||||||
"else" :else ## impl
|
"else" :else ## impl
|
||||||
"false" :false ## impl -> literal word
|
"false" :false ## impl -> literal word
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
|
|
||||||
(def terminators {
|
(def terminators {
|
||||||
":" true
|
":" true
|
||||||
"#" true
|
";" true
|
||||||
"\n" true
|
"\n" true
|
||||||
"{" true
|
"{" true
|
||||||
"}" true
|
"}" true
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
:line (get scanner :line)
|
:line (get scanner :line)
|
||||||
:start (get scanner :start)
|
:start (get scanner :start)
|
||||||
:source (get scanner :source)
|
:source (get scanner :source)
|
||||||
:start (get scanner :input)}))
|
:input (get scanner :input)}))
|
||||||
|
|
||||||
## TODO: errors should also be in the vector of tokens
|
## TODO: errors should also be in the vector of tokens
|
||||||
## The goal is to be able to be able to hand this to an LSP?
|
## The goal is to be able to be able to hand this to an LSP?
|
||||||
|
@ -190,17 +190,15 @@
|
||||||
## TODO: activate string interpolation
|
## TODO: activate string interpolation
|
||||||
(defn- add-string
|
(defn- add-string
|
||||||
[scanner]
|
[scanner]
|
||||||
|
(print "Adding string")
|
||||||
(defn recur [scanner buff interpolate?]
|
(defn recur [scanner buff interpolate?]
|
||||||
|
(print "\n printing a thing from add-stirng" buff)
|
||||||
(let [char (current-char scanner)]
|
(let [char (current-char scanner)]
|
||||||
(case char
|
(case char
|
||||||
"{" (recur (advance scanner) (buffer/push buff char) true)
|
"{" (recur (advance scanner) (buffer/push buff char) true)
|
||||||
# allow multiline strings
|
# allow multiline strings
|
||||||
"\n" (recur (update (advance scanner) :line inc) (buffer/push buff char) interpolate?)
|
"\n" (recur (update (advance scanner) :line inc) (buffer/push buff char) interpolate?)
|
||||||
"\"" (if interpolate?
|
"\"" (add-token (advance scanner) :string (string buff))
|
||||||
#(add-token (advance scanner) :interpolated string)
|
|
||||||
#no interpolation yet
|
|
||||||
(add-token (advance scanner) :string (string buff))
|
|
||||||
(add-token (advance scanner) :string (string buff)))
|
|
||||||
"\\" (let [next (next-char scanner)
|
"\\" (let [next (next-char scanner)
|
||||||
scanner (if (= next "\n")
|
scanner (if (= next "\n")
|
||||||
(update scanner :line inc)
|
(update scanner :line inc)
|
||||||
|
@ -255,7 +253,7 @@
|
||||||
"}" (add-token (add-token scanner :break) :rbrace)
|
"}" (add-token (add-token scanner :break) :rbrace)
|
||||||
"[" (add-token scanner :lbracket)
|
"[" (add-token scanner :lbracket)
|
||||||
"]" (add-token (add-token scanner :break) :rbracket)
|
"]" (add-token (add-token scanner :break) :rbracket)
|
||||||
"#" (add-token scanner :semicolon)
|
";" (add-token scanner :semicolon)
|
||||||
"," (add-token scanner :comma)
|
"," (add-token scanner :comma)
|
||||||
"\n" (add-token (update scanner :line inc) :newline)
|
"\n" (add-token (update scanner :line inc) :newline)
|
||||||
"\\" (add-token scanner :backslash)
|
"\\" (add-token scanner :backslash)
|
||||||
|
@ -315,7 +313,8 @@
|
||||||
(defn- next-token [scanner]
|
(defn- next-token [scanner]
|
||||||
(put scanner :start (get scanner :current)))
|
(put scanner :start (get scanner :current)))
|
||||||
|
|
||||||
(defn scan [source input]
|
(defn scan [source &opt input]
|
||||||
|
(default input "")
|
||||||
(defn recur [scanner]
|
(defn recur [scanner]
|
||||||
(if (at-end? scanner)
|
(if (at-end? scanner)
|
||||||
(let [scanner (add-token (add-token scanner :break) :eof)]
|
(let [scanner (add-token (add-token scanner :break) :eof)]
|
||||||
|
@ -323,3 +322,4 @@
|
||||||
:errors (get scanner :errors)})
|
:errors (get scanner :errors)})
|
||||||
(recur (-> scanner (scan-token) (next-token)))))
|
(recur (-> scanner (scan-token) (next-token)))))
|
||||||
(recur (new-scanner source input)))
|
(recur (new-scanner source input)))
|
||||||
|
|
||||||
|
|
11
justfile
11
justfile
|
@ -4,14 +4,19 @@ build:
|
||||||
|
|
||||||
# open a janet repl in a different os window
|
# open a janet repl in a different os window
|
||||||
repl:
|
repl:
|
||||||
kitten @ launch --type=os-window --allow-remote-control --cwd=current --title=hx_repl:ludus janet -s
|
kitten @ launch --type=os-window --allow-remote-control --cwd=current --title=hx_repl:ludus
|
||||||
|
kitten @ send-text -m "title:hx_repl:ludus" "janet -s\n"
|
||||||
|
|
||||||
|
restart:
|
||||||
|
kitten @ send-text -m "title:hx_repl:ludus" "\04"
|
||||||
|
kitten @ send-text -m "title:hx_repl:ludus" "janet -s\n"
|
||||||
|
|
||||||
# send what's selected to the repl and evaluate it
|
# send what's selected to the repl and evaluate it
|
||||||
eval:
|
eval:
|
||||||
sd "$" "\n" | sd "\n\n" "\n" | kitten @ send-text -m "title:hx_repl:ludus" --stdin
|
sd "$" "\n" | sd "\n\n" "\n" | kitten @ send-text -m "title:hx_repl:ludus" --stdin
|
||||||
|
|
||||||
# send what's selected to a buffer, and then evaluate what's in the buffer
|
# send what's selected to a buffer, and then evaluate what's in the buffer
|
||||||
buffer:
|
buffer:
|
||||||
sd "$" "\n" | sd "\n\n" "\n" > .repl-buffer
|
sd "$" "\n" | sd "\n\n" "\n" > .repl-buffer.janet
|
||||||
kitten @ send-text -m "title:hx_repl:ludus" --from-file .repl-buffer
|
kitten @ send-text -m "title:hx_repl:ludus" "(import ./.repl-buffer :prefix \"\")"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user