aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-04-29 13:37:28 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-04-29 13:37:28 -0400
commitc0fbd3c6877eb270b957dde5622e0fc5d84595fa (patch)
tree8de7ca69209716f680e4675faf7f3544bcd9c198
parent9ebe3bcdc963a47fa80606942f252ec5464cf911 (diff)
Fix up references to r.bqn
-rw-r--r--README.md2
-rw-r--r--docs/implementation/index.html2
-rw-r--r--docs/implementation/vm.html4
-rw-r--r--docs/index.html2
-rw-r--r--implementation/README.md2
-rw-r--r--implementation/vm.md4
-rw-r--r--src/README.txt31
-rw-r--r--test/README.txt2
8 files changed, 33 insertions, 16 deletions
diff --git a/README.md b/README.md
index 18cd8b0c..15fd47c1 100644
--- a/README.md
+++ b/README.md
@@ -50,7 +50,7 @@ Rather strange, most likely:
⊑+`∘⌽⍟12↕2 # The 12th Fibonacci number
-More snippets are programmed into the live demo at the top of the page: hit the arrow at the right of the code window to see them. For longer samples, you can [gaze into the abyss](src/c.bqn) that is the self-hosted compiler, or the [shallower but wider abyss](src/r.bqn) of the runtime, or take a look at the friendlier [markdown processor](md.bqn) used to format and highlight documentation files. This repository also has [some translations](examples/fifty.bqn) from ["A History of APL in 50 Functions"](https://www.jsoftware.com/papers/50/).
+More snippets are programmed into the live demo at the top of the page: hit the arrow at the right of the code window to see them. For longer samples, you can [gaze into the abyss](src/c.bqn) that is the self-hosted compiler, or the [shallower but wider abyss](src/r1.bqn) of the runtime, or take a look at the friendlier [markdown processor](md.bqn) used to format and highlight documentation files. This repository also has [some translations](examples/fifty.bqn) from ["A History of APL in 50 Functions"](https://www.jsoftware.com/papers/50/).
## How do I work with the character set?
diff --git a/docs/implementation/index.html b/docs/implementation/index.html
index 8235b6cd..c9d79a2c 100644
--- a/docs/implementation/index.html
+++ b/docs/implementation/index.html
@@ -10,7 +10,7 @@
<li><a href="codfns.html">Comparison to Co-dfns</a> discusses the general compilation strategy and how it compares to the only other array-based compiler.</li>
<li><a href="vm.html">The BQN virtual machine and runtime</a> describes the non-self-hosted parts of the BQN implementation, that is, everything you need to port it to a new platform.</li>
</ul>
-<p>This repository's BQN implementation is written mainly in BQN: the bytecode <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../src/c.bqn">compiler</a> is completely self-hosted, and the <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../src/r.bqn">majority of the runtime</a> is written in BQN except that it is allowed to define primitives; some preprocessing turns the primitives into identifiers. The remaining part, a VM, can be implemented in any language to obtain a version of BQN running in that language.</p>
+<p>This repository's BQN implementation is written mainly in BQN: the bytecode <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../src/c.bqn">compiler</a> is completely self-hosted, and the majority of the runtime (<a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../src/r0.bqn">r0</a>, <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../src/r1.bqn">r1</a>) is written in BQN except that it is allowed to define primitives; some preprocessing turns the primitives into identifiers. The remaining part, a VM, can be implemented in any language to obtain a version of BQN running in that language.</p>
<p>The VM used for the online REPL is the <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../docs/bqn.js">Javascript implementation</a>. The bytecode matches dzaima/BQN's format, and <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../dc.bqn">an extension</a> to the compiler adjusts the slightly different block declarations to target dzaima+reference BQN. <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../wc.bqn">An earlier experiment</a> targetting <a href="https://en.wikipedia.org/wiki/WebAssembly">WebAssembly</a> works only on a very small subset of BQN. All versions have automated tests in the <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../test/">test</a> directory.</p>
<p>I have also held some forum discussions on the actual workings of the compiler, but aborted these because the interactive format wasn't doing too much. I haven't yet started on non-interactive replacements.</p>
<ul>
diff --git a/docs/implementation/vm.html b/docs/implementation/vm.html
index e7fcf5f0..57f328e6 100644
--- a/docs/implementation/vm.html
+++ b/docs/implementation/vm.html
@@ -390,8 +390,8 @@
<p><strong>SETM</strong> additionally needs to get the current value of a reference. For a variable reference this is its current value (with an error if it's not defined yet); for a reference list it's a list of the values of each reference in the list.</p>
<h2 id="runtime">Runtime</h2>
<p>Primitive functions and modifiers used in a program are stored in its <code><span class='Value'>consts</span></code> array. The compiler needs to be passed a <em>runtime</em> with the value of every primitive so that these functions and modifiers are available.</p>
-<p>While it's perfectly possible to implement the runtime from scratch, the pseudo-BQN file <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../src/r.bqn">r.bqn</a> implements the full runtime in terms of a <em>core runtime</em> consisting of a smaller number of much simpler functions. <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../src/pr.bqn">pr.bqn</a> converts this file so that it can be compiled. It changes values in the core runtime to primitives and primitives to generated identifiers, so that the first 22 values in the output's <code><span class='Value'>consts</span></code> array are exactly the core runtime, and no other primitives are required. The result is a list of two elements: first the list of all primitive values, and then a function that can be called to pass in two additional core functions used for inferred properties.</p>
-<p>The contents of a core runtime are given below. The names given are those used in r.bqn; the environment only provides a list of values and therefore doesn't need to use the same names. For named functions a description is given. For primitives, the implementation should match the BQN specification for that primitive on the specified domain, or the entire domain if left empty. They won't be called outside that domain except if there are bugs in r.bqn.</p>
+<p>While it's perfectly possible to implement the runtime from scratch, the pseudo-BQN files <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../src/r0.bqn">r0.bqn</a> and <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../src/r1.bqn">r1.bqn</a> implement the full runtime in terms of a <em>core runtime</em> consisting of a smaller number of much simpler functions. <a href="https://github.com/mlochbaum/BQN/blob/master/implementation/../src/pr.bqn">pr.bqn</a> converts this file so that it can be compiled. It changes values in the core runtime to primitives and primitives to generated identifiers, so that the first 22 values in the output's <code><span class='Value'>consts</span></code> array are exactly the core runtime, and no other primitives are required. The result is a list of two elements: first the list of all primitive values, and then a function that can be called to pass in two additional core functions used for inferred properties.</p>
+<p>The contents of a core runtime are given below. The names given are those used in r1.bqn; the environment only provides a list of values and therefore doesn't need to use the same names. For named functions a description is given. For primitives, the implementation should match the BQN specification for that primitive on the specified domain, or the entire domain if left empty. They won't be called outside that domain except if there are bugs in the BQN sources.</p>
<table>
<thead>
<tr>
diff --git a/docs/index.html b/docs/index.html
index fe8ae698..90005211 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -48,7 +48,7 @@
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqRK2DiiJjijL3ijZ8xMuKGlTIgICMgVGhlIDEydGggRmlib25hY2NpIG51bWJlcg==">↗️</a><pre> <span class='Function'>⊑+</span><span class='Modifier'>`</span><span class='Modifier2'>∘</span><span class='Function'>⌽</span><span class='Modifier2'>⍟</span><span class='Number'>12</span><span class='Function'>↕</span><span class='Number'>2</span> <span class='Comment'># The 12th Fibonacci number
</span>144
</pre>
-<p>More snippets are programmed into the live demo at the top of the page: hit the arrow at the right of the code window to see them. For longer samples, you can <a href="https://github.com/mlochbaum/BQN/blob/master/src/c.bqn">gaze into the abyss</a> that is the self-hosted compiler, or the <a href="https://github.com/mlochbaum/BQN/blob/master/src/r.bqn">shallower but wider abyss</a> of the runtime, or take a look at the friendlier <a href="https://github.com/mlochbaum/BQN/blob/master/md.bqn">markdown processor</a> used to format and highlight documentation files. This repository also has <a href="https://github.com/mlochbaum/BQN/blob/master/examples/fifty.bqn">some translations</a> from <a href="https://www.jsoftware.com/papers/50/">&quot;A History of APL in 50 Functions&quot;</a>.</p>
+<p>More snippets are programmed into the live demo at the top of the page: hit the arrow at the right of the code window to see them. For longer samples, you can <a href="https://github.com/mlochbaum/BQN/blob/master/src/c.bqn">gaze into the abyss</a> that is the self-hosted compiler, or the <a href="https://github.com/mlochbaum/BQN/blob/master/src/r1.bqn">shallower but wider abyss</a> of the runtime, or take a look at the friendlier <a href="https://github.com/mlochbaum/BQN/blob/master/md.bqn">markdown processor</a> used to format and highlight documentation files. This repository also has <a href="https://github.com/mlochbaum/BQN/blob/master/examples/fifty.bqn">some translations</a> from <a href="https://www.jsoftware.com/papers/50/">&quot;A History of APL in 50 Functions&quot;</a>.</p>
<h2 id="how-do-i-work-with-the-character-set">How do I work with the character set?</h2>
<p>Right at the beginning, you can use the bar above the online REPL to enter BQN code: hover over a character to see a short description, and click to insert it into the editor. But you'll soon want to skip the clicking and use keyboard input. I type the special characters using a backslash escape, so that, for example, typing <code><span class='Value'>\</span></code> then <code><span class='Value'>z</span></code> writes <code><span class='Function'>⥊</span></code> (the backslash character itself is not used by BQN). The online REPL supports this method out of the box, and configuration files to enable it in various other places are included with the <a href="https://github.com/mlochbaum/BQN/tree/master/editors">editor plugins</a>. There's also a <a href="https://abrudz.github.io/lb/bqn">bookmarklet</a> you can use to enable BQN input in any webpage in your browser.</p>
<p>The <a href="https://mlochbaum.github.io/BQN/fonts.html">font comparison page</a> shows several fonts that support BQN (including the one used on this site, BQN386). Most other monospace fonts are missing some BQN characters, such as double-struck letters <code><span class='Value'>𝕨</span></code>, <code><span class='Value'>𝕩</span></code> and so on, which will cause these characters to be rendered with a fallback font and possibly have the wrong width or look inconsistent.</p>
diff --git a/implementation/README.md b/implementation/README.md
index 7f29f70e..223b0734 100644
--- a/implementation/README.md
+++ b/implementation/README.md
@@ -7,7 +7,7 @@ Notes about how BQN is implemented. There's not too much here yet.
- [Comparison to Co-dfns](codfns.md) discusses the general compilation strategy and how it compares to the only other array-based compiler.
- [The BQN virtual machine and runtime](vm.md) describes the non-self-hosted parts of the BQN implementation, that is, everything you need to port it to a new platform.
-This repository's BQN implementation is written mainly in BQN: the bytecode [compiler](../src/c.bqn) is completely self-hosted, and the [majority of the runtime](../src/r.bqn) is written in BQN except that it is allowed to define primitives; some preprocessing turns the primitives into identifiers. The remaining part, a VM, can be implemented in any language to obtain a version of BQN running in that language.
+This repository's BQN implementation is written mainly in BQN: the bytecode [compiler](../src/c.bqn) is completely self-hosted, and the majority of the runtime ([r0](../src/r0.bqn), [r1](../src/r1.bqn)) is written in BQN except that it is allowed to define primitives; some preprocessing turns the primitives into identifiers. The remaining part, a VM, can be implemented in any language to obtain a version of BQN running in that language.
The VM used for the online REPL is the [Javascript implementation](../docs/bqn.js). The bytecode matches dzaima/BQN's format, and [an extension](../dc.bqn) to the compiler adjusts the slightly different block declarations to target dzaima+reference BQN. [An earlier experiment](../wc.bqn) targetting [WebAssembly](https://en.wikipedia.org/wiki/WebAssembly) works only on a very small subset of BQN. All versions have automated tests in the [test](../test/) directory.
diff --git a/implementation/vm.md b/implementation/vm.md
index 8f7c0997..c9d089d9 100644
--- a/implementation/vm.md
+++ b/implementation/vm.md
@@ -117,9 +117,9 @@ The **SETN**, **SETU**, and **SETM** instructions set a value for a reference. I
Primitive functions and modifiers used in a program are stored in its `consts` array. The compiler needs to be passed a *runtime* with the value of every primitive so that these functions and modifiers are available.
-While it's perfectly possible to implement the runtime from scratch, the pseudo-BQN file [r.bqn](../src/r.bqn) implements the full runtime in terms of a *core runtime* consisting of a smaller number of much simpler functions. [pr.bqn](../src/pr.bqn) converts this file so that it can be compiled. It changes values in the core runtime to primitives and primitives to generated identifiers, so that the first 22 values in the output's `consts` array are exactly the core runtime, and no other primitives are required. The result is a list of two elements: first the list of all primitive values, and then a function that can be called to pass in two additional core functions used for inferred properties.
+While it's perfectly possible to implement the runtime from scratch, the pseudo-BQN files [r0.bqn](../src/r0.bqn) and [r1.bqn](../src/r1.bqn) implement the full runtime in terms of a *core runtime* consisting of a smaller number of much simpler functions. [pr.bqn](../src/pr.bqn) converts this file so that it can be compiled. It changes values in the core runtime to primitives and primitives to generated identifiers, so that the first 22 values in the output's `consts` array are exactly the core runtime, and no other primitives are required. The result is a list of two elements: first the list of all primitive values, and then a function that can be called to pass in two additional core functions used for inferred properties.
-The contents of a core runtime are given below. The names given are those used in r.bqn; the environment only provides a list of values and therefore doesn't need to use the same names. For named functions a description is given. For primitives, the implementation should match the BQN specification for that primitive on the specified domain, or the entire domain if left empty. They won't be called outside that domain except if there are bugs in r.bqn.
+The contents of a core runtime are given below. The names given are those used in r1.bqn; the environment only provides a list of values and therefore doesn't need to use the same names. For named functions a description is given. For primitives, the implementation should match the BQN specification for that primitive on the specified domain, or the entire domain if left empty. They won't be called outside that domain except if there are bugs in the BQN sources.
| Ind | Name | Description / restrictions
|----:|------------|---------------------------
diff --git a/src/README.txt b/src/README.txt
index 2881a572..5b2f659b 100644
--- a/src/README.txt
+++ b/src/README.txt
@@ -1,15 +1,32 @@
Documentation for BQN's implementation is at ../implementation/.
-BQN sources for BQN. Object code obtained from these sources is run with
-a VM to obtain a BQN implementation. This is done in Javascript in
-../docs/bqn.js and ../docs/repl.js.
+BQN sources for BQN. Object code from these is run with a VM to obtain a
+BQN implementation. The Javascript VM is ../docs/bqn.js.
+
+Compiler toolchain:
+
+- glyphs.bqn Glyphs for all BQN primitives
+- c.bqn Compiler
+- pp.bqn General preprocessing
+- pr.bqn Preprocess the runtime
+- cjs.bqn Format compiler output as Javascript literals
+
+Compilation targets:
- c.bqn Compiler
-- r.bqn Runtime
+- r0.bqn, r1.bqn Runtime
- f.bqn Formatter
- e.bqn Expression syntax explainer
+- p.bqn Plot generator
+
+Since it defines primitives, the runtime is only sort of BQN. This is
+why pr.bqn is required to process it. It's also compiled with a custom
+primitive set.
-Helper code used to obtain Javascript-formatted object code:
+e.bqn and p.bqn also require the definitions from svg.bqn; they are
+attached cjs.bqn.
-- pr.bqn Preprocess the runtime
-- cjs.bqn Format compiler output as Javascript literals
+Some of these files are also used elsewhere: pp.bqn preprocesses other
+primitive-defining code in ../test/ref.bqn and ../dzref, and f.bqn is
+used to format results in markdown while e.bqn generates diagrams for
+the tutorials.
diff --git a/test/README.txt b/test/README.txt
index c5913a4d..cf82e757 100644
--- a/test/README.txt
+++ b/test/README.txt
@@ -6,7 +6,7 @@ Test scripts:
- dz_wasm.js dzaima/BQN WebAssembly
dz_comp uses the self-hosted compiler ../src/c.bqn by default but not
-the runtime ../src/r.bqn. Pass -rt to test with the runtime, and -nocomp
+the runtime ../src/r*.bqn. Pass -rt to test with the runtime, and -nocomp
to test dzaima/BQN only (this doesn't pass as of the time of writing).
Test cases (cases/):