File:  [gforth] / gforth / wordinfo.fs
Revision 1.12: download - view: text, annotated - select for diffs
Wed Aug 21 14:58:45 1996 UTC (25 years, 3 months ago) by anton
Branches: MAIN
CVS tags: HEAD
a little cleanup in 386.h
renamed special: to interpret/compile:
renamed save-string to save-mem
added extend-mem
replaced (name>) with ((name>))
replaced name> with name>int and name>comp
renamed compile-only to compile-only-error
replaced xt>i with name>int
replaced xt>c with name>comp
removed xt>s
removed found
search-wordlist now delivers interpretation-xt
replaced (sfind) with find-name
replaced C' with COMP' and [C'] with [COMP']
removed S' and [S']
added hex.
added some helper words
adapted other words to the changes
started documenting the intergration of Gforth in applications

    1: \ WORDINFO.FS  V1.0                                    17may93jaw
    2: 
    3: \ Copyright (C) 1995 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: \ May be cross-compiled
   22: \ If you want check values then exclude comments,
   23: \ but keep in mind that this can't be cross-compiled
   24: 
   25: INCLUDE look.fs
   26: 
   27: \ Wordinfo is a tool that checks a nfa
   28: \ and finds out what wordtype we have
   29: \ it is used in SEE.FS
   30: 
   31: \ the old alias? did not work and it is not used, so I changed
   32: \ it in many respects - anton
   33: : alias? ( nfa1 -- nfa2|0 )
   34:     \ if nfa1 is an alias, nfa2 is the name of the original word
   35:     dup cell+ c@ alias-mask and 0=
   36:     IF ( nfa1 )
   37: 	((name>)) @ >name ( use look instead? )
   38:     ELSE
   39: 	drop 0
   40:     THEN ;
   41: 
   42: : var?  ( nfa -- flag )
   43:     ((name>)) >code-address dovar: = ;
   44: 
   45: : con?  ( nfa -- flag )
   46:     ((name>)) >code-address docon: = ;
   47: 
   48: : user?  ( nfa -- flag )
   49:     ((name>)) >code-address douser: = ;
   50: 
   51: : does? ( nfa -- flag )
   52:     \ !! does not work on all installations
   53:     ((name>))
   54:     >code-address ['] spaces >code-address = ;
   55: 
   56: : defered? ( nfa -- flag )
   57:     ((name>)) >code-address dodefer: = ;
   58: 
   59: : colon? ( nfa -- flag )
   60:     ((name>)) >code-address docol: = ;
   61: 
   62: \ the above words could be factored with create-does>, but this would
   63: \ probably make this file incompatible with cross.
   64: 
   65: : prim? ( nfa -- flag )
   66:         name>int
   67:         forthstart u< ;
   68: 
   69: \ None nestable IDs:
   70: 
   71: 1 CONSTANT Pri#         \ Primitives
   72: 2 CONSTANT Con#         \ Constants
   73: 3 CONSTANT Var#         \ Variables
   74: 4 CONSTANT Val#         \ Values
   75: 
   76: \ Nestabe IDs:
   77: 
   78: 5 CONSTANT Doe#         \ Does part
   79: 6 CONSTANT Def#         \ Defer
   80: 7 CONSTANT Col#         \ Colon def
   81: 8 CONSTANT Use#         \ User variable
   82: 
   83: \ Nobody knows:
   84: 
   85: 9 CONSTANT Ali#         \ Alias
   86: 
   87: 10 CONSTANT Str#         \ Structure words
   88: 
   89: 11 CONSTANT Com#        \ Compiler directives : ; POSTPONE
   90: 
   91: CREATE InfoTable
   92:         ' Prim?    A, Pri# ,
   93:         ' Alias?   A, Ali# ,
   94:         ' Con?     A, Con# ,
   95:         ' Var?     A, Var# ,
   96: \        ' Value?  A, Val# ,
   97:         ' Defered? A, Def# ,
   98:         ' Does?    A, Doe# ,
   99:         ' Colon?   A, Col# ,
  100: 	' User?    A, Use# ,
  101:         0 ,
  102: 
  103: : WordInfo ( nfa --- code )
  104:         InfoTable
  105:         BEGIN  dup @ dup
  106:         WHILE  swap 2 cells + swap
  107:                2 pick swap execute
  108:         UNTIL
  109:         1 cells - @ nip
  110:         ELSE
  111:         2drop drop 0
  112:         THEN ;
  113: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>