Restructure further into module-land
dkl9

dkl9 commited on 2023-197 08:48:46
Showing 3 changed files, with 10 additions and 16 deletions.

... ...
@@ -52,7 +52,7 @@
52 52
             <p>I made this many months ago with reckless/weird development practices, and haven't tested it since.
53 53
             Hopefully, it still works, but one of the dozens of moving parts may have broken.
54 54
             I might fix it sometime.</p>
55
-            <p><a href="documentation.md">There is prose documentation</a>, but it is outdated and only available as raw markdown.</p>
55
+            <p><a href="/essays/rtensor_doc">There is prose documentation.</a></p>
56 56
             <p>Comments and questions on RTensor are welcome.
57 57
             Email them to <code>contact@[this domain]</code>.</p>
58 58
             <p><a href="/">dkl9 home</a></p>
... ...
@@ -300,17 +300,10 @@
300 300
         <textarea id="bci" cols="120" rows="8"># Throw in some code ...</textarea><br />
301 301
         <span>use alternative numeric type:</span>
302 302
         <div id="iol"></div>
303
-        <script src="types/basic.js"></script>
304
-        <script src="types/bigint.js"></script>
305
-        <script src="types/complex.js"></script>
306
-        <script src="types/mathsfunc.js"></script>
307
-        <script src="types/real.js"></script>
308
-        <script src="maths_ast.js"></script>
309
-        <script src="maths_parser.js"></script>
310
-        <script src="rtensor_to_html.js"></script>
311
-        <script src="rtensor_lib.js"></script>
312
-        <script>
303
+        <script type="module">
313 304
             /*<![CDATA[*/
305
+            import {BUILTIN_FUNCS} from "./rtensor_lib.js";
306
+            import {TokenStream, NewParser} from "./maths_parser.js";
314 307
             const calcVars = Object.fromEntries(Object.entries(BUILTIN_FUNCS));
315 308
             calcVars["_"] = calcVars["null"];
316 309
             const pastInps = [];
... ...
@@ -5,6 +5,11 @@ import {Complex} from "./types/complex.js";
5 5
 import {MathsFunc} from "./types/mathsfunc.js";
6 6
 import {AST, vecOp, NumericType, anyNaN} from "./maths_ast.js";
7 7
 import {Token} from "./maths_parser.js";
8
+import {RTensorRender} from "./rtensor_to_html.js"
9
+
10
+AST.prototype.shouldParenMul = RTensorRender.shouldParenMul;
11
+AST.prototype.shouldParenExp = RTensorRender.shouldParenExp;
12
+AST.prototype.toHTML = RTensorRender.toHTML;
8 13
 
9 14
 export const IDENT_AST = new AST(1, new Token(1, ""));
10 15
 
... ...
@@ -74,7 +74,7 @@ const NCR = {
74 74
 
75 75
 const ucFromNcr = s => NCR[`&${s};`].characters;
76 76
 
77
-const RTensorRender = {
77
+export const RTensorRender = {
78 78
     // special character from identifier, along with "greek" boolean
79 79
     unicodify(ident) {
80 80
         if (ident == "infty" || ident == "inf" || ident == "infinity") {
... ...
@@ -323,7 +323,3 @@ const RTensorRender = {
323 323
         }
324 324
     },
325 325
 };
326
-
327
-AST.prototype.shouldParenMul = RTensorRender.shouldParenMul;
328
-AST.prototype.shouldParenExp = RTensorRender.shouldParenExp;
329
-AST.prototype.toHTML = RTensorRender.toHTML;
330 326