From b2806d7af02e46069c5604baab70592f3e6096bc Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 24 Sep 2020 14:08:54 -0400 Subject: Support table column alignment in md.bqn --- doc/fromDyalog.md | 6 +- docs/doc/fromDyalog.html | 202 +++++++++++++++--------------- docs/implementation/vm.html | 296 ++++++++++++++++++++++---------------------- docs/tutorial/list.html | 16 +-- implementation/vm.md | 6 +- md.bqn | 13 +- tutorial/list.md | 2 +- 7 files changed, 272 insertions(+), 269 deletions(-) diff --git a/doc/fromDyalog.md b/doc/fromDyalog.md index 1818a094..42a2ffc7 100644 --- a/doc/fromDyalog.md +++ b/doc/fromDyalog.md @@ -37,19 +37,19 @@ Dyalog uses value types (array, function, and so on) to determine syntax while B Here are some closest equivalents in Dyalog APL for the BQN functions that don't use the same glyphs as APL. Correspondence can be approximate, and `⌽` is just used as a decorator to mean "reverse some things". | BQN | `⋆` | `√` | `∧` | `∨` | `¬` | `≠` | `<` | `>` | `≢` | `⥊` | `∾` | `≍` | -|-------|-----|----------|-------|-------|-------|-----|-----|-----|-----|-----|-------|--------| +|:-----:|:---:|:--------:|:-----:|:-----:|:-----:|:---:|:---:|:---:|:---:|:---:|:-----:|:------:| | Monad | `*` | `*∘(÷2)` | `[⍋]` | `[⍒]` | `~` | `≢` | `⊂` | `↑` | `⍴` | `,` | `⊃,⌿` | `↑,⍥⊂` | | Dyad | `*` | `*∘÷⍨` | `∧` | `∨` | `1+-` | `≠` | `<` | `>` | `≢` | `⍴` | `⍪` | `↑,⍥⊂` | | BQN | `↑` | `↓` | `↕` | `/` | `⍋` | `⍒` | `⊏` | `⊑` | `⊐` | `⊒` | `∊` | `⍷` | `⊔` | -|-------|------|---------|------|-----|-----|-------|------|-----|-----|-----|-----|-----|------------| +|:-----:|:----:|:-------:|:----:|:---:|:---:|:-----:|:----:|:---:|:---:|:---:|:---:|:---:|:----------:| | Monad | `,⍀` | `⌽,⌽⍀⌽` | `⍳` | `⍸` | `⍋` | `⍒` | `⊣⌿` | `⊃` | | `…` | `≠` | `∪` | `⌸` | | Dyad | `↑` | `↓` | `,⌿` | `⌿` | `⍸` | `⌽⍸⌽` | `⌷` | `⊃` | `⍳` | `…` | `∊` | `⍷` | `⌸` or `⊆` | Modifiers are a little harder. Many have equivalents in some cases, but Dyalog sometimes chooses different functionality based on whether the operand is an array. In BQN an array is always treated as a constant function. | BQN | `¨` | `⌜` | `˝` | `⎉` | `⍟` | `˜` | `∘` | `○` | `⟜` | -|--------|-----|------|-----|-----|-----|-----|-----|-----|-----| +|:------:|:---:|:----:|:---:|:---:|:---:|:---:|:---:|:---:|:---:| | Dyalog | `¨` | `∘.` | `⌿` | `⍤` | `⍣` | `⍨` | `⍤` | `⍥` | `∘` | In BQN `⎉` is Rank and `∘` is Atop. Dyalog's Atop (`⍤`) and Over (`⍥`) were added in version 18.0. diff --git a/docs/doc/fromDyalog.html b/docs/doc/fromDyalog.html index 96320db6..aa53a768 100644 --- a/docs/doc/fromDyalog.html +++ b/docs/doc/fromDyalog.html @@ -74,105 +74,105 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + +
BQN¬<>BQN¬<>
Monad**(÷2)[][]~,,,⍥⊂Monad**(÷2)[][]~,,,⍥⊂
Dyad**÷1+-<>,⍥⊂Dyad**÷1+-<>,⍥⊂
- - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + +
BQN/BQN/
Monad,,Monad,,
Dyad, or Dyad, or
@@ -180,30 +180,30 @@ - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - + + + + + + + + + +
BQN¨˝˜BQN¨˝˜
Dyalog¨.Dyalog¨.
diff --git a/docs/implementation/vm.html b/docs/implementation/vm.html index c0608644..4805d6b1 100644 --- a/docs/implementation/vm.html +++ b/docs/implementation/vm.html @@ -36,221 +36,221 @@ - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + @@ -259,7 +259,7 @@
BB NameUsedLikeArgsUsedLikeArgs Description
00 PUSHXIXI Push object I
11 VAROII Push named variable I
22 VARMII Push named variable I reference
33 ARROXNXN Create length-N list
44 ARRMX3NX3N Create length-N reference list
55 FN1C Monadic function call
66 FN2C Dyadic function call
77 OP1DXX 1-modifier call
88 OP2DXX 2-modifier call
99 TR2DXX Create 2-train
1010 TR3D Create 3-train
1111 SETNXX Define variable
1212 SETUXX Change variable
1313 SETMXX Modify variable
1414 POPSXX Pop and discard top of stack
1515 DFNDXIXI Localize and push block I
1616 FN1OX5X5 Monadic call, checking for ·
1717 FN2OX6X6 Dyadic call, checking for ·
1818 CHKV Error if top of stack is ·
1919 TR3OX10X10 Create 3-train, checking for ·
2020 OP2H Bind right operand to 2-modifier
2121 LOCOXD, IXD, I Push local variable I from D frames up
2222 LOCMXD, IXD, I Push local variable reference I from D frames up
2323 VFYM Convert to matcher (for header tests)
2424 SETH Test header
2525 RETNXX Returns top of stack
- + @@ -267,103 +267,103 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -389,114 +389,114 @@
BB Name Stack effect Comments
00 PUSH (iconsts)
33 ARRO x0 xm x0 xm N total variables (m=n-1)
55 FN1C 𝕩 𝕤 (𝕊 𝕩) 16: 𝕩 may be ·
66 FN2C 𝕩 𝕤 𝕨 (𝕨 𝕊 𝕩) 17: 𝕨 or 𝕩 may be ·
77 OP1D 𝕣 𝕗 (𝔽 _𝕣)
88 OP2D 𝕘 𝕣 𝕗 (𝔽 _𝕣_ 𝔾)
99 TR2D g f (F G)
1010 TR3D h g f (F G H) 19: F may be ·
1111 SETN x r (rx) r is a reference
1212 SETU x r (rx) r is a reference
1313 SETM x f r (r F x) r is a reference
1414 POPS x
1515 DFND (iblocks) Also sets block's parent scope
2020 OP2H 𝕘 𝕣 (_𝕣_ 𝕘)
2121 LOCO x Local variable value
2222 LOCM r Local variable reference
2525 RETN x x Returns from current block
- + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/docs/tutorial/list.html b/docs/tutorial/list.html index 7895a891..373da09a 100644 --- a/docs/tutorial/list.html +++ b/docs/tutorial/list.html @@ -50,22 +50,22 @@
IndInd Name Description / restrictions
00 IsArray 1 if the right argument is an array, 0 otherwise
11 Type The fill value for array 𝕩
22 Log (natural or base-𝕨 logarithm) for atomic arguments
33 GroupLen ¨𝕩 for a valid list 𝕩
44 GroupOrd ∾⊔𝕩 provided 𝕨 is GroupLen 𝕩
55 !
66 + On two atoms
77 - On one or two atoms
88 × On two atoms
99 ÷ On one or two atoms
1010 On one or two atoms
1111 On one atom
1212 = On one value or two atoms
1313 On two atoms
1414 For array 𝕩
1515 For array 𝕩 with no 𝕨 or 𝕨=(×´)𝕩
1616 For atom 𝕨 and list 𝕩
1717 For natural number 𝕩
1818 On arrays
1919 `
2020
- - + + - - + + - - + + - - + +
DataOperationDataOperation
NumberFunctionNumberFunction
Character1-modifierCharacter1-modifier
Array2-modifierArray2-modifier
diff --git a/implementation/vm.md b/implementation/vm.md index 2e501bf5..a94eadb5 100644 --- a/implementation/vm.md +++ b/implementation/vm.md @@ -43,7 +43,7 @@ Because most encoded numbers will be less than 128, for higher performance it's The following instructions are defined by dzaima/BQN. The ones emitted by the self-hosted BQN compiler are marked in the "used" column. | B | Name | Used | Like | Args | Description -|----|------|------|------|----------|------------ +|---:|------|:----:|-----:|:---------|------------ | 0 | PUSH | X | | `I` | Push object `I` | 1 | VARO | | | `I` | Push named variable `I` | 2 | VARM | | | `I` | Push named variable `I` reference @@ -74,7 +74,7 @@ The following instructions are defined by dzaima/BQN. The ones emitted by the se Stack effects for most instructions are given below. Instructions 16, 17, and 19 are identical to 5, 6, and 10 except that the indicated values in the higher-numbered instructions may be `·`. The lower-numbered instructions are not yet emitted by the self-hosted compiler and can be implemented simply by making them identical to the higher-numbered ones; however, it may be possible to make them faster by not checking for Nothing. | B | Name | Stack effect | Comments -|----|------|-----------------------|-------- +|---:|------|-----------------------|-------- | 0 | PUSH | `→ (i⊑consts)` | | 3 | ARRO | `x0 … xm → ⟨x0 … xm⟩` | `N` total variables (`m=n-1`) | 5 | FN1C | `𝕩 𝕤 → (𝕊 𝕩)` | 16: `𝕩` may be `·` @@ -126,7 +126,7 @@ While it's perfectly possible to implement the runtime from scratch, the pseudo- 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. | Ind | Name | Description / restrictions -|-----|------------|--------------------------- +|----:|------------|--------------------------- | 0 | `IsArray` | 1 if the right argument is an array, 0 otherwise | 1 | `Type` | The fill value for array `𝕩` | 2 | `Log` | `⋆⁼` (natural or base-`𝕨` logarithm) for atomic arguments diff --git a/md.bqn b/md.bqn index 428992d0..45fdada0 100644 --- a/md.bqn +++ b/md.bqn @@ -254,14 +254,17 @@ Markdown ← {filename𝕊𝕩: r ← b > » '\' = 𝕩 # Non-escaped bars 1 -˜ (¬r∨«b>r) × o + +` r } + alignments ← (" align="""∾∾⟜"""")⍟(0<≠)¨ ""‿"right"‿"left"‿"center" ProcTable ← { rows ← (Trim¨ CutTableRow⊸⊔)¨ 𝕩 - inc ← ¬ rule ← ∧´∘∾¨'-'=rows - rows ↩ ProcInline¨¨⌾(inc⊸/) rows + incl ← ¬ rule ← (∧´∾∊"-:"˙)¨ rows + align ← alignments ⊏˜ (+˜⊸+´0‿¯1⊏⊢)¨ ':' = ⊑ rule / rows + rows ↩ ProcInline¨¨⌾(incl⊸/) rows rows ↩ (⊏rows) (⊢ ∾ ⟨""⟩ /˜ 0⌈-○≠)¨ rows - rowType ← inc / +` rule # Head or body - DoRow ← { lf ∾ JoinLines 𝕨⊸Html¨ 𝕩 } - rows ↩ (rowType ⊏ "th"‿"td") DoRow¨ inc/rows + rowType ← incl / +` rule # Head or body + tags ← rowType ⊏ "th"‿"td" + DoRow ← { lf ∾ JoinLines 𝕨 Html¨ 𝕩 } + rows ↩ (<˘ tags ∾⌜ align) DoRow¨ incl/rows rowGroups ← ¯1 ↓ rowType ⊔○(∾⟜2) "tr"⊸Html¨ rows sections ← "thead"‿"tbody" Html⟜(lf ∾ JoinLines)¨ rowGroups "table" Html lf ∾ JoinLines (0 < ≠¨rowGroups) / sections diff --git a/tutorial/list.md b/tutorial/list.md index f97e5d95..015c2326 100644 --- a/tutorial/list.md +++ b/tutorial/list.md @@ -53,7 +53,7 @@ A ligature is a kind of notation and doesn't do something specific like a functi Now that all six BQN types have been introduced, let's make a table: Data | Operation -----------|----------- +:--------:|:---------: Number | Function Character | 1-modifier Array | 2-modifier -- cgit v1.2.3