-\ @(#) filefind.fth 98/01/26 1.2\r
-\ FILE? ( <name> -- , report which file this Forth word was defined in )\r
-\\r
-\ FILE? looks for ::::Filename and ;;;; in the dictionary\r
-\ that have been left by INCLUDE. It figures out nested\r
-\ includes and reports each file that defines the word.\r
-\\r
-\ Author: Phil Burk\r
-\ Copyright 1992 Phil Burk\r
-\\r
-\ 00001 PLB 2/21/92 Handle words from kernel or keyboard.\r
-\ Support EACH.FILE?\r
-\ 961213 PLB Port to pForth.\r
-\r
-ANEW TASK-FILEFIND.FTH\r
-\r
-: BE@ { addr | val -- val , fetch from unaligned address in BigEndian order }\r
- 4 0\r
- DO\r
- addr i + c@\r
- val 8 lshift or -> val\r
- LOOP\r
- val\r
-;\r
-\r
-: BE! { val addr -- , store to unaligned address in BigEndian order }\r
- 4 0\r
- DO\r
- val 3 i - 8 * rshift\r
- addr i + c!\r
- LOOP\r
-;\r
-: BEW@ { addr -- , fetch word from unaligned address in BigEndian order }\r
- addr c@ 8 lshift\r
- addr 1+ c@ OR\r
-;\r
-\r
-: BEW! { val addr -- , store word to unaligned address in BigEndian order }\r
- val 8 rshift addr c!\r
- val addr 1+ c!\r
-;\r
-\r
-\ scan dictionary from NFA for filename\r
-: F?.SEARCH.NFA { nfa | dpth stoploop keyb nfa0 -- addr count }\r
- 0 -> dpth\r
- 0 -> stoploop\r
- 0 -> keyb\r
- nfa -> nfa0\r
- BEGIN\r
- nfa prevname -> nfa\r
- nfa 0>\r
- IF\r
- nfa 1+ be@\r
- CASE\r
- $ 3a3a3a3a ( :::: )\r
- OF\r
- dpth 0=\r
- IF\r
- nfa count 31 and\r
- 4 - swap 4 + swap\r
- true -> stoploop\r
- ELSE\r
- -1 dpth + -> dpth\r
- THEN\r
- ENDOF\r
- $ 3b3b3b3b ( ;;;; )\r
- OF\r
- 1 dpth + -> dpth\r
- true -> keyb \ maybe from keyboard\r
- ENDOF\r
- ENDCASE\r
- ELSE\r
- true -> stoploop\r
- keyb\r
- IF\r
- " keyboard"\r
- ELSE\r
- " 'C' kernel"\r
- THEN\r
- count\r
- THEN\r
- stoploop\r
- UNTIL\r
-;\r
-\r
-: FINDNFA.FROM { $name start_nfa -- nfa true | $word false }\r
- context @ >r\r
- start_nfa context !\r
- $name findnfa\r
- r> context !\r
-;\r
-\r
-\ Search entire dictionary for all occurences of named word.\r
-: FILE? { | $word nfa done? -- , take name from input }\r
- 0 -> done?\r
- bl word -> $word\r
- $word findnfa\r
- IF ( -- nfa )\r
- $word count type ." from:" cr\r
- -> nfa\r
- BEGIN\r
- nfa f?.search.nfa ( addr cnt )\r
- nfa name> 12 .r \ print xt\r
- 4 spaces type cr\r
- nfa prevname dup -> nfa\r
- 0>\r
- IF\r
- $word nfa findnfa.from \ search from one behind found nfa\r
- swap -> nfa\r
- not\r
- ELSE\r
- true\r
- THEN\r
- UNTIL\r
- ELSE ( -- $word )\r
- count type ." not found!" cr\r
- THEN\r
-;\r
-\r
+\ @(#) filefind.fth 98/01/26 1.2
+\ FILE? ( <name> -- , report which file this Forth word was defined in )
+\
+\ FILE? looks for ::::Filename and ;;;; in the dictionary
+\ that have been left by INCLUDE. It figures out nested
+\ includes and reports each file that defines the word.
+\
+\ Author: Phil Burk
+\ Copyright 1992 Phil Burk
+\
+\ 00001 PLB 2/21/92 Handle words from kernel or keyboard.
+\ Support EACH.FILE?
+\ 961213 PLB Port to pForth.
+
+ANEW TASK-FILEFIND.FTH
+
+: BE@ { addr | val -- val , fetch from unaligned address in BigEndian order }
+ 4 0
+ DO
+ addr i + c@
+ val 8 lshift or -> val
+ LOOP
+ val
+;
+
+: BE! { val addr -- , store to unaligned address in BigEndian order }
+ 4 0
+ DO
+ val 3 i - 8 * rshift
+ addr i + c!
+ LOOP
+;
+: BEW@ { addr -- , fetch word from unaligned address in BigEndian order }
+ addr c@ 8 lshift
+ addr 1+ c@ OR
+;
+
+: BEW! { val addr -- , store word to unaligned address in BigEndian order }
+ val 8 rshift addr c!
+ val addr 1+ c!
+;
+
+\ scan dictionary from NFA for filename
+: F?.SEARCH.NFA { nfa | dpth stoploop keyb nfa0 -- addr count }
+ 0 -> dpth
+ 0 -> stoploop
+ 0 -> keyb
+ nfa -> nfa0
+ BEGIN
+ nfa prevname -> nfa
+ nfa 0>
+ IF
+ nfa 1+ be@
+ CASE
+ $ 3a3a3a3a ( :::: )
+ OF
+ dpth 0=
+ IF
+ nfa count 31 and
+ 4 - swap 4 + swap
+ true -> stoploop
+ ELSE
+ -1 dpth + -> dpth
+ THEN
+ ENDOF
+ $ 3b3b3b3b ( ;;;; )
+ OF
+ 1 dpth + -> dpth
+ true -> keyb \ maybe from keyboard
+ ENDOF
+ ENDCASE
+ ELSE
+ true -> stoploop
+ keyb
+ IF
+ " keyboard"
+ ELSE
+ " 'C' kernel"
+ THEN
+ count
+ THEN
+ stoploop
+ UNTIL
+;
+
+: FINDNFA.FROM { $name start_nfa -- nfa true | $word false }
+ context @ >r
+ start_nfa context !
+ $name findnfa
+ r> context !
+;
+
+\ Search entire dictionary for all occurences of named word.
+: FILE? { | $word nfa done? -- , take name from input }
+ 0 -> done?
+ bl word -> $word
+ $word findnfa
+ IF ( -- nfa )
+ $word count type ." from:" cr
+ -> nfa
+ BEGIN
+ nfa f?.search.nfa ( addr cnt )
+ nfa name> 12 .r \ print xt
+ 4 spaces type cr
+ nfa prevname dup -> nfa
+ 0>
+ IF
+ $word nfa findnfa.from \ search from one behind found nfa
+ swap -> nfa
+ not
+ ELSE
+ true
+ THEN
+ UNTIL
+ ELSE ( -- $word )
+ count type ." not found!" cr
+ THEN
+;
+