18a060afc5166f9fe7739927819cfd9aeef3b67d
[debian/pforth] / fth / require.fth
1 \ REQUIRE and REQUIRED
2 \
3 \ This code is part of pForth.
4 \
5 \ The pForth software code is dedicated to the public domain,
6 \ and any third party may reproduce, distribute and modify
7 \ the pForth software code or any derivative works thereof
8 \ without any compensation or license.  The pForth software
9 \ code is provided on an "as is" basis without any warranty
10 \ of any kind, including, without limitation, the implied
11 \ warranties of merchantability and fitness for a particular
12 \ purpose and their equivalents under the laws of any jurisdiction.
13
14 private{
15
16 \ Has the file with name C-ADDR/U already been included?
17 \
18 \ This searches the "::::<filename>" marker created by INCLUDED.  This
19 \ works for now, but may break if pForth ever receives wordlists.
20 : INCLUDED? ( c-addr u -- flag )
21     s" ::::" here place         ( c-addr u )
22     here $append                ( )
23     here find nip 0<>           ( found? )
24 ;
25
26 \ FIXME: use real PARSE-NAME when available
27 : (PARSE-NAME) ( "word" -- c-addr u ) bl parse-word ;
28
29 }private
30
31 : REQUIRED ( i*x c-addr u -- j*x ) 2dup included? IF 2drop ELSE included THEN ;
32 : REQUIRE ( i*x "name" -- i*x ) (parse-name) required ;
33
34 privatize