File:
[gforth] /
gforth /
Attic /
interpretation.fs
Revision
1.3:
download - view:
text,
annotated -
select for diffs
Mon May 13 16:36:59 1996 UTC (27 years, 11 months ago) by
anton
Branches:
MAIN
CVS tags:
HEAD
eliminated state-smartness in ;code and sfnumber
immediate-flag is now $40 and restrict-flag $20
HEADER now stores the compilation wordlist in the header and
REVEAL reveals into that wordlist
assorted cleanups
1: \ Interpretation semantics
2:
3: \ Copyright (C) 1996 Free Software Foundation, Inc.
4:
5: \ This file is part of Gforth.
6:
7: \ Gforth is free software; you can redistribute it and/or
8: \ modify it under the terms of the GNU General Public License
9: \ as published by the Free Software Foundation; either version 2
10: \ of the License, or (at your option) any later version.
11:
12: \ This program is distributed in the hope that it will be useful,
13: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
14: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: \ GNU General Public License for more details.
16:
17: \ You should have received a copy of the GNU General Public License
18: \ along with this program; if not, write to the Free Software
19: \ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20:
21:
22: \ This file defines a mechanism for specifying special interpretation
23: \ semantics and the interpretation semantics of several words.
24:
25: require search-order.fs
26:
27: table constant interpretation-semantics
28:
29: :noname ( c-addr u word-ident -- )
30: \ word-ident is currently an xt, but it might be the nfa
31: sp@ cell interpretation-semantics search-wordlist
32: if ( c-addr u word-ident xt )
33: nip nip nip execute
34: else
35: defers interpret-special
36: endif ;
37: ' interpret-special >body !
38:
39: : interpretation: ( -- colon-sys ) \ gforth
40: \G make the last word one with special interpretation semantics and
41: \G start the (colon) definition of these semantics.
42: \ !! fix reveal such that it is not necessary to do it before the
43: \ set-current
44: restrict
45: lastcfa cell nextname \ !! use nfa instead of cfa
46: get-current >r
47: interpretation-semantics set-current :
48: r> set-current ;
49:
50: \ !! split notfound and sfnumber in a compiler and an interpreter part?
51:
52: \ ' [']
53:
54: \ !! or keep it state-smart?
55: ' [char] Alias Ascii immediate
56: interpretation: ( "char" -- c )
57: \ currently also the interpretation semantics of [char]
58: char ;
59:
60: \ [I]
61:
62: \ the following interpretation semantics definitions restrict the
63: \ preceeding word. However, this does not matter because these
64: \ restricted words are in interpretation-semantics and are never
65: \ interpreted like regular words.
66:
67: \ we cannot use s" interpretively yet (to make a string for (sfind), so:
68: ' S" lastcfa !
69: interpretation: ( "ccc<">" -- c-addr u )
70: [char] " parse
71: /line min >r s"-buffer r@ cmove
72: s"-buffer r> ;
73:
74: ' ." lastcfa !
75: interpretation: ( "ccc<">" -- )
76: [char] " parse type ;
77:
78: ' does> lastcfa !
79: interpretation: ( -- colon-sys ) ( name execution: -- addr )
80: align dodoes, here !does ]
81: defstart :-hook ;
82:
83: ' is lastcfa !
84: interpretation: ( addr "name" -- )
85: ' >body ! ;
86:
87: ' what's lastcfa !
88: interpretation: ( "name" -- addr )
89: ' >body @ ;
90:
91:
92: \ : foo
93: \ ." compilation semantics" ; immediate
94: \ interpretation:
95: \ ." interpretation semantics" ;
96:
97: \ foo \ interpretation semantics ok
98: \ : xxx foo ; \ compilation semantics ok
99: \ : yyy postpone foo ; \ ok
100: \ yyy \ compilation semantics ok
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>