aboutsummaryrefslogtreecommitdiff
path: root/softwords/ficllocal.fr
blob: 9381247edfc4bacd8106dfa22f35edc598e5c25e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
\ ** ficl/softwords/ficllocal.fr
\ ** stack comment style local syntax...
\ {{ a b c -- d e }}
\ variables before the "--" are initialized in reverse order
\ from the stack. Those after the "--" are zero initialized
\ Uses locals...
\ locstate: 0 = looking for -- or }}
\           1 = found --
hide
0 constant zero

: ?--   s" --" compare 0= ;
: ?}}   s" }}" compare 0= ;

set-current

: {{
    0 dup  locals| nLocs locstate |
    begin
        parse-word 
        ?dup 0= abort" Error: out of text without seeing }}"
        2dup 2dup  ?-- -rot ?}} or 0=
    while
        nLocs 1+ to nLocs
    repeat

    ?-- if 1 to locstate endif

    nLocs 0 do
        (local) 
    loop

    locstate 1 = if
        begin
            parse-word
            2dup ?}} 0=
        while
            postpone zero  (local)
        repeat
        2drop
    endif

    0 0 (local)
; immediate compile-only
 
previous