diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-03-25 20:55:32 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-03-25 20:55:32 -0400 |
| commit | 7108cf5d72bffd0c79788d9e3fe4c57782d0e606 (patch) | |
| tree | ef000753f650ed5b04d267d96e4baa982b77428e /docs/bqn.js | |
| parent | ec98071c058e68ab9f3eb62378cad09d05871ee5 (diff) | |
Move decompose and glyph definitions after setting .glyph
Diffstat (limited to 'docs/bqn.js')
| -rwxr-xr-x | docs/bqn.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/docs/bqn.js b/docs/bqn.js index 5e53cb27..fb1abb4f 100755 --- a/docs/bqn.js +++ b/docs/bqn.js @@ -188,9 +188,6 @@ let group_ord = (x,w) => { // βΎβx assuming w=group_len(x) return list(r,x.fill); } let type = x => isfunc(x) ? 3+(x.m||0) : x.sh ? 0 : 2-isnum(x); -let decompose = x => list(!isfunc(x) ? [-1,x] - : x.glyph ? [0,x] : x.repr ? x.repr() : [1,x]); -let glyph = x => x.glyph; let tofill = x => isfunc(x) ? undefined : x.sh ? arr(x.map(tofill),x.sh,x.fill) : isnum(x)?0 : ' '; @@ -249,6 +246,15 @@ let [runtime,setPrims] = run( ,provide.concat([0,1,2,32,3,8,-1,5,-Infinity,Infinity,4,-2,str("Β΄: π© must be a list"),str("Mapping: Equal-rank argument shapes don\'t agree"),str("Mapping: Argument shape prefixes don\'t agree"),str("βπ©: π© must have rank at least 1"),str("/: Replication argument must have rank 1"),str("/: Amounts to replicate must be natural numbers"),str("β½π©: π© must have rank at least 1"),str("π¨β½π©: π¨ must consist of integers"),str("βπ©: π© must have rank at least 1"),str("βπ©: π© must have rank at least 1"),str("βπ©: π© must have rank at least 1"),str("βπ©: π© cannot have length 0"),str("π¨βπ©: π¨ must be an array"),str("π¨βπ©: Indices in π¨ must be integers"),str("π¨βπ©: Indices out of range"),str("βΎ: Incompatible result elements in structural Under"),str(">π©: Elements of π© must have matching shapes"),str("βΎπ©: Elements of π© must all have the same rank"),str("βΎπ©: π© element rank must be at least argument rank"),str("βΎπ©: π© element shapes must be compatible"),str("βΎπ©: π© element trailing shapes must match"),str("βΎπ©: empty π© fill rank must be at least argument rank"),str("βΎπ©: π© must be an array"),str("π¨"),str("π©: π¨ must "),str("have rank at most 1"),str("consist of integers"),str("β"),str("β"),str("Β« or Β»: π© must have rank at least 1"),str("Β« or Β»: π¨ must not have higher rank than π©"),str("Β« or Β»: Rank of π¨ must be at least rank of π© minus 1"),str("Β« or Β»: π¨ must share π©\'s major cell shape"),str("π¨βπ©: π¨ must have rank at most 1"),str("π¨βπ©: Length of π¨ must be at most rank of π©"),str("π¨βπ©: π¨ must consist of natural numbers"),str("π¨βπ©: Window length π¨ must be at most axis length plus one"),str("First-axis primitive: π© must have rank at least 1"),str("Multi-axis primitive: π¨ must have rank at most 1"),str("Multi-axis primitive: Length of π¨ must be at most rank of π©"),str("β₯: No monadic form"),str("β€: No monadic form"),str("Β΄: Identity not found"),str("π¨β₯π©: π¨ must have rank at most 1"),str("π¨β₯π©: π¨ must consist of natural numbers"),str("π¨β₯π©: Can\'t compute axis length when rest of shape is empty"),str("π¨β₯π©: π¨ must consist of natural numbers or β β β½ β"),str("π¨β₯π©: Shape must be exact when reshaping with β"),str("βπ©: π© must consist of natural numbers"),str("βπ©: π© must be a number or list"),str("β or β: π½ result must have rank at most 1"),str("β or β: π½ result must have 1 to 3 elements"),str("β or β: π½ result must consist of integers"),str("Λ: π© must have rank at least 1"),str("Λ: Identity does not exist"),str("π¨βΎπ©: Rank of π¨ and π© must differ by at most 1"),str("π¨βΎπ©: Cell shapes of π¨ and π© must match"),str("π¨/π©: Lengths of components of π¨ must match π©"),str("β: Grouping argument must consist of integers"),str("β: Grouping argument values cannot be less than Β―1"),str("βπ©: π© must be a list"),str("π¨βπ©: π© must be an array"),str("π¨βπ©: Compound π¨ must be a list"),str("π¨βπ©: Total rank of π¨ must be at most rank of π©"),str("π¨βπ©: Lengths of π¨ must equal to π©, or one more only in a rank-1 component"),str("π¨βπ©: Indices in compound π¨ must be lists"),str("π¨βπ©: Index length in π¨ must match rank of π©"),str("π¨βπ©: Indices in π¨ must consist of integers"),str("π¨βπ©: Index out of range"),str("β or β: Rank of π¨ must be at least 1"),str("β or β: Rank of π© must be at least cell rank of π¨"),str("β or β: π¨ must be sorted"),str("pβπ© or π¨βp: p must have rank at least 1"),str("pβn or nβp: Rank of n must be at least cell rank of p"),str("βπ© or βπ©: π© must have rank at least 1"),str("β·π©: Rank of π¨ cannot exceed rank of π©"),str("π¨βπ©: π¨ must have rank at most 1"),str("π¨βπ©: Length of π¨ must not exceed rank of π©"),str("π¨βπ©: π¨ must consist of natural numbers"),str("π¨βπ©: Skipped result axis"),str("β: Rank of π¨ must be at least 1"),str("β: Rank of π© must be at least cell rank of π¨"),str("β: Repetition numbers in π¨ must be integers"),str("βΌ: Inverse failed"),str("βΌ: Inverse does not exist"),str("βΌ: Inverse not found"),str("Cannot currently invert blocks"),str("Cannot invert modifier")]) ,[[0,1,0,180],[0,0,4161,3],[0,0,4169,3],[0,0,4179,3],[2,0,4192,6],[0,0,4219,3],[0,0,4223,3],[0,0,4227,3],[1,0,4231,5],[1,0,4239,5],[2,0,4257,6],[2,0,4272,6],[2,0,4291,6],[2,0,4313,6],[2,0,4335,6],[0,0,4367,3],[0,0,4379,3],[0,0,4388,3],[0,0,4394,3],[0,0,4411,3],[0,0,4420,3],[1,0,4429,9],[0,0,4542,3],[0,0,4582,4],[0,0,4658,5],[0,0,4733,3],[1,1,4750,4],[1,1,4823,3],[0,0,4901,3],[0,0,4912,5],[2,0,4996,12],[0,0,5207,4],[0,0,5261,6],[0,0,5351,3],[0,0,5376,7],[0,0,5505,4],[0,0,5566,4],[0,0,5668,3],[0,0,5736,4],[1,1,5813,2],[0,0,5846,3],[0,0,5896,4],[0,0,6038,4],[2,1,6139,3],[1,0,6182,5],[0,0,6220,3],[2,0,6224,11],[0,0,6355,3],[0,0,6363,6],[0,0,6390,5],[0,0,6411,6],[1,0,6438,19],[0,0,6947,3],[0,0,6974,3],[0,0,7000,3],[2,1,7039,3],[0,0,7108,4],[0,0,7205,7],[0,0,7252,14],[0,0,7486,5],[1,1,7583,8],[1,0,7636,6],[1,1,7744,2],[0,0,7802,5],[0,0,7964,5],[0,0,8101,7],[0,0,8270,3],[0,0,8329,4],[1,0,8396,5],[2,1,8413,4],[0,0,8456,3],[0,0,8483,3],[0,0,8505,3],[0,0,8527,3],[0,0,8564,3],[0,0,8583,9],[0,0,8740,5],[0,0,8774,3],[1,1,8869,2],[2,0,8938,10],[2,0,8997,8],[1,0,9190,7],[0,0,9257,8],[0,0,9493,5],[0,0,9583,3],[1,0,9617,9],[0,0,9768,4],[0,0,9887,10],[0,0,10345,4],[0,0,10558,3],[0,0,10576,4],[1,0,10648,9],[1,1,10717,3],[1,0,10741,14],[1,1,11184,4],[1,0,11238,6],[0,0,11382,4],[0,0,11490,3],[0,0,11564,3],[0,0,11619,4],[0,0,11748,4],[0,0,11868,4],[2,0,11989,6],[1,1,12017,2],[2,0,12025,14],[2,0,12212,7],[0,0,12253,6],[0,0,12403,3],[2,1,12473,4],[0,0,12556,3],[0,0,12594,5],[0,0,12738,3],[0,0,12785,3],[0,0,12811,3],[1,0,12898,5],[2,0,12926,6],[0,0,12941,3],[0,0,12949,3],[1,1,12970,2],[0,0,12999,3],[0,0,13035,3],[0,0,13083,3],[0,0,13137,3],[0,0,13149,3],[0,0,13229,3],[1,1,13237,2],[0,0,13270,3],[0,0,13281,4],[0,0,13318,3],[0,0,13333,3],[0,0,13362,3],[0,0,13377,3],[0,0,13395,3],[0,0,13410,3],[0,0,13420,3],[0,0,13477,7],[0,0,13556,3],[0,0,13564,3],[1,1,13589,2],[0,0,13672,3],[1,1,13721,2],[1,1,13725,2],[0,0,13729,3],[0,0,13741,3],[0,0,13764,3],[1,0,13785,6],[1,0,13902,11],[1,0,14123,5],[0,0,14138,3],[0,0,14152,3],[0,0,14166,3],[1,0,14211,8],[0,0,14349,8],[0,0,14516,3],[0,0,14542,3],[0,0,14552,3],[0,0,14569,9],[0,0,14752,6],[0,0,14827,3],[2,0,14835,11],[1,0,14912,5],[0,0,14943,3],[0,0,14953,3],[1,0,14963,5],[0,0,14996,4],[0,0,15007,4],[0,0,15018,3],[0,0,15026,3],[0,0,15038,3],[0,0,15046,3],[1,0,15090,7],[0,0,15116,9],[1,0,15402,5],[0,0,15418,7],[0,0,15585,11],[0,0,15827,8],[0,0,16139,3],[0,0,16167,5],[0,0,16262,8],[0,0,16517,3],[0,0,16564,3],[0,0,16584,3],[1,0,16650,6],[0,0,16803,7],[0,0,16941,5],[0,0,17018,3],[0,0,17041,3],[0,0,17052,3],[0,0,17073,3],[0,0,17105,3],[0,0,17136,3],[0,0,17174,6],[0,0,17279,6],[0,0,17328,4],[0,0,17357,3],[0,0,17376,4],[1,1,17553,2],[0,0,17557,3],[0,0,17600,3],[0,0,17611,3],[0,0,17619,3],[0,0,17641,3],[0,0,17649,3],[0,0,17661,3],[0,0,17680,3],[0,0,17705,3],[0,0,17732,3],[1,0,17750,5],[1,0,17761,5],[0,0,17772,14],[0,0,17942,3],[0,0,17962,3],[0,0,17977,3],[0,0,17985,8],[0,0,18056,3],[0,0,18078,5],[0,0,18107,11],[2,0,18319,6],[0,0,18358,3],[0,0,18429,3],[0,0,18461,3],[1,0,18472,5],[1,1,18483,2],[2,1,18502,3],[0,0,18524,3],[0,0,18553,4],[0,0,18576,3],[1,0,18609,5],[0,0,18635,3],[0,0,18705,3],[0,0,18719,3],[0,0,18730,5],[0,0,18866,3],[0,0,18896,3],[0,0,18916,3],[0,0,18970,3],[0,0,19005,3],[0,0,19029,3],[0,0,19044,3],[0,0,19087,3],[0,0,19104,5],[0,0,19214,3],[0,0,19269,3],[0,0,19292,5],[1,0,19421,5],[2,0,19432,6],[0,0,19447,3],[0,0,19486,3],[0,0,19569,3],[0,0,19603,3],[0,0,19632,3],[0,0,19650,3],[0,0,19667,3],[0,0,19696,4],[0,0,19757,3],[0,0,19770,4],[0,0,19802,3],[0,0,19812,3],[0,0,19830,3],[0,0,19862,3],[0,0,19905,6],[0,0,19984,3],[0,0,20011,3],[0,0,20051,3]] ); + +let rtAssert = runtime[42] = assertFn("!"); +runtime.map((r,i) => { + let prims = "+-ΓΓ·ββββ|Β¬β§β¨<>β =β€β₯β‘β’β£β’β₯βΎββββ«»β½β/ββββββββ·β!ΛΛΛΒ¨ββΌΒ΄Λ`βββΈββΎββΆβββ"; + r.glyph = prims.charAt(i); // Used to format +}); +let decompose = x => list(!isfunc(x) ? [-1,x] + : x.glyph ? [0,x] : x.repr ? x.repr() : [1,x]); +let glyph = x => x.glyph; setPrims(list([decompose, glyph])); // Compiler @@ -258,11 +264,7 @@ let compile = run( ,[runtime[0],runtime[1],runtime[2],runtime[3],runtime[4],runtime[6],runtime[7],runtime[8],runtime[9],runtime[10],runtime[11],runtime[12],runtime[13],runtime[14],runtime[15],runtime[16],runtime[17],runtime[19],runtime[20],runtime[21],runtime[22],runtime[23],runtime[24],runtime[25],runtime[26],runtime[27],runtime[28],runtime[29],runtime[30],runtime[31],runtime[32],runtime[33],runtime[35],runtime[36],runtime[37],runtime[38],runtime[39],runtime[40],runtime[41],runtime[42],runtime[43],runtime[44],runtime[45],runtime[46],runtime[47],runtime[48],runtime[49],runtime[50],runtime[51],runtime[52],runtime[53],runtime[54],runtime[55],runtime[56],runtime[58],runtime[59],runtime[61],10,-1,26,9,0,1,2,3,-3,-2,5,17,3.141592653589793,Infinity,4,-4,-10,21,14,15,11,16,7,25,'\0','0','#','\'','\"','@',str("+-ΓΓ·ββββ|Β¬β§β¨<>β =β€β₯β‘β’β£β’β₯βΎββββ«»β½β/ββββββββ·β!"),str("ΛΛΛΒ¨ββΌΒ΄Λ`"),str("βββΈββΎββΆβββ"),str("β,"),str("βββ©"),str("(){}β¨β©"),str("βΏ"),str("Β·"),str("ππππ½πΎπ€π©π¨ππ"),str("ΟβΒ―."),str("_"),str("aA"),str("π¨"),str(" "),str("#\'\"@"),str("s"),str("Unknown character"),str(": "),str("Unclosed quote"),str("Numbers can\'t start with underscores"),str("Letter"),str(" \""),str("\" not allowed in numbers"),str("ea"),str("Negative sign in the middle of a number"),str("Portion of a number is empty"),str("Ill-formed decimal or exponent use"),str("Ο and β must occur alone"),str("Missing "),str("opening"),str("closing"),str("Malformed bracket nesting"),str("Empty program"),str("Swapped open and closed brackets"),str("Parentheses can\'t contain separators"),str("Empty statement or expression"),str("Invalid assignment or stranding use"),str("Can\'t strand Nothing (Β·)"),str("Can\'t return Nothing (Β·)"),str("Special name outside of any block"),str("Can\'t export from a non-immediate block"),str("Modules must be immediately assigned"),str("Modules must be destructured"),str("Nothing (Β·) cannot be assigned"),str("Missing operand"),str("Double subjects (missing βΏ?)"),str("Role of the two sides in assignment must match"),str("Function or modifier assignment to a non-name"),str("Assignment target must be a name or list of targets"),str("Can\'t use result of function/modifier assignment without parentheses"),str("Redefinition"),str("Undefined identifier"),str("Imports must have been exported"),str("Second-level parts of a train must be functions"),str("Can\'t use Nothing (Β·) in lists")] ,[[0,1,0,32],[1,0,464,5],[1,1,483,5],[0,0,607,45],[0,0,2168,22],[0,0,2966,119],[0,0,7866,13],[0,0,7988,3],[0,0,7996,3],[0,0,8036,3],[0,0,8055,3],[0,0,8078,3],[0,0,8100,3],[2,1,8124,3],[0,0,8160,6],[2,1,8297,3],[0,0,8366,3],[0,0,8416,3],[0,0,8438,3],[0,0,8468,3],[0,0,8526,3],[0,0,8588,4],[0,0,8640,3],[2,1,8665,3]] ); -runtime[42] = assertFn("!"); -runtime.map((r,i) => { - let prims = "+-ΓΓ·ββββ|Β¬β§β¨<>β =β€β₯β‘β’β£β’β₯βΎββββ«»β½β/ββββββββ·β!ΛΛΛΒ¨ββΌΒ΄Λ`βββΈββΎββΆβββ"; - r.glyph = prims.charAt(i); // Used to format -}); +runtime[42] = rtAssert; let bqn = src => run.apply(null,compile(str(src),runtime)); // Formatter |
