Compare commits
No commits in common. "b3cfeb82e13b62f2ba1ff8aadd869e8feb2e07c0" and "a6e2e11e4acc817c26d859b7bb07ad9ede364850" have entirely different histories.
b3cfeb82e1
...
a6e2e11e4a
4
justfile
4
justfile
|
@ -18,7 +18,3 @@ buffer:
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
sd "$" "\n" | sd "\n\n" "\n" | xargs -I _ echo "(doc " _ ")" | kitten @ send-text -m "title:hx_repl:ludus" --stdin
|
sd "$" "\n" | sd "\n\n" "\n" | xargs -I _ echo "(doc " _ ")" | kitten @ send-text -m "title:hx_repl:ludus" --stdin
|
||||||
|
|
||||||
publish:
|
|
||||||
git commit -am "publishing!"
|
|
||||||
|
|
||||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@ludus/ludus-js-pure",
|
"name": "@ludus/ludus-js-pure",
|
||||||
"version": "0.1.7",
|
"version": "0.1.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@ludus/ludus-js-pure",
|
"name": "@ludus/ludus-js-pure",
|
||||||
"version": "0.1.7",
|
"version": "0.1.3",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"shadow-cljs": "^2.26.0",
|
"shadow-cljs": "^2.26.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@ludus/ludus-js-pure",
|
"name": "@ludus/ludus-js-pure",
|
||||||
"version": "0.1.7",
|
"version": "0.1.5",
|
||||||
"description": "A Ludus interpreter in a pure JS function.",
|
"description": "A Ludus interpreter in a pure JS function.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "build/ludus.mjs",
|
"main": "build/ludus.mjs",
|
||||||
|
@ -11,7 +11,6 @@
|
||||||
"files": [
|
"files": [
|
||||||
"build/out.wasm",
|
"build/out.wasm",
|
||||||
"build/out.mjs",
|
"build/out.mjs",
|
||||||
"build/ludus.mjs"
|
"build/ludus.mjs"],
|
||||||
],
|
|
||||||
"devDependencies": {}
|
"devDependencies": {}
|
||||||
}
|
}
|
||||||
|
|
41
prelude.ld
41
prelude.ld
|
@ -249,32 +249,33 @@ fn concat {
|
||||||
& the console: sending messages to the outside world
|
& the console: sending messages to the outside world
|
||||||
& the console is *both* something we send to the host language's console
|
& the console is *both* something we send to the host language's console
|
||||||
& ...and also a list of messages.
|
& ...and also a list of messages.
|
||||||
& box console = []
|
box console = []
|
||||||
|
|
||||||
& fn flush! {
|
fn flush! {
|
||||||
& "Clears the console, and returns the messages."
|
"Clears the console, and returns the messages."
|
||||||
& () -> {
|
() -> {
|
||||||
& let msgs = unbox (console)
|
let msgs = unbox (console)
|
||||||
& store! (console, [])
|
store! (console, [])
|
||||||
& msgs
|
msgs
|
||||||
& }
|
}
|
||||||
& }
|
}
|
||||||
|
|
||||||
& fn add_msg! {
|
fn add_msg! {
|
||||||
& "Adds a message to the console."
|
"Adds a message to the console."
|
||||||
& (msg as :string) -> update! (console, append (_, msg))
|
(msg as :string) -> update! (console, append (_, msg))
|
||||||
& (msgs as :list) -> {
|
(msgs as :list) -> {
|
||||||
& base :print! (("adding msg", msgs))
|
base :print! (("adding msg", msgs))
|
||||||
& let msg = do msgs > map (string, _) > join
|
let msg = do msgs > map (string, _) > join
|
||||||
& base :print! (("msg: ", msg))
|
base :print! (("msg: ", msg))
|
||||||
& update! (console, append (_, msg))
|
update! (console, append (_, msg))
|
||||||
& }
|
}
|
||||||
& }
|
}
|
||||||
|
|
||||||
fn print! {
|
fn print! {
|
||||||
"Sends a text representation of Ludus values to the console."
|
"Sends a text representation of Ludus values to the console."
|
||||||
(...args) -> {
|
(...args) -> {
|
||||||
base :print! (args)
|
base :print! (args)
|
||||||
|
& add_msg! (args)
|
||||||
:ok
|
:ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1305,6 +1306,7 @@ pkg Prelude {
|
||||||
coll?
|
coll?
|
||||||
colors
|
colors
|
||||||
concat
|
concat
|
||||||
|
console
|
||||||
cos
|
cos
|
||||||
count
|
count
|
||||||
dec
|
dec
|
||||||
|
@ -1330,6 +1332,7 @@ pkg Prelude {
|
||||||
filter
|
filter
|
||||||
first
|
first
|
||||||
floor
|
floor
|
||||||
|
flush!
|
||||||
fn?
|
fn?
|
||||||
fold
|
fold
|
||||||
forward!
|
forward!
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
(print source-line))
|
(print source-line))
|
||||||
|
|
||||||
(defn runtime-error [e]
|
(defn runtime-error [e]
|
||||||
(when (= :string (type e)) (print (string "Internal Ludus error: " e)) (break e))
|
(when (= :string (type e)) (print e) (break e))
|
||||||
(def msg (e :msg))
|
(def msg (e :msg))
|
||||||
(case msg
|
(case msg
|
||||||
"no match: function call" (fn-no-match e)
|
"no match: function call" (fn-no-match e)
|
||||||
|
|
|
@ -251,9 +251,7 @@
|
||||||
(interpret last-line ctx))
|
(interpret last-line ctx))
|
||||||
|
|
||||||
(defn- to_string [ctx] (fn [x]
|
(defn- to_string [ctx] (fn [x]
|
||||||
(if (buffer? x)
|
(b/stringify (interpret x ctx))))
|
||||||
(string x)
|
|
||||||
(b/stringify (interpret x ctx)))))
|
|
||||||
|
|
||||||
(defn- interpolated [ast ctx]
|
(defn- interpolated [ast ctx]
|
||||||
(def terms (ast :data))
|
(def terms (ast :data))
|
||||||
|
@ -622,9 +620,9 @@
|
||||||
(set interpret interpret*)
|
(set interpret interpret*)
|
||||||
|
|
||||||
# # repl
|
# # repl
|
||||||
# (import /src/scanner :as s)
|
# (import ./scanner :as s)
|
||||||
# (import /src/parser :as p)
|
# (import ./parser :as p)
|
||||||
# (import /src/validate :as v)
|
# (import ./validate :as v)
|
||||||
|
|
||||||
# (var source nil)
|
# (var source nil)
|
||||||
|
|
||||||
|
@ -639,16 +637,14 @@
|
||||||
# # (when (has-errors? validated) (break (validated :errors)))
|
# # (when (has-errors? validated) (break (validated :errors)))
|
||||||
# # (def cleaned (get-in parsed [:ast :data 1]))
|
# # (def cleaned (get-in parsed [:ast :data 1]))
|
||||||
# # # (pp cleaned)
|
# # # (pp cleaned)
|
||||||
# (interpret (parsed :ast) @{:^parent b/ctx})
|
# # (interpret (parsed :ast) @{:^parent b/ctx})
|
||||||
# # (try (interpret (parsed :ast) @{:^parent b/ctx})
|
# (try (interpret (parsed :ast) @{:^parent b/ctx})
|
||||||
# # ([e] (if (struct? e) (error (e :msg)) (error e))))
|
# ([e] (if (struct? e) (error (e :msg)) (error e)))))
|
||||||
# )
|
|
||||||
|
|
||||||
# # (do
|
# # (do
|
||||||
# (comment
|
# (comment
|
||||||
# (set source `
|
# (set source `
|
||||||
# let foo = 42
|
|
||||||
# "{foo} bar baz"
|
|
||||||
# `)
|
# `)
|
||||||
# (def result (run))
|
# (def result (run))
|
||||||
# )
|
# )
|
||||||
|
|
|
@ -24,13 +24,13 @@
|
||||||
(set (out :errors) (scanned :errors))
|
(set (out :errors) (scanned :errors))
|
||||||
(each err (scanned :errors)
|
(each err (scanned :errors)
|
||||||
(e/scan-error err))
|
(e/scan-error err))
|
||||||
(break (j/encode out)))
|
(break out))
|
||||||
(def parsed (p/parse scanned))
|
(def parsed (p/parse scanned))
|
||||||
(when (any? (parsed :errors))
|
(when (any? (parsed :errors))
|
||||||
(set (out :errors) (parsed :errors))
|
(set (out :errors) (parsed :errors))
|
||||||
(each err (parsed :errors)
|
(each err (parsed :errors)
|
||||||
(e/parse-error err))
|
(e/parse-error err))
|
||||||
(break (j/encode out)))
|
(break out))
|
||||||
(def validated (v/valid parsed ctx))
|
(def validated (v/valid parsed ctx))
|
||||||
(when (any? (validated :errors))
|
(when (any? (validated :errors))
|
||||||
(set (out :errors) (validated :errors))
|
(set (out :errors) (validated :errors))
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
([err]
|
([err]
|
||||||
(e/runtime-error err)
|
(e/runtime-error err)
|
||||||
(set (out :errors) [err])
|
(set (out :errors) [err])
|
||||||
(break (j/encode out))))
|
(break out)))
|
||||||
(setdyn :out stdout)
|
(setdyn :out stdout)
|
||||||
(set (out :result) (b/show result))
|
(set (out :result) (b/show result))
|
||||||
(var post @{})
|
(var post @{})
|
||||||
|
@ -53,7 +53,4 @@
|
||||||
(set (out :draw) (post :draw))
|
(set (out :draw) (post :draw))
|
||||||
(string (j/encode out)))
|
(string (j/encode out)))
|
||||||
|
|
||||||
(ludus `
|
|
||||||
let foo = 42
|
|
||||||
"{foo} bar baz"
|
|
||||||
`)
|
|
||||||
|
|
|
@ -1116,11 +1116,10 @@
|
||||||
|
|
||||||
# (do
|
# (do
|
||||||
(comment
|
(comment
|
||||||
(def source `
|
(def source `...
|
||||||
"{f} a {f}"
|
|
||||||
`)
|
`)
|
||||||
(def scanned (s/scan source))
|
(def scanned (s/scan source))
|
||||||
# (print "\n***NEW PARSE***\n")
|
# (print "\n***NEW PARSE***\n")
|
||||||
(def a-parser (new-parser scanned))
|
(def a-parser (new-parser scanned))
|
||||||
(def parsed (interpolated a-parser))
|
(def parsed (splat a-parser))
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user