diff options
author | dzaima <dzaimagit@gmail.com> | 2021-08-27 11:52:56 +0300 |
---|---|---|
committer | dzaima <dzaimagit@gmail.com> | 2021-08-27 11:52:56 +0300 |
commit | 305f578707d6f0a9cf27e93135513cbb670919ea (patch) | |
tree | 6a11fda7f50d7aca032e7ccfb6b8549a726ef958 | |
parent | a7ee8044d165119c6df8e93c5c13286bac54bf59 (diff) |
add •Fmt, changes to readme files
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | src/README.md | 2 | ||||
-rw-r--r-- | src/builtins/sysfn.c | 11 | ||||
-rw-r--r-- | src/utils/builtins.h | 2 |
4 files changed, 18 insertions, 8 deletions
@@ -3,12 +3,13 @@ Build & run (tl;dr: `make; rlwrap ./BQN`): 1. (optional) Run `./genRuntime path/to/mlochbaum/BQN`; Otherwise, the necessary precompiled bytecode will be retrieved from `remotes/origin/bytecode` 2. If wanted, customize settings in `src/h.h` 3. `make` - - Options: `make o3`, `make debug` (`make rtperf`, `make heapverify` and `make rtverify` also exist for further testing/debugging) - - Do `make clean` or `make [o3|debug|…]-clean` beforehand to force recompile - - `./build` and `./debugBuild` compile everything at once and allow specifying extra compiler arguments, but may be slower -4. `./BQN` (or `rlwrap ./BQN` for a better REPL) + - Options: `make o3` (the default), `make debug` (more presets exist for more specific debugging) + - `make CC=gcc` can be used to compile with gcc + - Do `make clean` or `make t=[o3|debug|…] clean` beforehand to force recompile + - `make single-(o3|o3g|debug|c)` compile everything as a single translation unit and thus will compile slower, but allows specifying extra compiler arguments with `make f='…' single-…` and allows the compiler to optimize more +4. `./BQN` (or `rlwrap ./BQN` for a better REPL; see `./BQN --help` for more options) -Run tests with `./BQN mlochbaum/BQN/test/this.bqn` (with `-noerr` for a heapverify build). +Run tests with `./BQN mlochbaum/BQN/test/this.bqn` (add `-noerr` for a heapverify build). Time REPL-executed safe prim tests: `./test.bqn mlochbaum/BQN -s prim > SP; time ./BQN<SP>/dev/null` diff --git a/src/README.md b/src/README.md index ebcdc9d8..332d3417 100644 --- a/src/README.md +++ b/src/README.md @@ -6,7 +6,7 @@ Functions starting with `m_` allocate a new object. Functions starting with `q_` are queries/predicates, and return a boolean. Functions ending with `R` are either supposed to be called rarely, or the caller expects that a part of it happens rarely. Functions ending with `U` return (or take) a non-owned object (`U` = "unincremented"). -Functions ending with `_c1` are monadic implementations, `_c2` are dyadic (for both modifiers and functions). +Functions ending with `_c1` are monadic implementations, `_c2` are dyadic (for both modifiers and functions). Variables starting with `bi_` are builtins (primitives or special values). Which arguments are consumed usually is described in a comment after the function or its prototype. Otherwise, check the source. diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index 2cd05899..a5a4cee9 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -75,11 +75,19 @@ B repr_c1(B t, B x) { #if FORMATTER return bqn_repr(x); #else - thrM("•Repr: Cannot represent non-numbers"); + thrM("•Repr: Cannot represent non-numbers without FORMATTER defined"); #endif } } +B fmt_c1(B t, B x) { + #if FORMATTER + return bqn_fmt(x); + #else + thrM("•Fmt isn't supported without FORMATTER defined"); + #endif +} + B fill_c1(B t, B x) { B r = getFillE(x); dec(x); @@ -660,6 +668,7 @@ B sys_c1(B t, B x) { else if (eqStr(c, U"delay")) r.a[i] = inc(bi_delay); else if (eqStr(c, U"hash")) r.a[i] = inc(bi_hash); else if (eqStr(c, U"repr")) r.a[i] = inc(bi_repr); + else if (eqStr(c, U"fmt")) r.a[i] = inc(bi_fmt); else if (eqStr(c, U"glyph")) r.a[i] = inc(bi_glyph); else if (eqStr(c, U"makerand")) r.a[i] = inc(bi_makeRand); else if (eqStr(c, U"makerepl")) r.a[i] = inc(bi_makeREPL); diff --git a/src/utils/builtins.h b/src/utils/builtins.h index a7dc941d..def23c31 100644 --- a/src/utils/builtins.h +++ b/src/utils/builtins.h @@ -8,7 +8,7 @@ /* sort.c*/A(gradeUp,"⍋") A(gradeDown,"⍒") \ /* everything before the definition of •Type is defined to be pure, and everything after is not */ \ /* sysfn.c*/M(type,"•Type") M(decp,"•Decompose") M(primInd,"•PrimInd") M(glyph,"•Glyph") A(fill,"•FillFn") M(sys,"•getsys") A(grLen,"•GroupLen") D(grOrd,"•groupOrd") \ -/* sysfn.c*/M(repr,"•Repr") A(asrt,"!") A(casrt,"!") M(out,"•Out") M(show,"•Show") M(bqn,"•BQN") M(sh,"•SH") M(fromUtf8,"•FromUTF8") \ +/* sysfn.c*/M(repr,"•Repr") M(fmt,"•Fmt") A(asrt,"!") A(casrt,"!") M(out,"•Out") M(show,"•Show") M(bqn,"•BQN") M(sh,"•SH") M(fromUtf8,"•FromUTF8") \ /* sysfn.c*/D(cmp,"•Cmp") A(hash,"•Hash") M(delay,"•Delay") M(makeRand,"•MakeRand") M(makeREPL,"•MakeREPL") M(exit,"•Exit") M(getLine,"•GetLine") \ /*internal.c*/M(itype,"•internal.Type") M(refc,"•internal.Refc") M(squeeze,"•internal.Squeeze") M(isPure,"•internal.IsPure") A(info,"•internal.Info") \ /*internal.c*/D(variation,"•internal.Variation") A(listVariations,"•internal.ListVariations") M(clearRefs,"•internal.ClearRefs") M(unshare,"•internal.Unshare") |