Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / boot / ficl / softwords / ficllocal.fr
1 \ ** ficl/softwords/ficllocal.fr
2 \ ** stack comment style local syntax...
3 \ {{ a b c -- d e }}
4 \ variables before the "--" are initialized in reverse order
5 \ from the stack. Those after the "--" are zero initialized
6 \ Uses locals...
7 \ locstate: 0 = looking for -- or }}
8 \           1 = found --
9 \
10 \ $FreeBSD: src/sys/boot/ficl/softwords/ficllocal.fr,v 1.1 1999/09/29 04:43:15 dcs Exp $
11
12 hide
13 0 constant zero
14
15 : ?--   s" --" compare 0= ;
16 : ?}}   s" }}" compare 0= ;
17
18 set-current
19
20 : {{
21     0 dup  locals| nLocs locstate |
22     begin
23         parse-word 
24         ?dup 0= abort" Error: out of text without seeing }}"
25         2dup 2dup  ?-- -rot ?}} or 0=
26     while
27         nLocs 1+ to nLocs
28     repeat
29
30     ?-- if 1 to locstate endif
31
32     nLocs 0 do
33         (local) 
34     loop
35
36     locstate 1 = if
37         begin
38             parse-word
39             2dup ?}} 0=
40         while
41             postpone zero  (local)
42         repeat
43         2drop
44     endif
45
46     0 0 (local)
47 ; immediate compile-only
48  
49 previous