Annotation of gforth/interpretation.fs, revision 1.2
1.1 anton 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
1.2 ! anton 23: \ semantics and the interpretation semantics of several words.
! 24:
! 25: require search-order.fs
1.1 anton 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 ;
1.2 ! anton 37: ' interpret-special >body !
1.1 anton 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 : reveal
48: r> set-current ;
1.2 ! anton 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:
1.1 anton 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>