/fth/require.fth

https://github.com/philburk/pforth · Forth · 37 lines · 31 code · 6 blank · 0 comment · 3 complexity · 01d1c2cc2c178243041a4d20fb510cda MD5 · raw file

  1. \ REQUIRE and REQUIRED
  2. \
  3. \ This code is part of pForth.
  4. \
  5. \ Permission to use, copy, modify, and/or distribute this
  6. \ software for any purpose with or without fee is hereby granted.
  7. \
  8. \ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  9. \ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  10. \ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  11. \ THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
  12. \ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
  13. \ FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  14. \ CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. \ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. private{
  17. \ Has the file with name C-ADDR/U already been included?
  18. \
  19. \ This searches the "::::<filename>" marker created by INCLUDED. This
  20. \ works for now, but may break if pForth ever receives wordlists.
  21. : INCLUDED? ( c-addr u -- flag )
  22. s" ::::" here place ( c-addr u )
  23. here $append ( )
  24. here find nip 0<> ( found? )
  25. ;
  26. \ FIXME: use real PARSE-NAME when available
  27. : (PARSE-NAME) ( "word" -- c-addr u ) bl parse-word ;
  28. }private
  29. : REQUIRED ( i*x c-addr u -- j*x ) 2dup included? IF 2drop ELSE included THEN ;
  30. : REQUIRE ( i*x "name" -- i*x ) (parse-name) required ;
  31. privatize