diff --git a/TODO.md b/TODO.md index 067d6b30..557d53f9 100644 --- a/TODO.md +++ b/TODO.md @@ -1,9 +1,17 @@ # named port -`Node` with optionally named port +[syntax] named port + +`Node` with named port `defnode` instead of `defcons` and `defelim` +`PortPush` -- new word + +`PortConnect` -- new word + +no `defru` just `defrule` -- add feature when very very needed + # render `NetRenderer` -- format to simple text representation of graph @@ -18,7 +26,7 @@ change the `render` command to simple `run` command the stack can take other types of values -- not only port -`"head" put` instead of `(let head)` +`"head" set` instead of `(let head)` explicit `"name" get` for local variable @@ -26,6 +34,8 @@ explicit `"name" get` for local variable linear logic as type system of inet +`Node` port name can be optional + `deftype` -- `TermType` -- use `'a` for name of pattern like in haskell `defnode` -- type check diff --git a/docs/notes/using-string-for-local-variable.md b/docs/notes/using-string-for-local-variable.md index ea6b0be1..2f7f9784 100644 --- a/docs/notes/using-string-for-local-variable.md +++ b/docs/notes/using-string-for-local-variable.md @@ -9,11 +9,11 @@ to get pure postfix syntax. ```inet defn cons append - "head" put append + "head" set append "head" get cons end ``` -How about keywords like `put`, but need a code block? +How about keywords like `set`, but need a code block? TODO diff --git a/docs/tests/DiffList.inet.one_two_soles.finial.txt b/docs/tests/DiffList.inet.one_two_soles.finial.txt index c8e25093..601a059e 100644 --- a/docs/tests/DiffList.inet.one_two_soles.finial.txt +++ b/docs/tests/DiffList.inet.one_two_soles.finial.txt @@ -1,24 +1,8 @@ cons#2 -- sole#1 [label="0-0"] -sole#1 -cons#2 cons#6 -- sole#5 [label="0-0"] -sole#5 -cons#6 cons#8 -- sole#7 [label="0-0"] -sole#7 -cons#8 cons#8 -- cons#6 [label="1-2"] -cons#6 -cons#8 diff#13 -- cons#6 [label="0-1"] -cons#6 -diff#13 cons#8 -- cons#2 [label="2-2"] -cons#2 -cons#8 diff#13 -- cons#2 [label="1-1"] -cons#2 -diff#13 -diff#13(2) -- diff#13 -diff#13 -diff#13(2) \ No newline at end of file +diff#13(2) -- diff#13 \ 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 1465870c..12262be3 100644 --- a/docs/tests/DiffList.inet.one_two_soles.initial.txt +++ b/docs/tests/DiffList.inet.one_two_soles.initial.txt @@ -1,33 +1,11 @@ cons#2 -- sole#1 [label="0-0"] -sole#1 -cons#2 diff#3 -- cons#2 [label="0-2"] -cons#2 -diff#3 cons#6 -- sole#5 [label="0-0"] -sole#5 -cons#6 cons#8 -- sole#7 [label="0-0"] -sole#7 -cons#8 cons#8 -- cons#6 [label="1-2"] -cons#6 -cons#8 diff#9 -- cons#8 [label="0-2"] -cons#8 -diff#9 diff_append#10 -- diff#3 [label="1-2"] -diff#3 -diff_append#10 cons#2 -- diff#3 [label="1-1"] -diff#3 -cons#2 cons#6 -- diff#9 [label="1-1"] -diff#9 -cons#6 diff_append#10 -- diff#9 [label="0-2" color=red] -diff#9 -diff_append#10 -diff_append#10(2) -- diff_append#10 -diff_append#10 -diff_append#10(2) \ No newline at end of file +diff_append#10(2) -- diff_append#10 \ 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 04c61389..54b2d1f6 100644 --- a/docs/tests/DiffList.inet.two_two_soles.finial.txt +++ b/docs/tests/DiffList.inet.two_two_soles.finial.txt @@ -1,30 +1,10 @@ cons#16 -- sole#15 [label="0-0"] -sole#15 -cons#16 cons#18 -- sole#17 [label="0-0"] -sole#17 -cons#18 cons#18 -- cons#16 [label="1-2"] -cons#16 -cons#18 cons#22 -- sole#21 [label="0-0"] -sole#21 -cons#22 cons#24 -- sole#23 [label="0-0"] -sole#23 -cons#24 cons#24 -- cons#22 [label="1-2"] -cons#22 -cons#24 diff#29 -- cons#22 [label="0-1"] -cons#22 -diff#29 cons#24 -- cons#18 [label="2-2"] -cons#18 -cons#24 diff#29 -- cons#16 [label="1-1"] -cons#16 -diff#29 -diff#29(2) -- diff#29 -diff#29 -diff#29(2) \ No newline at end of file +diff#29(2) -- diff#29 \ 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 3425c168..860979ed 100644 --- a/docs/tests/DiffList.inet.two_two_soles.initial.txt +++ b/docs/tests/DiffList.inet.two_two_soles.initial.txt @@ -1,39 +1,13 @@ cons#16 -- sole#15 [label="0-0"] -sole#15 -cons#16 cons#18 -- sole#17 [label="0-0"] -sole#17 -cons#18 cons#18 -- cons#16 [label="1-2"] -cons#16 -cons#18 diff#19 -- cons#18 [label="0-2"] -cons#18 -diff#19 cons#22 -- sole#21 [label="0-0"] -sole#21 -cons#22 cons#24 -- sole#23 [label="0-0"] -sole#23 -cons#24 cons#24 -- cons#22 [label="1-2"] -cons#22 -cons#24 diff#25 -- cons#24 [label="0-2"] -cons#24 -diff#25 diff_append#26 -- diff#19 [label="1-2"] -diff#19 -diff_append#26 cons#16 -- diff#19 [label="1-1"] -diff#19 -cons#16 cons#22 -- diff#25 [label="1-1"] -diff#25 -cons#22 diff_append#26 -- diff#25 [label="0-2" color=red] -diff#25 -diff_append#26 -diff_append#26(2) -- diff_append#26 -diff_append#26 -diff_append#26(2) \ No newline at end of file +diff_append#26(2) -- diff_append#26 \ 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 80edf675..b8fdacc3 100644 --- a/docs/tests/List.inet.six_soles.finial.txt +++ b/docs/tests/List.inet.six_soles.finial.txt @@ -1,45 +1,15 @@ cons#2 -- sole#1 [label="0-0"] -sole#1 -cons#2 cons#2 -- null#0 [label="1-0"] -null#0 -cons#2 cons#4 -- sole#3 [label="0-0"] -sole#3 -cons#4 cons#4 -- cons#2 [label="1-2"] -cons#2 -cons#4 cons#6 -- sole#5 [label="0-0"] -sole#5 -cons#6 cons#6 -- cons#4 [label="1-2"] -cons#4 -cons#6 cons#9 -- sole#8 [label="0-0"] -sole#8 -cons#9 cons#9 -- null#7 [label="1-0"] -null#7 -cons#9 cons#11 -- sole#10 [label="0-0"] -sole#10 -cons#11 cons#11 -- cons#9 [label="1-2"] -cons#9 -cons#11 append#16 -- sole#12 [label="0-0"] -sole#12 -append#16 append#16 -- cons#6 [label="1-2"] -cons#6 -append#16 cons#17 -- cons#11 [label="0-2"] -cons#11 -cons#17 cons#17 -- append#16 [label="1-2"] -append#16 -cons#17 -cons#17(2) -- cons#17 -cons#17 -cons#17(2) \ No newline at end of file +cons#17(2) -- cons#17 \ 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 ab9d1ceb..e75ec09f 100644 --- a/docs/tests/List.inet.six_soles.initial.txt +++ b/docs/tests/List.inet.six_soles.initial.txt @@ -1,45 +1,15 @@ cons#2 -- sole#1 [label="0-0"] -sole#1 -cons#2 cons#2 -- null#0 [label="1-0"] -null#0 -cons#2 cons#4 -- sole#3 [label="0-0"] -sole#3 -cons#4 cons#4 -- cons#2 [label="1-2"] -cons#2 -cons#4 cons#6 -- sole#5 [label="0-0"] -sole#5 -cons#6 cons#6 -- cons#4 [label="1-2"] -cons#4 -cons#6 cons#9 -- sole#8 [label="0-0"] -sole#8 -cons#9 cons#9 -- null#7 [label="1-0"] -null#7 -cons#9 cons#11 -- sole#10 [label="0-0"] -sole#10 -cons#11 cons#11 -- cons#9 [label="1-2"] -cons#9 -cons#11 cons#13 -- sole#12 [label="0-0"] -sole#12 -cons#13 cons#13 -- cons#11 [label="1-2"] -cons#11 -cons#13 append#14 -- cons#6 [label="1-2"] -cons#6 -append#14 append#14 -- cons#13 [label="0-2" color=red] -cons#13 -append#14 -append#14(2) -- append#14 -append#14 -append#14(2) \ No newline at end of file +append#14(2) -- append#14 \ 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 bdfa26eb..3f436964 100644 --- a/docs/tests/Nat.inet.four.finial.txt +++ b/docs/tests/Nat.inet.four.finial.txt @@ -1,15 +1,5 @@ add1#9 -- zero#8 [label="0-0"] -zero#8 -add1#9 add1#23 -- add1#25 [label="0-1"] -add1#25 -add1#23 add1#25 -- add1#27 [label="0-1"] -add1#27 -add1#25 add1#27 -- add1#9 [label="0-1"] -add1#9 -add1#27 -add1#23(1) -- add1#23 -add1#23 -add1#23(1) \ No newline at end of file +add1#23(1) -- add1#23 \ 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 39459166..0d15deaf 100644 --- a/docs/tests/Nat.inet.four.initial.txt +++ b/docs/tests/Nat.inet.four.initial.txt @@ -1,33 +1,11 @@ add1#9 -- zero#8 [label="0-0"] -zero#8 -add1#9 add1#11 -- zero#10 [label="0-0"] -zero#10 -add1#11 add#12 -- add1#9 [label="1-1"] -add1#9 -add#12 add1#14 -- zero#13 [label="0-0"] -zero#13 -add1#14 add1#16 -- zero#15 [label="0-0"] -zero#15 -add1#16 add#17 -- add1#14 [label="1-1"] -add1#14 -add#17 add#18 -- add#17 [label="0-2"] -add#17 -add#18 add#18 -- add#12 [label="1-2"] -add#12 -add#18 add#12 -- add1#11 [label="0-1" color=red] -add1#11 -add#12 add#17 -- add1#16 [label="0-1" color=red] -add1#16 -add#17 -add#18(2) -- add#18 -add#18 -add#18(2) \ No newline at end of file +add#18(2) -- add#18 \ 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 1431c2ef..b92e0356 100644 --- a/docs/tests/Nat.inet.two.finial.txt +++ b/docs/tests/Nat.inet.two.finial.txt @@ -1,9 +1,3 @@ add1#1 -- zero#0 [label="0-0"] -zero#0 -add1#1 add1#7 -- add1#1 [label="0-1"] -add1#1 -add1#7 -add1#7(1) -- add1#7 -add1#7 -add1#7(1) \ No newline at end of file +add1#7(1) -- add1#7 \ 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 fdd2a721..91df5507 100644 --- a/docs/tests/Nat.inet.two.initial.txt +++ b/docs/tests/Nat.inet.two.initial.txt @@ -1,15 +1,5 @@ add1#1 -- zero#0 [label="0-0"] -zero#0 -add1#1 add1#3 -- zero#2 [label="0-0"] -zero#2 -add1#3 add#4 -- add1#1 [label="1-1"] -add1#1 -add#4 add#4 -- add1#3 [label="0-1" color=red] -add1#3 -add#4 -add#4(2) -- add#4 -add#4 -add#4(2) \ No newline at end of file +add#4(2) -- add#4 \ No newline at end of file diff --git a/src/renderers/NetRenderer.ts b/src/renderers/NetRenderer.ts index bf8115f5..2e2f48f4 100644 --- a/src/renderers/NetRenderer.ts +++ b/src/renderers/NetRenderer.ts @@ -15,8 +15,6 @@ export class NetRenderer { const end = formatNode(edge.end.node) const indexes = `${edge.end.index}-${edge.start.index}` lines.push(`${end} -- ${start} [label="${indexes}"]`) - lines.push(`${start}`) - lines.push(`${end}`) } for (const edge of net.activeEdges) { @@ -24,16 +22,12 @@ export class NetRenderer { const end = formatNode(edge.end.node) const indexes = `${edge.end.index}-${edge.start.index}` lines.push(`${end} -- ${start} [label="${indexes}" color=red]`) - lines.push(`${start}`) - lines.push(`${end}`) } for (const port of net.portStack) { const start = formatNode(port.node) const end = `${formatNode(port.node)}(${port.index})` lines.push(`${end} -- ${start}`) - lines.push(`${start}`) - lines.push(`${end}`) } return lines.join("\n")