PageRenderTime 60ms CodeModel.GetById 37ms RepoModel.GetById 0ms app.codeStats 0ms

/usr/src/common/ficl/test/vocab.fr

https://github.com/illumos/illumos-gate
Forth | 32 lines | 22 code | 10 blank | 0 comment | 0 complexity | ec6893bf0ecfc030139028917b8e82b1 MD5 | raw file
  1. \ Here is an implementation of ALSO/ONLY in terms of the
  2. \ primitive search-order word set.
  3. \
  4. WORDLIST CONSTANT ROOT ROOT SET-CURRENT
  5. : DO-VOCABULARY ( -- ) \ Implementation factor
  6. DOES> @ >R ( ) ( R: widnew )
  7. GET-ORDER SWAP DROP ( wid1 ... widn-1 n )
  8. R> SWAP SET-ORDER
  9. ;
  10. : DISCARD ( x1 .. xu u - ) \ Implementation factor
  11. 0 ?DO DROP LOOP \ DROP u+1 stack items
  12. ;
  13. CREATE FORTH FORTH-WORDLIST , DO-VOCABULARY
  14. : VOCABULARY ( name -- ) WORDLIST CREATE , DO-VOCABULARY ;
  15. : ALSO ( -- ) GET-ORDER OVER SWAP 1+ SET-ORDER ;
  16. : PREVIOUS ( -- ) GET-ORDER SWAP DROP 1- SET-ORDER ;
  17. : DEFINITIONS ( -- ) GET-ORDER OVER SET-CURRENT DISCARD ;
  18. : ONLY ( -- ) ROOT ROOT 2 SET-ORDER ;
  19. \ Forth-83 version; just removes ONLY
  20. : SEAL ( -- ) GET-ORDER 1- SET-ORDER DROP ;
  21. \ F83 and F-PC version; leaves only CONTEXT
  22. : SEAL ( -- ) GET-ORDER OVER 1 SET-ORDER DISCARD ;