aboutsummaryrefslogtreecommitdiff
path: root/docs/j1demo/firmware/ans.fs
blob: dcd29ed4b8598d6d192fc8e1b976fbe1f311b67e (plain)
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
( Main file for pure ANS forth               JCB 13:53 11/27/10)

: parse-word
    bl word count ;

: defer create                    ( "name" -- )
    ['] abort ,  does> @ execute ;

: include                         ( "filename" -- )
    bl word count included  decimal ;

: is                              ( xt "name" -- )
    '                               ( xt xt2)
    state @ if
        postpone literal  postpone >body  postpone !
    else
        >body !
    then ; immediate


: include                         ( "filename" -- )
    bl parse included  decimal ;

    : Do-Vocabulary                   ( -- )
        DOES>  @ >R                     ( )( R: widnew)
            GET-ORDER  SWAP DROP        ( wid_n ... wid_2 n)
        R> SWAP SET-ORDER ;

: VOCABULARY                      ( "name" -- )
    WORDLIST CREATE ,  Do-Vocabulary ;

: -rot      rot rot ;
: nstime     0. ;
: <=        > invert ;
: >=        < invert ;
: d0<>      d0= invert ;

: f>        fswap f< ;
: f<=       f> invert ;
: f>=       f< invert ;
: f=        0e0 f~ ;
: f<>       f= invert ;

3.1415926e0 fconstant pi

include main.fs