diff --git a/TODO.md b/TODO.md index 4fa99ed5..996b8dc0 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,3 @@ -use unicode for subscript number - `connect` v.s. `reconnect` - `reconnect` is used in `PortReconnect` diff --git a/docs/tests/DiffList.inet.one_two_soles.finial.txt b/docs/tests/DiffList.inet.one_two_soles.finial.txt index 9d994dc2..5536acfd 100644 --- a/docs/tests/DiffList.inet.one_two_soles.finial.txt +++ b/docs/tests/DiffList.inet.one_two_soles.finial.txt @@ -1,8 +1,8 @@ -(sole#1)-return head-(cons#2) -(sole#5)-return head-(cons#6) -(sole#7)-return head-(cons#8) -(cons#6)-return tail-(cons#8) -(cons#6)-tail left-(diff#13) -(cons#2)-return return-(cons#8) -(cons#2)-tail right-(diff#13) -(diff#13)-return \ No newline at end of file +(sole₁)-return head-(cons₂) +(sole₅)-return head-(cons₆) +(sole₇)-return head-(cons₈) +(cons₆)-return tail-(cons₈) +(cons₆)-tail left-(diff₁₃) +(cons₂)-return return-(cons₈) +(cons₂)-tail right-(diff₁₃) +(diff₁₃)-return \ No newline at end of file diff --git a/docs/tests/DiffList.inet.one_two_soles.initial.txt b/docs/tests/DiffList.inet.one_two_soles.initial.txt index 4a5b5651..0ce30ed1 100644 --- a/docs/tests/DiffList.inet.one_two_soles.initial.txt +++ b/docs/tests/DiffList.inet.one_two_soles.initial.txt @@ -1,11 +1,11 @@ -(diff#9)-return!left-(diff_append#10) -(sole#1)-return head-(cons#2) -(cons#2)-return left-(diff#3) -(sole#5)-return head-(cons#6) -(sole#7)-return head-(cons#8) -(cons#6)-return tail-(cons#8) -(cons#8)-return left-(diff#9) -(diff#3)-return right-(diff_append#10) -(diff#3)-right tail-(cons#2) -(diff#9)-right tail-(cons#6) -(diff_append#10)-return \ No newline at end of file +(diff₉)-return!left-(diff_append₁₀) +(sole₁)-return head-(cons₂) +(cons₂)-return left-(diff₃) +(sole₅)-return head-(cons₆) +(sole₇)-return head-(cons₈) +(cons₆)-return tail-(cons₈) +(cons₈)-return left-(diff₉) +(diff₃)-return right-(diff_append₁₀) +(diff₃)-right tail-(cons₂) +(diff₉)-right tail-(cons₆) +(diff_append₁₀)-return \ No newline at end of file diff --git a/docs/tests/DiffList.inet.two_two_soles.finial.txt b/docs/tests/DiffList.inet.two_two_soles.finial.txt index 3a79ab2e..a2325cb4 100644 --- a/docs/tests/DiffList.inet.two_two_soles.finial.txt +++ b/docs/tests/DiffList.inet.two_two_soles.finial.txt @@ -1,10 +1,10 @@ -(sole#15)-return head-(cons#16) -(sole#17)-return head-(cons#18) -(cons#16)-return tail-(cons#18) -(sole#21)-return head-(cons#22) -(sole#23)-return head-(cons#24) -(cons#22)-return tail-(cons#24) -(cons#22)-tail left-(diff#29) -(cons#18)-return return-(cons#24) -(cons#16)-tail right-(diff#29) -(diff#29)-return \ No newline at end of file +(sole₁₅)-return head-(cons₁₆) +(sole₁₇)-return head-(cons₁₈) +(cons₁₆)-return tail-(cons₁₈) +(sole₂₁)-return head-(cons₂₂) +(sole₂₃)-return head-(cons₂₄) +(cons₂₂)-return tail-(cons₂₄) +(cons₂₂)-tail left-(diff₂₉) +(cons₁₈)-return return-(cons₂₄) +(cons₁₆)-tail right-(diff₂₉) +(diff₂₉)-return \ No newline at end of file diff --git a/docs/tests/DiffList.inet.two_two_soles.initial.txt b/docs/tests/DiffList.inet.two_two_soles.initial.txt index 1580ac31..02e15d96 100644 --- a/docs/tests/DiffList.inet.two_two_soles.initial.txt +++ b/docs/tests/DiffList.inet.two_two_soles.initial.txt @@ -1,13 +1,13 @@ -(diff#25)-return!left-(diff_append#26) -(sole#15)-return head-(cons#16) -(sole#17)-return head-(cons#18) -(cons#16)-return tail-(cons#18) -(cons#18)-return left-(diff#19) -(sole#21)-return head-(cons#22) -(sole#23)-return head-(cons#24) -(cons#22)-return tail-(cons#24) -(cons#24)-return left-(diff#25) -(diff#19)-return right-(diff_append#26) -(diff#19)-right tail-(cons#16) -(diff#25)-right tail-(cons#22) -(diff_append#26)-return \ No newline at end of file +(diff₂₅)-return!left-(diff_append₂₆) +(sole₁₅)-return head-(cons₁₆) +(sole₁₇)-return head-(cons₁₈) +(cons₁₆)-return tail-(cons₁₈) +(cons₁₈)-return left-(diff₁₉) +(sole₂₁)-return head-(cons₂₂) +(sole₂₃)-return head-(cons₂₄) +(cons₂₂)-return tail-(cons₂₄) +(cons₂₄)-return left-(diff₂₅) +(diff₁₉)-return right-(diff_append₂₆) +(diff₁₉)-right tail-(cons₁₆) +(diff₂₅)-right tail-(cons₂₂) +(diff_append₂₆)-return \ No newline at end of file diff --git a/docs/tests/List.inet.six_soles.finial.txt b/docs/tests/List.inet.six_soles.finial.txt index f5e31c39..094d3842 100644 --- a/docs/tests/List.inet.six_soles.finial.txt +++ b/docs/tests/List.inet.six_soles.finial.txt @@ -1,13 +1,13 @@ -(sole#12)-return head-(cons#17) -(sole#5)-return head-(cons#19) -(cons#19)-return tail-(cons#17) -(sole#10)-return head-(cons#21) -(cons#21)-return tail-(cons#19) -(sole#3)-return head-(cons#23) -(cons#23)-return tail-(cons#21) -(sole#8)-return head-(cons#25) -(cons#25)-return tail-(cons#23) -(sole#1)-return head-(cons#27) -(cons#27)-return tail-(cons#25) -(null#0)-return tail-(cons#27) -(cons#17)-return \ No newline at end of file +(sole₁₂)-return head-(cons₁₇) +(sole₅)-return head-(cons₁₉) +(cons₁₉)-return tail-(cons₁₇) +(sole₁₀)-return head-(cons₂₁) +(cons₂₁)-return tail-(cons₁₉) +(sole₃)-return head-(cons₂₃) +(cons₂₃)-return tail-(cons₂₁) +(sole₈)-return head-(cons₂₅) +(cons₂₅)-return tail-(cons₂₃) +(sole₁)-return head-(cons₂₇) +(cons₂₇)-return tail-(cons₂₅) +(null₀)-return tail-(cons₂₇) +(cons₁₇)-return \ No newline at end of file diff --git a/docs/tests/List.inet.six_soles.initial.txt b/docs/tests/List.inet.six_soles.initial.txt index 61e97d99..9ecee03c 100644 --- a/docs/tests/List.inet.six_soles.initial.txt +++ b/docs/tests/List.inet.six_soles.initial.txt @@ -1,15 +1,15 @@ -(cons#13)-return!left-(append#14) -(sole#1)-return head-(cons#2) -(null#0)-return tail-(cons#2) -(sole#3)-return head-(cons#4) -(cons#2)-return tail-(cons#4) -(sole#5)-return head-(cons#6) -(cons#4)-return tail-(cons#6) -(sole#8)-return head-(cons#9) -(null#7)-return tail-(cons#9) -(sole#10)-return head-(cons#11) -(cons#9)-return tail-(cons#11) -(sole#12)-return head-(cons#13) -(cons#11)-return tail-(cons#13) -(cons#6)-return right-(append#14) -(append#14)-return \ No newline at end of file +(cons₁₃)-return!left-(append₁₄) +(sole₁)-return head-(cons₂) +(null₀)-return tail-(cons₂) +(sole₃)-return head-(cons₄) +(cons₂)-return tail-(cons₄) +(sole₅)-return head-(cons₆) +(cons₄)-return tail-(cons₆) +(sole₈)-return head-(cons₉) +(null₇)-return tail-(cons₉) +(sole₁₀)-return head-(cons₁₁) +(cons₉)-return tail-(cons₁₁) +(sole₁₂)-return head-(cons₁₃) +(cons₁₁)-return tail-(cons₁₃) +(cons₆)-return right-(append₁₄) +(append₁₄)-return \ No newline at end of file diff --git a/docs/tests/Nat.inet.four.finial.txt b/docs/tests/Nat.inet.four.finial.txt index b8ee8c55..2a3b0902 100644 --- a/docs/tests/Nat.inet.four.finial.txt +++ b/docs/tests/Nat.inet.four.finial.txt @@ -1,5 +1,5 @@ -(add1#35)-return prev-(add1#29) -(add1#37)-return prev-(add1#35) -(add1#41)-return prev-(add1#37) -(zero#14)-return prev-(add1#41) -(add1#29)-return \ No newline at end of file +(add1₃₅)-return prev-(add1₂₉) +(add1₃₇)-return prev-(add1₃₅) +(add1₄₁)-return prev-(add1₃₇) +(zero₁₄)-return prev-(add1₄₁) +(add1₂₉)-return \ No newline at end of file diff --git a/docs/tests/Nat.inet.four.initial.txt b/docs/tests/Nat.inet.four.initial.txt index 20add477..86f0d4ef 100644 --- a/docs/tests/Nat.inet.four.initial.txt +++ b/docs/tests/Nat.inet.four.initial.txt @@ -1,11 +1,11 @@ -(add1#17)-return!x-(add#18) -(add1#22)-return!x-(add#23) -(zero#14)-return prev-(add1#15) -(zero#16)-return prev-(add1#17) -(add1#15)-return y-(add#18) -(zero#19)-return prev-(add1#20) -(zero#21)-return prev-(add1#22) -(add1#20)-return y-(add#23) -(add#23)-return x-(add#24) -(add#18)-return y-(add#24) -(add#24)-return \ No newline at end of file +(add1₁₇)-return!x-(add₁₈) +(add1₂₂)-return!x-(add₂₃) +(zero₁₄)-return prev-(add1₁₅) +(zero₁₆)-return prev-(add1₁₇) +(add1₁₅)-return y-(add₁₈) +(zero₁₉)-return prev-(add1₂₀) +(zero₂₁)-return prev-(add1₂₂) +(add1₂₀)-return y-(add₂₃) +(add₂₃)-return x-(add₂₄) +(add₁₈)-return y-(add₂₄) +(add₂₄)-return \ No newline at end of file diff --git a/docs/tests/Nat.inet.two.finial.txt b/docs/tests/Nat.inet.two.finial.txt index e8eab9f5..fdea242d 100644 --- a/docs/tests/Nat.inet.two.finial.txt +++ b/docs/tests/Nat.inet.two.finial.txt @@ -1,3 +1,3 @@ -(add1#13)-return prev-(add1#11) -(zero#4)-return prev-(add1#13) -(add1#11)-return \ No newline at end of file +(add1₁₃)-return prev-(add1₁₁) +(zero₄)-return prev-(add1₁₃) +(add1₁₁)-return \ No newline at end of file diff --git a/docs/tests/Nat.inet.two.initial.txt b/docs/tests/Nat.inet.two.initial.txt index 09a9a9c8..a4afe7e1 100644 --- a/docs/tests/Nat.inet.two.initial.txt +++ b/docs/tests/Nat.inet.two.initial.txt @@ -1,5 +1,5 @@ -(add1#7)-return!x-(add#8) -(zero#4)-return prev-(add1#5) -(zero#6)-return prev-(add1#7) -(add1#5)-return y-(add#8) -(add#8)-return \ No newline at end of file +(add1₇)-return!x-(add₈) +(zero₄)-return prev-(add1₅) +(zero₆)-return prev-(add1₇) +(add1₅)-return y-(add₈) +(add₈)-return \ No newline at end of file diff --git a/docs/tests/Nat.inet.zero_zero_add.finial.txt b/docs/tests/Nat.inet.zero_zero_add.finial.txt index 0ea06bae..fb8d110a 100644 --- a/docs/tests/Nat.inet.zero_zero_add.finial.txt +++ b/docs/tests/Nat.inet.zero_zero_add.finial.txt @@ -1 +1 @@ -(zero#0)-return \ No newline at end of file +(zero₀)-return \ No newline at end of file diff --git a/docs/tests/Nat.inet.zero_zero_add.initial.txt b/docs/tests/Nat.inet.zero_zero_add.initial.txt index fadd96fa..de846e2d 100644 --- a/docs/tests/Nat.inet.zero_zero_add.initial.txt +++ b/docs/tests/Nat.inet.zero_zero_add.initial.txt @@ -1,3 +1,3 @@ -(zero#1)-return!x-(add#2) -(zero#0)-return y-(add#2) -(add#2)-return \ No newline at end of file +(zero₁)-return!x-(add₂) +(zero₀)-return y-(add₂) +(add₂)-return \ No newline at end of file diff --git a/src/renderers/formatNode.ts b/src/renderers/formatNode.ts index 6f3bd3c9..5d361725 100644 --- a/src/renderers/formatNode.ts +++ b/src/renderers/formatNode.ts @@ -1,5 +1,22 @@ import { Node } from "../lang/graph" export function formatNode(node: Node): string { - return `${node.name}#${node.id}` + const subscript = [...node.id.toString()] + .map((c) => numberSubscripts[c] || c) + .join("") + + return `${node.name}${subscript}` +} + +const numberSubscripts: Record = { + "0": "₀", + "1": "₁", + "2": "₂", + "3": "₃", + "4": "₄", + "5": "₅", + "6": "₆", + "7": "₇", + "8": "₈", + "9": "₉", }