xref: /illumos-gate/usr/src/common/ficl/softcore/prefix.fr (revision d48be21240dfd051b689384ce2b23479d757f2d8)
1\ **
2\ ** Prefix words for ficl
3\ ** submitted by Larry Hastings, larry@hastings.org
4\ **
5\ (jws) To make a prefix, simply create a new definition in the <prefixes>
6\ wordlist. start-prefixes and end-prefixes handle the bookkeeping
7
8variable save-current
9
10: start-prefixes   get-current save-current ! <prefixes> set-current ;
11: end-prefixes     save-current @ set-current ;
12: show-prefixes    <prefixes> >search  words  search> drop ;
13
14start-prefixes
15
16S" FICL_WANT_EXTENDED_PREFIX" ENVIRONMENT? drop [if]
17
18\ define " (double-quote) as an alias for s", and make it a prefix
19: " postpone s" ; immediate
20
21
22\ make .( a prefix (we just create an alias for it in the prefixes list)
23: .( postpone .( ; immediate
24
25
26\ make \ a prefix, and add // (same thing) as a prefix too
27: \ postpone \ ; immediate
28: // postpone \ ; immediate
29
30
31\ ** add 0b, 0o, 0d, 0x and $ as prefixes
32\ ** these temporarily shift the base to 2, 8, 10, and 16 respectively
33\ ** and consume the next number in the input stream, pushing/compiling
34\ ** as normal
35\ **
36\ ** __tempbase is precompiled, see prefix.c
37
38: 0b  2 __tempbase ; immediate
39: 0o  8 __tempbase ; immediate
40
41[endif]
42
43: 0d 10 __tempbase ; immediate
44: 0x 16 __tempbase ; immediate
45: $ 16 __tempbase ; immediate
46
47end-prefixes
48