-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxwords_fs
74 lines (56 loc) · 2.2 KB
/
xwords_fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
\ xwords_fs
\ This file is part of Sfera, a library for SuperForth
\ http://programandala.net/en.program.sfera.html
\ Author: Marcos Cruz (programandala.net)
\ ==============================================================
\ License
\ You may do whatever you want with this work, so long as you
\ retain the copyright/authorship/acknowledgment/credit
\ notice(s) and this license in all redistributed copies and
\ derived works. There is no warranty.
\ ==============================================================
\ Description
\ This module provides `xwords`, which print a table containing
\ all header addresses from all words in the current search
\ order. The table is printed is AsciiDoc/Asciidoctor format.
\ ==============================================================
\ History
\ 2016-01-06: Code extracted from <boot.fs>.
\
\ 2016-01-12: Updated: `link>link? 0=` instead of `first-word?`.
\
\ 2016-02-08: Removed `end-of-file`.
\ ==============================================================
: | ( -- ) ." | " ;
: table ( -- ) cr ." |===" ;
: .xheader-field ( n -- ) | 16hex. ;
: .xtype ( cfa -- )
dup @ over >body = if drop ." CODE (at PFA) " exit then
dup @ h# 87C6 = if drop ." : " exit then
dup @ h# 87AA = if drop ." USER " exit then
dup @ h# 879A = if drop ." CREATE " exit then
dup @ h# 96D0 = if drop ." 2CONSTANT " exit then
dup @ h# 877C = if drop ." CONSTANT " exit then
@ h# 9542 = if ." EXVECT: " exit then
." CODE (not at PFA) " ;
: .xheader ( lfa -- )
cr dup .xheader-field dup link> >r
r@ >name .xheader-field
r@ .xheader-field
r@ @ .xheader-field
r@ >body .xheader-field
r> | .xtype
| id. ;
: xwords ( -- )
table
cr ." | LFA | NFA | CFA | Code | PFA | Type | Name" cr
latest ( lfa )
begin
dup .xheader space-paused
link>link? 0= escape-key? or
until drop table ;
\ Print the words table to the current output channel.
: xwords>printer ( -- )
printer_on xwords printer_off ;
\ Print the words table to the printer.
\ vim: filetype=superforthsfera