prefix.fr revision 76116
1169695Skan\ ** 2169695Skan\ ** Prefix words for ficl 3169695Skan\ ** submitted by Larry Hastings, larry@hastings.org 4169695Skan\ ** 5169695Skan\ (jws) To make a prefix, simply create a new definition in the <prefixes> 6169695Skan\ wordlist. start-prefixes and end-prefixes handle the bookkeeping 7169695Skan 8169695Skan\ $FreeBSD: head/sys/boot/ficl/softwords/prefix.fr 76116 2001-04-29 02:36:36Z dcs $ 9169695Skan 10169695Skanvariable save-current 11169695Skan 12169695Skan: start-prefixes get-current save-current ! <prefixes> set-current ; 13169695Skan: end-prefixes save-current @ set-current ; 14169695Skan: show-prefixes <prefixes> >search words search> drop ; 15169695Skan 16169695Skan\ #if (FICL_EXTENDED_PREFIX) 17169695Skan 18169695Skanstart-prefixes 19169695Skan 20169695Skan\ define " (double-quote) as an alias for s", and make it a prefix 21169695Skan: " postpone s" ; immediate 22169695Skan 23169695Skan 24169695Skan\ make .( a prefix (we just create an alias for it in the prefixes list) 25169695Skan: .( .( ; 26169695Skan 27169695Skan 28169695Skan\ make \ a prefix, and add // (same thing) as a prefix too 29169695Skan\ (jws) "//" is precompiled to save aggravation with Perl 30169695Skan\ : // postpone \ ; immediate 31169695Skan 32169695Skan 33169695Skan\ ** add 0b, 0o, 0d, and 0x as prefixes 34169695Skan\ ** these temporarily shift the base to 2, 8, 10, and 16 respectively 35169695Skan\ ** and consume the next number in the input stream, pushing/compiling 36169695Skan\ ** as normal 37169695Skan 38169695Skan\ (jws) __tempbase is precompiled, as are 0x and 0d - see prefix.c 39169695Skan\ 40169695Skan\ : __tempbase { newbase | oldbase -- } 41169695Skan\ base @ to oldbase 42169695Skan\ newbase base ! 43169695Skan\ 0 0 parse-word >number 2drop drop 44169695Skan\ oldbase base ! 45169695Skan\ ; 46169695Skan 47169695Skan: 0b 2 __tempbase ; immediate 48169695Skan 49169695Skan: 0o 8 __tempbase ; immediate 50169695Skan 51169695Skan\ : 0d 10 __tempbase ; immediate 52169695Skan\ "0d" add-prefix 53169695Skan 54169695Skan\ : 0x 16 __tempbase ; immediate 55169695Skan\ "0x" add-prefix 56169695Skan 57169695Skanend-prefixes 58169695Skan 59169695Skan\ #endif 60169695Skan