File:
[gforth] /
gforth /
extend.fs
Revision
1.3:
download - view:
text,
annotated -
select for diffs
Sat May 7 14:55:48 1994 UTC (28 years, 10 months ago) by
anton
Branches:
MAIN
CVS tags:
HEAD
local variables
rewrote primitives2c.el in Forth (prims2x.el)
various small changes
Added Files:
from-cut-here gforth.el gforth.texi glocals.fs gray.fs
locals-test.fs prims2x.fs
1: \ EXTEND.FS CORE-EXT Word not fully tested! 12may93jaw
2:
3: \ May be cross-compiled
4:
5: decimal
6:
7: \ .( 12may93jaw
8:
9: : .( [char] ) parse type ;
10:
11: \ VALUE 2>R 2R> 2R@ 17may93jaw
12:
13: : value ( n -- )
14: (constant) , ;
15: \ !! 2value
16:
17: : 2>r postpone >r postpone >r ; immediate restrict
18: : 2r> postpone r> postpone r> ; immediate restrict
19: : 2r@ postpone 2r> postpone 2dup postpone 2>r ; immediate restrict
20:
21: : 2Literal swap postpone Literal postpone Literal ;
22: immediate restrict
23:
24: \ CASE OF ENDOF ENDCASE 17may93jaw
25:
26: \ just as described in dpANS5
27:
28: 0 CONSTANT case immediate
29:
30: : of
31: 1+ >r
32: postpone over postpone = postpone if postpone drop
33: r> ; immediate
34:
35: : endof
36: >r postpone else r> ; immediate
37:
38: : endcase
39: postpone drop
40: 0 ?do postpone then loop ; immediate
41:
42: \ C" 17may93jaw
43:
44: : (c") "lit ;
45:
46: : CLiteral postpone (c") here over char+ allot place align ;
47: immediate restrict
48: : C" [char] " parse postpone CLiteral ; immediate restrict
49:
50: \ UNUSED 17may93jaw
51:
52: : unused forthstart dup @ over 2 cells + @ -
53: 512 - \ for stack
54: + here - ;
55:
56: \ [COMPILE] 17may93jaw
57:
58: : [compile]
59: ' compile, ; immediate
60:
61: \ MARKER 17may93jaw
62:
63: \ : marker here last @ create , , DOES> dup @ last ! cell+ @ dp ! ;
64: \ doesn't work now. vocabularies?
65:
66: \ CONVERT 17may93jaw
67:
68: : convert true >number drop ;
69:
70: \ ERASE 17may93jaw
71:
72: : erase ( 0 1 chars um/mod nip ) 0 fill ;
73: : blank ( 0 1 chars um/mod nip ) bl fill ;
74:
75: \ ROLL 17may93jaw
76:
77: : roll dup 1+ pick >r
78: cells sp@ 2 cells + dup cell+ rot move drop r> ;
79:
80: \ SOURCE-ID SAVE-INPUT RESTORE-INPUT 11jun93jaw
81:
82: : source-id ( -- 0 | -1 | fileid )
83: loadfile @ dup 0= IF drop linestart @ THEN ;
84:
85: : save-input ( -- x1 .. xn n )
86: >in @
87: loadfile @ ?dup
88: IF linestart 2@ loadline @ 6
89: ELSE loadline @ blk @ linestart @ 5 THEN
90: >tib @ swap ; \ >tib for security
91:
92: : restore-input ( x1 .. xn n -- flag )
93: 1- swap >tib @ <> IF discard true EXIT THEN
94: 5 = IF loadline ! 2dup linestart 2! rot dup loadfile !
95: reposition-file IF drop true EXIT THEN
96: refill 0= IF drop true EXIT THEN
97: ELSE linestart ! blk !
98: dup loadline @ <> IF 2drop true EXIT THEN
99: loadline !
100: THEN
101: >in ! false ;
102:
103:
104:
105: \ This things we don't need, but for being complete... jaw
106:
107: \ EXPECT SPAN 17may93jaw
108:
109: variable span
110:
111: : expect ( c-addr +len -- )
112: 0 rot over
113: BEGIN key decode >r 2over = r> or UNTIL
114: 2drop nip span ! ;
115:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>