Compare commits

..

2 Commits

Author SHA1 Message Date
Scott Richmond
a30cbaebc6 at for strings, for real 2024-06-21 15:28:46 -04:00
Scott Richmond
7b56e90468 build 2024-06-21 11:37:31 -04:00
8 changed files with 30 additions and 23 deletions

Binary file not shown.

View File

@ -6489,7 +6489,7 @@ var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['
var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])(); var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
var ___cxa_is_pointer_type = createExportWrapper('__cxa_is_pointer_type', 1); var ___cxa_is_pointer_type = createExportWrapper('__cxa_is_pointer_type', 1);
var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5); var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5);
var ___emscripten_embedded_file_data = Module['___emscripten_embedded_file_data'] = 1837508; var ___emscripten_embedded_file_data = Module['___emscripten_embedded_file_data'] = 1838072;
function invoke_i(index) { function invoke_i(index) {
var sp = stackSave(); var sp = stackSave();
try { try {

Binary file not shown.

View File

@ -44,6 +44,7 @@ fn ordered? {
"Returns true if a value is an indexed collection: list or tuple." "Returns true if a value is an indexed collection: list or tuple."
(coll as :list) -> true (coll as :list) -> true
(coll as :tuple) -> true (coll as :tuple) -> true
(coll as :string) -> true
(_) -> false (_) -> false
} }
@ -138,6 +139,7 @@ fn rest {
(()) -> () (()) -> ()
(xs as :list) -> base :rest (xs) (xs as :list) -> base :rest (xs)
(xs as :tuple) -> base :rest (xs) (xs as :tuple) -> base :rest (xs)
(xs as :string) -> base :str_slice (xs, 1)
} }
fn inc { fn inc {
@ -629,10 +631,13 @@ fn at {
"Returns the element at index n of a list or tuple, or the byte at index n of a string. Zero-indexed: the first element is at index 0. Returns nil if nothing is found in a list or tuple; returns an empty string if nothing is found in a string." "Returns the element at index n of a list or tuple, or the byte at index n of a string. Zero-indexed: the first element is at index 0. Returns nil if nothing is found in a list or tuple; returns an empty string if nothing is found in a string."
(xs as :list, n as :number) -> base :nth (n, xs) (xs as :list, n as :number) -> base :nth (n, xs)
(xs as :tuple, n as :number) -> base :nth (n, xs) (xs as :tuple, n as :number) -> base :nth (n, xs)
(str as :string, n as :number) -> when { (str as :string, n as :number) -> {
neg? (n) -> "" let raw = base :nth (n, str)
gte? (n, count (str)) -> "" when {
true -> base :slice (str, n, inc (n)) nil? (raw) -> nil
gte? (raw, 128) -> panic! "not an ASCII char"
true -> raw
}
} }
(_) -> nil (_) -> nil
} }
@ -1283,7 +1288,9 @@ fn apply_command {
(:home) -> do state > (:home) -> do state >
assoc (_, :position, (0, 0)) > assoc (_, :position, (0, 0)) >
assoc (_, :heading, 0) assoc (_, :heading, 0)
(:clear) -> assoc (state, :position, (0, 0)) (:clear) -> do state >
assoc (state, :position, (0, 0)) >
assoc (_, :heading, 0)
(:right, turns) -> update (state, :heading, add (_, turns)) (:right, turns) -> update (state, :heading, add (_, turns))
(:left, turns) -> update (state, :heading, sub (_, turns)) (:left, turns) -> update (state, :heading, sub (_, turns))
(:forward, steps) -> { (:forward, steps) -> {

View File

@ -640,7 +640,7 @@
# # (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/lett})
# # (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))))
# ) # )

View File

@ -52,14 +52,14 @@
(comment (comment
# (do # (do
(def source ` (def source `
contains? (:d, [:a, :b]) add (1, 2)
`) `)
(def out (-> source (def out (-> source
ludus ludus
j/decode j/decode
)) ))
(setdyn :out stdout) (setdyn :out stdout)
(pp out) # (pp out)
(def console (out "console")) (def console (out "console"))
(print console) (print console)
(def result (out "result")) (def result (out "result"))

View File

@ -1117,10 +1117,10 @@
# (do # (do
(comment (comment
(def source ` (def source `
"{f} a {f}" let foo = :bar
`) `)
(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 (lett a-parser))
) )

View File

@ -350,6 +350,6 @@
(comment (comment
# (do # (do
(def source "/iii") (def source "add 1 2 () four")
(scan source) (scan source)
) )