retroforth/interface/stack-comments.retro
crc cf00ecef3b add float, address stack effect diagrams
FossilOrigin-Name: ca21010ddad34b91c18fec98f2106b877eadd42c07f168c60fa1c0976e05f32e
2024-09-12 13:21:26 +00:00

474 lines
16 KiB
Forth

Add stack comments to existing words (from retro.muri,
retro.forth, interface/ll.retro, and interface/dedup.retro).
Words defined in the others will make use of the extended
comment format this introduces to add them inline.
~~~
{{
:save (s-)
n:inc s:chop here swap s:keep |drop #2 + d:last.name #4 - store ;
:stack-comment? (s-sf) dup #0 s:fetch $: eq? ;
---reveal---
:sigil:( stack-comment? &save &drop choose ; immediate
}}
:d:describe (:s-)
d:lookup nl
dup 'Name:_____ s:put d:name s:put nl
dup 'Address:__ s:put d:xt fetch n:put nl
dup 'Class:____ s:put d:class fetch dup n:put d:lookup-xt dup n:-zero? [ sp d:name s:put ] &drop choose nl
dup 'Source:___ s:put d:source fetch dup n:-zero? &s:put &drop choose nl
dup 'Stack:____ s:put d:stack fetch dup n:-zero? &s:put &drop choose nl
dup 'A._Stack:_ s:put d:astack fetch dup n:-zero? &s:put &drop choose nl
dup 'Float:____ s:put d:fstack fetch dup n:-zero? &s:put &drop choose nl
dup 'Descr:____ s:put d:descr fetch dup n:-zero? &s:put &drop choose nl
drop ;
:d:set-stack-comment (:ss-)
d:lookup dup n:-zero? [ d:stack &s:keep dip store ] &drop-pair choose ;
:d:set-astack-comment (:ss-)
d:lookup dup n:-zero? [ d:astack &s:keep dip store ] &drop-pair choose ;
:d:set-fstack-comment (:ss-)
d:lookup dup n:-zero? [ d:fstack &s:keep dip store ] &drop-pair choose ;
~~~
Add the stack comments for existing words:
~~~
'n- 'pop d:set-astack-comment
'-n 'push d:set-astack-comment
~~~
~~~
'ss- 'd:set-source d:set-stack-comment
'n-s 'n:to-string/reversed d:set-stack-comment
's-s 's:truncate d:set-stack-comment
's-sf 's:oversize? d:set-stack-comment
'- 'err:notfound d:set-stack-comment
'd-a 'd:stack d:set-stack-comment
'd-a 'd:astack d:set-stack-comment
'd-a 'd:fstack d:set-stack-comment
'd-a 'd:descr d:set-stack-comment
'n- 'io:core d:set-stack-comment
~~~
~~~
'-c '$ d:set-stack-comment
'-s '' d:set-stack-comment
'- '( d:set-stack-comment
'- ') d:set-stack-comment
'nn-n '* d:set-stack-comment
'xyz-rv '*/mod d:set-stack-comment
'nn-n '+ d:set-stack-comment
'n- ', d:set-stack-comment
'nn-n '- d:set-stack-comment
'- '---reveal--- d:set-stack-comment
'nn-f '-eq? d:set-stack-comment
'fq- '-if d:set-stack-comment
'fq- '-if; d:set-stack-comment
'nm-v '/ d:set-stack-comment
'- '// d:set-stack-comment
'nm-rv '/mod d:set-stack-comment
'n-n_||_n- '0; d:set-stack-comment
'- '; d:set-stack-comment
'n-nn_||_n-n '?dup d:set-stack-comment
'-n 'ASCII:ACK d:set-stack-comment
'-n 'ASCII:BEL d:set-stack-comment
'-n 'ASCII:BS d:set-stack-comment
'-n 'ASCII:CAN d:set-stack-comment
'-n 'ASCII:CR d:set-stack-comment
'-n 'ASCII:DC1 d:set-stack-comment
'-n 'ASCII:DC2 d:set-stack-comment
'-n 'ASCII:DC3 d:set-stack-comment
'-n 'ASCII:DC4 d:set-stack-comment
'-n 'ASCII:DEL d:set-stack-comment
'-n 'ASCII:DLE d:set-stack-comment
'-n 'ASCII:EM d:set-stack-comment
'-n 'ASCII:ENQ d:set-stack-comment
'-n 'ASCII:EOT d:set-stack-comment
'-n 'ASCII:ESC d:set-stack-comment
'-n 'ASCII:ETB d:set-stack-comment
'-n 'ASCII:ETX d:set-stack-comment
'-n 'ASCII:FF d:set-stack-comment
'-n 'ASCII:FS d:set-stack-comment
'-n 'ASCII:GS d:set-stack-comment
'-n 'ASCII:HT d:set-stack-comment
'-n 'ASCII:LF d:set-stack-comment
'-n 'ASCII:NAK d:set-stack-comment
'-n 'ASCII:NUL d:set-stack-comment
'-n 'ASCII:RS d:set-stack-comment
'-n 'ASCII:SI d:set-stack-comment
'-n 'ASCII:SO d:set-stack-comment
'-n 'ASCII:SOH d:set-stack-comment
'-n 'ASCII:SPACE d:set-stack-comment
'-n 'ASCII:STX d:set-stack-comment
'-n 'ASCII:SUB d:set-stack-comment
'-n 'ASCII:SYN d:set-stack-comment
'-n 'ASCII:US d:set-stack-comment
'-n 'ASCII:VT d:set-stack-comment
'-n 'BUILD d:set-stack-comment
'-a 'Base d:set-stack-comment
'-a 'Compiler d:set-stack-comment
'-a 'Dictionary d:set-stack-comment
'- 'END d:set-stack-comment
'-a 'EOM d:set-stack-comment
'-n 'FALSE d:set-stack-comment
'-n 'FREE d:set-stack-comment
'-s 'HOME d:set-stack-comment
'-a 'Heap d:set-stack-comment
'-n 'I d:set-stack-comment
'-a 'Ignoring d:set-stack-comment
'-n 'J d:set-stack-comment
'-n 'K d:set-stack-comment
'-a 'RewriteUnderscores d:set-stack-comment
'-a 'STRINGS d:set-stack-comment
'-a 'ScopeList d:set-stack-comment
'-a 'TIB d:set-stack-comment
'-n 'TRUE d:set-stack-comment
'-a 'TempStringMax d:set-stack-comment
'-a 'TempStrings d:set-stack-comment
'-a 'Version d:set-stack-comment
'- '[ d:set-stack-comment
'- '] d:set-stack-comment
'aa-f 'a:-eq? d:set-stack-comment
'aa-a 'a:append d:set-stack-comment
'aa-f 'a:begins-with? d:set-stack-comment
'a-a 'a:chop d:set-stack-comment
'sa-f 'a:contains/string? d:set-stack-comment
'na-f 'a:contains? d:set-stack-comment
'aa- 'a:copy d:set-stack-comment
'q-a 'a:counted-results d:set-stack-comment
'a-b 'a:dup d:set-stack-comment
'aa-f 'a:ends-with? d:set-stack-comment
'aa-f 'a:eq? d:set-stack-comment
'an-n 'a:fetch d:set-stack-comment
'aq-b 'a:filter d:set-stack-comment
'a-n 'a:first d:set-stack-comment
'aq- 'a:for-each d:set-stack-comment
's-a 'a:from-string d:set-stack-comment
'a-n 'a:hash d:set-stack-comment
'an-n 'a:index d:set-stack-comment
'as-n 'a:index/string d:set-stack-comment
'av-a 'a:indices d:set-stack-comment
'as-a 'a:indices/string d:set-stack-comment
'a-n 'a:last d:set-stack-comment
'an-a 'a:left d:set-stack-comment
'a-n 'a:length d:set-stack-comment
'q-a 'a:make d:set-stack-comment
'aq-b 'a:map d:set-stack-comment
'afl-a 'a:middle d:set-stack-comment
'aa-a 'a:prepend d:set-stack-comment
'pnq-n 'a:reduce d:set-stack-comment
'a-b 'a:reverse d:set-stack-comment
'an-a 'a:right d:set-stack-comment
'van- 'a:store d:set-stack-comment
'a-a 'a:temp d:set-stack-comment
'an-b 'a:th d:set-stack-comment
'a-s 'a:to-string d:set-stack-comment
'- 'abort d:set-stack-comment
'- 'again d:set-stack-comment
'n- 'allot d:set-stack-comment
'nm-o 'and d:set-stack-comment
'a-n 'b:fetch d:set-stack-comment
'a-an 'b:fetch-next d:set-stack-comment
'na- 'b:store d:set-stack-comment
'na-a 'b:store-next d:set-stack-comment
'a-a 'b:to-byte-address d:set-stack-comment
'- 'banner d:set-stack-comment
'xqq-? 'bi d:set-stack-comment
'xyqq-? 'bi* d:set-stack-comment
'xyq-? 'bi@ d:set-stack-comment
'- 'binary d:set-stack-comment
'n- 'buffer:add d:set-stack-comment
'- 'buffer:empty d:set-stack-comment
'-a 'buffer:end d:set-stack-comment
'-n 'buffer:get d:set-stack-comment
'q- 'buffer:preserve d:set-stack-comment
'a- 'buffer:set d:set-stack-comment
'-n 'buffer:size d:set-stack-comment
'-a 'buffer:start d:set-stack-comment
'- 'bye d:set-stack-comment
'c-f 'c:-consonant? d:set-stack-comment
'c-f 'c:-digit? d:set-stack-comment
'c-f 'c:-lowercase? d:set-stack-comment
'c-f 'c:-uppercase? d:set-stack-comment
'c-f 'c:-visible? d:set-stack-comment
'c-f 'c:-vowel? d:set-stack-comment
'c-f 'c:-whitespace? d:set-stack-comment
'c-f 'c:consonant? d:set-stack-comment
'c-f 'c:digit? d:set-stack-comment
'-c 'c:get d:set-stack-comment
'c-f 'c:letter? d:set-stack-comment
'c-f 'c:lowercase? d:set-stack-comment
'c- 'c:put d:set-stack-comment
'c-c 'c:to-lower d:set-stack-comment
'c-n 'c:to-number d:set-stack-comment
'c-s 'c:to-string d:set-stack-comment
'c-c 'c:to-upper d:set-stack-comment
'c-c 'c:toggle-case d:set-stack-comment
'c-f 'c:uppercase? d:set-stack-comment
'c-f 'c:visible? d:set-stack-comment
'c-f 'c:vowel? d:set-stack-comment
'c-f 'c:whitespace? d:set-stack-comment
'a- 'call d:set-stack-comment
'a-a 'car d:set-stack-comment
'na- 'car! d:set-stack-comment
'a-n 'car@ d:set-stack-comment
'nmq-_||_nmq-n 'case d:set-stack-comment
'a-a 'cdr d:set-stack-comment
'na- 'cdr! d:set-stack-comment
'a-n 'cdr@ d:set-stack-comment
'fqq- 'choose d:set-stack-comment
'n-_||_n-n 'class:data d:set-stack-comment
'a- 'class:macro d:set-stack-comment
'a- 'class:primitive d:set-stack-comment
'a- 'class:word d:set-stack-comment
'- 'clear d:set-stack-comment
'n- 'comma d:set-stack-comment
'a- 'compile:call d:set-stack-comment
'a- 'compile:jump d:set-stack-comment
'n- 'compile:lit d:set-stack-comment
'- 'compile:ret d:set-stack-comment
'-f 'compiling? d:set-stack-comment
'xy-a 'cons d:set-stack-comment
'ns- 'const d:set-stack-comment
'sdl- 'copy d:set-stack-comment
'nq-q 'curry d:set-stack-comment
'n- 'd d:set-stack-comment
'- 'd:Hash-Function d:set-stack-comment
'saa- 'd:add-header d:set-stack-comment
'd-a 'd:class d:set-stack-comment
's- 'd:create d:set-stack-comment
'q- 'd:for-each d:set-stack-comment
'd-a 'd:hash d:set-stack-comment
'-d 'd:last d:set-stack-comment
'-a 'd:last.class d:set-stack-comment
'-s 'd:last.name d:set-stack-comment
'-a 'd:last.xt d:set-stack-comment
'd-a 'd:link d:set-stack-comment
's-d 'd:lookup d:set-stack-comment
'a-d 'd:lookup-xt d:set-stack-comment
'd-s 'd:name d:set-stack-comment
'- 'd:rehash d:set-stack-comment
'ss- 'd:set-source d:set-stack-comment
'd-a 'd:source d:set-stack-comment
'- 'd:use-hashes d:set-stack-comment
'- 'd:use-strings d:set-stack-comment
'- 'd:words d:set-stack-comment
's- 'd:words-beginning-with d:set-stack-comment
's- 'd:words-with d:set-stack-comment
'd-a 'd:xt d:set-stack-comment
'- 'data d:set-stack-comment
'- 'decimal d:set-stack-comment
'-n 'depth d:set-stack-comment
'nq-n 'dip d:set-stack-comment
'q- 'does d:set-stack-comment
'n- 'drop d:set-stack-comment
'nn- 'drop-pair d:set-stack-comment
'- 'dump-stack d:set-stack-comment
'n-nn 'dup d:set-stack-comment
'nm-nmnm 'dup-pair d:set-stack-comment
'- 'err:notfound d:set-stack-comment
'nn-f 'eq? d:set-stack-comment
'a-n 'fetch d:set-stack-comment
'a-an 'fetch-next d:set-stack-comment
'vpn- 'fill d:set-stack-comment
'pv- 'fll:append/value d:set-stack-comment
'v-p 'fll:create d:set-stack-comment
'pn- 'fll:del d:set-stack-comment
'p- 'fll:drop d:set-stack-comment
'pq- 'fll:for-each d:set-stack-comment
'pnv- 'fll:inject d:set-stack-comment
'p-n 'fll:length d:set-stack-comment
'p- 'fll:put d:set-stack-comment
'p-p 'fll:to-end d:set-stack-comment
'pn-p 'fll:to-index d:set-stack-comment
'q- 'forever d:set-stack-comment
'a- 'gc d:set-stack-comment
'nn-f 'gt? d:set-stack-comment
'nn-f 'gteq? d:set-stack-comment
'a-n 'h:fetch d:set-stack-comment
'a-an 'h:fetch-next d:set-stack-comment
'na- 'h:store d:set-stack-comment
'na-a 'h:store-next d:set-stack-comment
'-a 'here d:set-stack-comment
'- 'hex d:set-stack-comment
'- 'hook d:set-stack-comment
's- 'i d:set-stack-comment
'fq- 'if d:set-stack-comment
'fq- 'if; d:set-stack-comment
's- 'image:save d:set-stack-comment
'- 'immediate d:set-stack-comment
's- 'include d:set-stack-comment
'nq- 'indexed-times d:set-stack-comment
's- 'interpret d:set-stack-comment
'...n- 'io:core d:set-stack-comment
'-n 'io:enumerate d:set-stack-comment
'n- 'io:invoke d:set-stack-comment
'n-mN 'io:query d:set-stack-comment
'n-m 'io:scan-for d:set-stack-comment
'- 'listen d:set-stack-comment
'nn-f 'lt? d:set-stack-comment
'nn-f 'lteq? d:set-stack-comment
'nm-o 'mod d:set-stack-comment
'n-f 'n:-zero? d:set-stack-comment
'-n 'n:MAX d:set-stack-comment
'-n 'n:MIN d:set-stack-comment
'n-n 'n:abs d:set-stack-comment
'nn-n 'n:add d:set-stack-comment
'nlu-f 'n:between? d:set-stack-comment
'n-m 'n:dec d:set-stack-comment
'nm-v 'n:div d:set-stack-comment
'nm-rv 'n:divmod d:set-stack-comment
'n-f 'n:even? d:set-stack-comment
'n-m 'n:inc d:set-stack-comment
'nlu-m 'n:limit d:set-stack-comment
'mn-o 'n:max d:set-stack-comment
'mn-o 'n:min d:set-stack-comment
'nm-o 'n:mod d:set-stack-comment
'nn-n 'n:mul d:set-stack-comment
'n-n 'n:negate d:set-stack-comment
'n-f 'n:negative? d:set-stack-comment
'n-f 'n:odd? d:set-stack-comment
'n-f 'n:positive? d:set-stack-comment
'bp-n 'n:pow d:set-stack-comment
'n- 'n:put d:set-stack-comment
'-n 'n:random d:set-stack-comment
'n-m 'n:sqrt d:set-stack-comment
'n-m 'n:square d:set-stack-comment
'n-f 'n:strictly-positive? d:set-stack-comment
'nn-n 'n:sub d:set-stack-comment
'n- 'n:to-float d:set-stack-comment
'n-s 'n:to-string d:set-stack-comment
'n-f 'n:zero? d:set-stack-comment
'nm-m 'nip d:set-stack-comment
'- 'nl d:set-stack-comment
'n-m 'not d:set-stack-comment
'- 'octal d:set-stack-comment
'mn-o 'or d:set-stack-comment
'nm-nmn 'over d:set-stack-comment
'nnnn-n 'pack d:set-stack-comment
'q-s 'parse-until d:set-stack-comment
'-n 'pop d:set-stack-comment
'- 'primitive d:set-stack-comment
'n- 'push d:set-stack-comment
's- 'r d:set-stack-comment
'a- 'reclass d:set-stack-comment
'...ss-? 'reorder d:set-stack-comment
'- 'repeat d:set-stack-comment
'...- 'reset d:set-stack-comment
'abc-bca 'rot d:set-stack-comment
's- 's, d:set-stack-comment
'-s 's:ASCII-LETTERS d:set-stack-comment
'-s 's:ASCII-LOWERCASE d:set-stack-comment
'-s 's:ASCII-UPPERCASE d:set-stack-comment
'-s 's:DIGITS d:set-stack-comment
'-s 's:PUNCTUATION d:set-stack-comment
'-s 's:WHITESPACE d:set-stack-comment
'ss-s 's:append d:set-stack-comment
'ss-f 's:begins-with? d:set-stack-comment
'sSq-_||_sSq-s 's:case d:set-stack-comment
's-s 's:chop d:set-stack-comment
'ss- 's:const d:set-stack-comment
'sc-f 's:contains/char? d:set-stack-comment
'ss-f 's:contains/string? d:set-stack-comment
'sa- 's:copy d:set-stack-comment
's-s 's:dedup d:set-stack-comment
'-a 's:dedup.data d:set-stack-comment
's-f 's:dedup.defined? d:set-stack-comment
's-s 's:dedup.find d:set-stack-comment
's- 's:dedup.register d:set-stack-comment
'-s 's:empty d:set-stack-comment
'ss-f 's:ends-with? d:set-stack-comment
'ss-f 's:eq? d:set-stack-comment
's-? 's:evaluate d:set-stack-comment
'sn-n 's:fetch d:set-stack-comment
'sq-s 's:filter d:set-stack-comment
'sq- 's:for-each d:set-stack-comment
'...s-s 's:format d:set-stack-comment
'-s 's:get d:set-stack-comment
'-s 's:get-word d:set-stack-comment
's-n 's:hash d:set-stack-comment
'sc-n 's:index/char d:set-stack-comment
'ss-n 's:index/string d:set-stack-comment
's-s 's:keep d:set-stack-comment
'sn-s 's:left d:set-stack-comment
's-n 's:length d:set-stack-comment
'sq-s 's:map d:set-stack-comment
'ss-s 's:prepend d:set-stack-comment
's- 's:put d:set-stack-comment
'sss-s 's:replace d:set-stack-comment
'sss-s 's:replace-all d:set-stack-comment
's-s 's:reverse d:set-stack-comment
'sn-s 's:right d:set-stack-comment
'- 's:skip d:set-stack-comment
'sc-ss 's:split/char d:set-stack-comment
'ss-ss 's:split/string d:set-stack-comment
'csn- 's:store d:set-stack-comment
'sfl-s 's:substr d:set-stack-comment
's-s 's:temp d:set-stack-comment
's- 's:to-float d:set-stack-comment
's-s 's:to-lower d:set-stack-comment
's-n 's:to-number d:set-stack-comment
's-s 's:to-upper d:set-stack-comment
'sc-a 's:tokenize d:set-stack-comment
'ss-a 's:tokenize-on-string d:set-stack-comment
's-s 's:trim d:set-stack-comment
's-s 's:trim-left d:set-stack-comment
's-s 's:trim-right d:set-stack-comment
's-f 's:unique? d:set-stack-comment
'aa- 'set-hook d:set-stack-comment
'mn-o 'shift d:set-stack-comment
'ns- 'sigil:! d:set-stack-comment
's-n 'sigil:# d:set-stack-comment
's-c 'sigil:$ d:set-stack-comment
's-a 'sigil:& d:set-stack-comment
's-s 'sigil:' d:set-stack-comment
's- 'sigil:( d:set-stack-comment
's- 'sigil:. d:set-stack-comment
's- 'sigil:: d:set-stack-comment
's-n 'sigil:@ d:set-stack-comment
's- 'sigil:\ d:set-stack-comment
's- 'sigil:^ d:set-stack-comment
's- 'sigil:` d:set-stack-comment
's- 'sigil:| d:set-stack-comment
'nq(?n-?)-n 'sip d:set-stack-comment
'- 'sp d:set-stack-comment
'na- 'store d:set-stack-comment
'na-a 'store-next d:set-stack-comment
'nm-mn 'swap d:set-stack-comment
'- 'tab d:set-stack-comment
'- 'tail-recurse d:set-stack-comment
'nq- 'times d:set-stack-comment
'xqqq-? 'tri d:set-stack-comment
'xyzqqq-? 'tri* d:set-stack-comment
'xyzq-? 'tri@ d:set-stack-comment
'nm-mnm 'tuck d:set-stack-comment
'a- 'unhook d:set-stack-comment
'n-nnnn 'unpack d:set-stack-comment
'q(-f)- 'until d:set-stack-comment
'a- 'v:dec d:set-stack-comment
'na- 'v:dec-by d:set-stack-comment
'a- 'v:inc d:set-stack-comment
'na- 'v:inc-by d:set-stack-comment
'alu- 'v:limit d:set-stack-comment
'a- 'v:off d:set-stack-comment
'a- 'v:on d:set-stack-comment
'aq- 'v:preserve d:set-stack-comment
'aq- 'v:update d:set-stack-comment
's- 'var d:set-stack-comment
'ns- 'var-n d:set-stack-comment
'ss- 'var-s d:set-stack-comment
'a-n 'w:fetch d:set-stack-comment
'a-an 'w:fetch-next d:set-stack-comment
'na- 'w:store d:set-stack-comment
'na-a 'w:store-next d:set-stack-comment
'q(-f)- 'while d:set-stack-comment
'mn-o 'xor d:set-stack-comment
'- '{ d:set-stack-comment
'- '{{ d:set-stack-comment
'-a '} d:set-stack-comment
'- '}} d:set-stack-comment
~~~