PageRenderTime 22ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/fth/wordslik.fth

https://github.com/cataska/pforth
Forth | 44 lines | 40 code | 4 blank | 0 comment | 1 complexity | faae54294413f6072892e855ad7d5970 MD5 | raw file
  1. \ @(#) wordslik.fth 98/01/26 1.2
  2. \
  3. \ WORDS.LIKE ( <string> -- , search for words that contain string )
  4. \
  5. \ Enter: WORDS.LIKE +
  6. \ Enter: WORDS.LIKE EMIT
  7. \
  8. \ Author: Phil Burk
  9. \ Copyright 1994 3DO, Phil Burk, Larry Polansky, Devid Rosenboom
  10. \
  11. \ The pForth software code is dedicated to the public domain,
  12. \ and any third party may reproduce, distribute and modify
  13. \ the pForth software code or any derivative works thereof
  14. \ without any compensation or license. The pForth software
  15. \ code is provided on an "as is" basis without any warranty
  16. \ of any kind, including, without limitation, the implied
  17. \ warranties of merchantability and fitness for a particular
  18. \ purpose and their equivalents under the laws of any jurisdiction.
  19. anew task-wordslik.fth
  20. decimal
  21. : PARTIAL.MATCH.NAME ( $str1 nfa -- flag , is $str1 in nfa ??? )
  22. count $ 1F and
  23. rot count
  24. search
  25. >r 2drop r>
  26. ;
  27. : WORDS.LIKE ( <name> -- , print all words containing substring )
  28. BL word latest
  29. >newline
  30. BEGIN
  31. prevname dup 0<> \ get previous name in dictionary
  32. WHILE
  33. 2dup partial.match.name
  34. IF
  35. dup id. tab
  36. cr?
  37. THEN
  38. REPEAT 2drop
  39. >newline
  40. ;