Main Page | Data Structures | File List | Data Fields | Globals

dictionary.c

Go to the documentation of this file.
00001 /*
00002  *                     OpenBIOS - free your system!
00003  *                         ( FCode tokenizer )
00004  *
00005  *  dictionary.c - dictionary initialization and functions.
00006  *
00007  *  This program is part of a free implementation of the IEEE 1275-1994
00008  *  Standard for Boot (Initialization Configuration) Firmware.
00009  *
00010  *  Copyright (C) 2001-2005 Stefan Reinauer, <stepan@openbios.org>
00011  *
00012  *  This program is free software; you can redistribute it and/or modify
00013  *  it under the terms of the GNU General Public License as published by
00014  *  the Free Software Foundation; version 2 of the License.
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU General Public License for more details.
00020  *
00021  *  You should have received a copy of the GNU General Public License
00022  *  along with this program; if not, write to the Free Software
00023  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
00024  *
00025  */
00026 
00027 /* **************************************************************************
00028  *         Modifications made in 2005 by IBM Corporation
00029  *      (C) Copyright 2005 IBM Corporation.  All Rights Reserved.
00030  *      Modifications Author:  David L. Paktor    dlpaktor@us.ibm.com
00031  **************************************************************************** */
00032 
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035 #if defined(__linux__) && ! defined(__USE_BSD)
00036 #define __USE_BSD
00037 #endif
00038 #include <string.h>
00039 #include <errno.h>
00040 
00041 #include "emit.h"
00042 #include "macros.h"
00043 #include "scanner.h"
00044 #include "ticvocab.h"
00045 #include "dictionary.h"
00046 #include "vocabfuncts.h"
00047 #include "devnode.h"
00048 #include "clflags.h"
00049 #include "parselocals.h"
00050 #include "errhandler.h"
00051 #include "tokzesc.h"
00052 #include "conditl.h"
00053 
00054 /* **************************************************************************
00055  *
00056  *      Revision History:
00057  *          Updated Fri, 29 Jul 2005 by David L. Paktor
00058  *          Retrofit to handle "Current Device" as a separate vocabulary;
00059  *              if one is in effect, searches through it occur first, as
00060  *              do definitions to it, ahead of the general vocabulary.  This
00061  *              is to support managing device-node vocabularies correctly.
00062  *          Updated Mon, 12 Dec 2005 by David L. Paktor
00063  *          Allow the user to specify a group of exceptions, words whose
00064  *              scope will be "global" within the tokenization.  Under "global"
00065  *              scope, definitions will be made to the "core" vocabulary.
00066  *
00067  *          Wed, 14 Dec 2005 by David L. Paktor
00068  *          Found a problem with the current approach.  Need to be able to
00069  *              temporarily suspend meaning of "instance".  Define:  (1) an
00070  *              alias for  INSTANCE  called  GENERIC_INSTANCE  (2) a macro
00071  *              called  INSTANCE  that effectively no-ops it out; and, when
00072  *              it is time to restore "INSTANCE" to normal functionality,
00073  *              (3) an alias for  GENERIC_INSTANCE  called  INSTANCE .
00074  *          Problem is that macros are treated as a separate vocabulary
00075  *              from FWords (and their aliases) and searching one before the
00076  *              other (either way) renders the second one searched unable to
00077  *              supercede the first one:  If macros are searched first, (2)
00078  *              will be found ahead of the built-in FWord (which is what we
00079  *              want) but later, when we search for (3) among the FWords, it
00080  *              will not be found ahead of (2).  If, on the other hand, we
00081  *              search FWords first, the macro defined in (2) will never be
00082  *              found.
00083  *          We need a way to define both (all?) types of definitions in a
00084  *              single vocabulary that will honor the LIFO order of def'ns.
00085  *
00086  *          Mon, 19 Dec 2005 by David L. Paktor
00087  *          Begin development of implementation of a way to define both (all?)
00088  *              types of definitions in a single  tic_hdr_t  type vocabulary.
00089  *
00090  **************************************************************************** */
00091 
00092 
00093 
00094 /* **************************************************************************
00095  *
00096  *      We will be creating several different lists of initial built-in
00097  *          definitions; together, they constitute the Global Vocabulary.
00098  *          (We will avoid the term "dictionary", since, in classical
00099  *          Forth terminology, it refers to the complete collection of
00100  *          vocabularies in an application.)  The usage of the pointer
00101  *          to the Global Vocabulary is central to the operation of this
00102  *          program and the maintenance programmer needs to understand it.
00103  *          We may also refer to the Global Vocabulary as the "core" vocab.
00104  *
00105  *      Each initial list will be created as an array of TIC-header entries.
00106  *          Because the global vocabulary is expandable by the user,
00107  *          we will not be searching the lists as arrays but rather as
00108  *          linked-lists; the run-time initialization routine will fill
00109  *          in their link-fields and also will link the various lists
00110  *          together, so we can group their initial declarations according
00111  *          to our convenience.
00112  *
00113  *      A single pointer, called the "Global Vocabulary Dictionary Pointer"
00114  *          (okay, so classical Forth terminology isn't completely rigorous...)
00115  *          and abbreviated GV_DP, will point to the "tail" of the "thread".
00116  *          Similar vocabularies will be created for the device-nodes; look
00117  *          in the file  devnode.fth  for a more detailed discussion of those.
00118  *
00119  *      The "FC-Tokens" list contains the names and FCode numeric tokens
00120  *          of the straightforward FORTH words that simply write a token
00121  *          directly to the tokenized output.  We need to access these
00122  *          without being confused by aliases or other distractions, so
00123  *          we will keep a pointer to them especially for that purpose.
00124  *      Therefore it is IMPORTANT:  that the "FC-Tokens" list MUST be the
00125  *          first table linked by the initialization routine, so that its
00126  *          last-searched entry's link-field is NULL.
00127  *
00128  *      The "FWords" list contains FORTH words that require additional
00129  *          special action at tokenization-time.  Their numeric values
00130  *          are derived from the  fword_token  enumeration declaration,
00131  *          and are used as the control-expression for a SWITCH statement
00132  *          with a large number of CASE labels in the  handle_internal()
00133  *          function.
00134  *
00135  *      The "Shared Words" list contains FORTH words that can be executed
00136  *          similarly both during "Tokenizer Escape" mode (i.e., the scope
00137  *          of the special brackets:  tokenizer[  ...   ]tokenizer ) and
00138  *          also within "Normal Tokenization" mode.  Their numeric values
00139  *          are derived and used the same way as the "FWords".  Since we
00140  *          will be needing to do a separate search through them at times,
00141  *          we will also need a lower-bracket pointer for them.  (An upper
00142  *          bracket is irrelevant for these, because aliases can be added.
00143  *          This is not the case for the "FC-Tokens" list, because searches
00144  *          through those will be conducted from within this program.)
00145  *
00146  *      The "definer" field in the TIC-header structure is primarily used to
00147  *          detect attempts to apply the  TO  directive to an inappropriate
00148  *          target.  Its numeric values are a subset of the "FWord tokens".
00149  *          Certain "FC-Token" names are specified to be valid  TO  targets;
00150  *          their entries' "definer" fields will be initialized accordingly.
00151  *          Entries in FWord Token lists that are "shared" between "Normal
00152  *          Tokenization" and "Tokenizer Escape" modes will have their
00153  *          "definer" fields initialized to  COMMON_FWORD .  All other
00154  *          entries' "definer" fields will be initialized to  UNSPECIFIED .
00155  *
00156  *      Other files maintain and support additional lists with the same
00157  *          structure, which need to be linked together with the lists
00158  *          declared here.  We prefer to keep the  GV_DP  private to this
00159  *          file, so it will be passed as a parameter where needed.  (I'm
00160  *          not pleased to note, however, that it can't be kept completely
00161  *          private; it's needed for add_user_macro() and possibly other
00162  *          functions outside this file.)
00163  *
00164  *      The words that can only be used during "Tokenizer Escape" mode and
00165  *          the IBM-style "Locals", as well as the device-node vocabularies,
00166  *          will need to be separate and will not be linked together with
00167  *          the Global Vocabulary.
00168  *
00169  **************************************************************************** */
00170 
00171 /* **************************************************************************
00172  *
00173  *      We'll be initializing the lists later, but will be referencing
00174  *          the pointers sooner, so we need to declare the pointers here.
00175  *
00176  *      We will keep all of these pointers private to this file.
00177  *
00178  **************************************************************************** */
00179 
00180 static tic_hdr_t *global_voc_dict_ptr  = NULL;  /*  The Global Vocabulary    */
00181 static tic_hdr_t *fc_tokens_list_ender = NULL;  /*  Tokens search ends here  */
00182 static tic_hdr_t *fc_tokens_list_start = NULL;  /*  Start the search here    */
00183 static tic_hdr_t *shared_fwords_ender  = NULL;  /*  Shared FWords search end */
00184 static tic_hdr_t *global_voc_reset_ptr = NULL;  /*  Reset-point for G.V.     */
00185 
00186 
00187 /* **************************************************************************
00188  *
00189  *      Function name:  lookup_core_word
00190  *      Synopsis:       Return a pointer to the data-structure of the named
00191  *                      word in the "Global" Vocabulary
00192  *
00193  *      Inputs:
00194  *         Parameters:
00195  *             tname                     The name to look up
00196  *         Local Static Variables:
00197  *             global_voc_dict_ptr       "Tail" of Global Vocabulary
00198  *
00199  *      Outputs:
00200  *         Returned Value:                Pointer to the data-structure, or
00201  *                                            NULL if not found.
00202  *
00203  **************************************************************************** */
00204 
00205 tic_hdr_t *lookup_core_word( char *tname)
00206 {
00207     tic_hdr_t *found ;
00208 
00209     found = lookup_tic_entry( tname, global_voc_dict_ptr);
00210     return ( found ) ;
00211 }
00212 
00213 /* **************************************************************************
00214  *
00215  *      Function name:  exists_in_core
00216  *      Synopsis:       Confirm whether the given name exists in the
00217  *                      Global (aka "core") Vocabulary.  Search the
00218  *                      Global Vocabulary exclusively.
00219  *
00220  *      Inputs:
00221  *         Parameters:
00222  *             name                      The name for which to look
00223  *         Local Static Variables:
00224  *             global_voc_dict_ptr       "Tail" of Global Vocabulary
00225  *
00226  *      Outputs:
00227  *         Returned Value:               TRUE if name is found.
00228  *
00229  **************************************************************************** */
00230 
00231 bool exists_in_core( char *name)
00232 {
00233     return exists_in_tic_vocab( name, global_voc_dict_ptr );
00234 }
00235 
00236 /* **************************************************************************
00237  *
00238  *      Function name:  handle_core_word
00239  *      Synopsis:       Perform a function in the "Global" Vocabulary and
00240  *                      indicate whether the name is valid.
00241  *
00242  *      Inputs:
00243  *         Parameters:
00244  *             tname                     The name to handle
00245  *         Local Static Variables:
00246  *             global_voc_dict_ptr       "Tail" of Global Vocabulary
00247  *
00248  *      Outputs:
00249  *         Returned Value:   TRUE if the given name is valid in Global Vocab
00250  *
00251  *      Error Detection:
00252  *          If the name is not in the "Global" Vocabulary, let the calling
00253  *              routine determine whether to print an error message or to
00254  *              try it out as a number.
00255  *
00256  **************************************************************************** */
00257 
00258 bool handle_core_word( char *tname )
00259 {
00260     bool retval;
00261 
00262     retval = handle_tic_vocab( tname, global_voc_dict_ptr );
00263 
00264     return ( retval ) ;
00265 }
00266 
00267 
00268 /* **************************************************************************
00269  *
00270  *      Function name:  create_core_alias
00271  *      Synopsis:       Create, in the "Global" ("core") Vocabulary, an entry
00272  *                          for NEW_NAME that behaves the same as the latest
00273  *                          definition of OLD_NAME, and whose behavior will
00274  *                          not change even if a new definition of OLD_NAME
00275  *                          is overlaid.  Indicate if successful.
00276  *
00277  *      Inputs:
00278  *         Parameters:
00279  *             new_name          The name for the new alias to be created
00280  *             old_name          The name of the old function to be duplicated
00281  *         Local Static Variables:
00282  *             global_voc_dict_ptr        "Tail" of Global Vocabulary
00283  *
00284  *      Outputs:
00285  *         Returned Value:                TRUE if OLD_NAME was found.
00286  *         Local Static Variables:
00287  *             global_voc_dict_ptr        Updated with the new entry
00288  *         Memory Allocated
00289  *             By support routine.
00290  *
00291  *      Process Explanation:
00292  *          Both the "old" and "new" names are presumed to already point to
00293  *              stable, freshly allocated memory-spaces.
00294  *
00295  **************************************************************************** */
00296 
00297 bool create_core_alias( char *new_name, char *old_name)
00298 {
00299     bool retval = create_tic_alias( new_name, old_name, &global_voc_dict_ptr);
00300     return ( retval );
00301 }
00302 
00303 /* **************************************************************************
00304  *
00305  *      The functions that go into the various lists' FUNCT field may be
00306  *           defined below, or might be defined externally.
00307  *
00308  *      Often, we will need a function that merely recasts the type of the
00309  *           parameter field before passing it to the function that does
00310  *           the actual work.
00311  *
00312  *      Prologs will be brief or even non-existent.
00313  *
00314  *      Initialization macro definitions will accompany the functions.
00315  *
00316  **************************************************************************** */
00317 
00318 /* **************************************************************************
00319  *
00320  *      For the "FCode-Tokens" list, simply generate the token directly.
00321  *      We need this layer for param type conversion.
00322  *      In case we're ever able to eliminate it, (or just on General
00323  *          Principles) we'll invoke it via a macro...
00324  *
00325  **************************************************************************** */
00326 
00327 static void emit_fc_token( tic_param_t pfield)
00328 {
00329     u16 fc_tok = (u16)pfield.deflt_elem;
00330     emit_fcode( fc_tok);
00331 }
00332 
00333 #define FC_TOKEN_FUNC  emit_fc_token
00334 
00335 #define BUILTIN_FCODE( tok, nam)   \
00336      VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , UNSPECIFIED )
00337 
00338 /*  Built-in FCodes with known definers:  */
00339 #define BI_FCODE_VALUE( tok, nam)   \
00340      VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , VALUE )
00341 
00342 #define BI_FCODE_VRBLE( tok, nam)   \
00343      VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , VARIABLE )
00344 
00345 #define BI_FCODE_DEFER( tok, nam)   \
00346      VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , DEFER )
00347 
00348 #define BI_FCODE_CONST( tok, nam)   \
00349      VALPARAM_TIC(nam, FC_TOKEN_FUNC, tok , CONST )
00350 
00351 /* **************************************************************************
00352  *
00353  *      The "FCode-Tokens" list includes tokens that are identified
00354  *         in the Standard as Obsolete.  We will define a function
00355  *         that issues a WARNING before generating the token, and
00356  *         assign it to those elements of the list.
00357  *
00358  *      Control the message via a command-line flag.
00359  *
00360  **************************************************************************** */
00361 
00362 static void obsolete_warning( void)
00363 {
00364     if ( obso_fcode_warning )
00365     {
00366         tokenization_error( WARNING, "%s is an Obsolete FCode.\n",
00367             strupr(statbuf) );
00368     }
00369 }
00370 
00371 static void obsolete_fc_token( tic_param_t pfield)
00372 {
00373     obsolete_warning();
00374     emit_fc_token( pfield);
00375 }
00376 
00377 #define OBSO_FC_FUNC  obsolete_fc_token
00378 
00379 #define OBSOLETE_FCODE( tok, nam)   \
00380      VALPARAM_TIC(nam, OBSO_FC_FUNC, tok , UNSPECIFIED )
00381 
00382 #define OBSOLETE_VALUE( tok, nam)   \
00383      VALPARAM_TIC(nam, OBSO_FC_FUNC, tok , VALUE )
00384 
00385 
00386 /* **************************************************************************
00387  *
00388  *      The function for most of the "FWords" list,  handle_internal() ,
00389  *          is defined externally, but not exported in a  .h  file,
00390  *          because we want to keep it as private as possible.
00391  *      We will declare its prototype here.
00392  *
00393  *      Initialization macros for both "Normal Mode"-only and
00394  *          "Shared" entries are also defined here.
00395  *
00396  *   Arguments:
00397  *       fwt      (fword_token)    Value of the FWord Token (from Enum list)
00398  *       nam      (string)         Name of the entry as seen in the source
00399  *
00400  **************************************************************************** */
00401 
00402 void handle_internal( tic_param_t pfield);
00403 /*  "Skip-a-string when Ignoring" function.  Same args and limited-proto ...  */
00404 void skip_string( tic_param_t pfield);
00405 
00406 #define FWORD_EXEC_FUNC  handle_internal
00407 
00408 #define BUILTIN_FWORD( fwt, nam)   \
00409      FWORD_TKN_TIC(nam, FWORD_EXEC_FUNC, fwt, BI_FWRD_DEFN )
00410 
00411 #define SHARED_FWORD( fwt, nam)   \
00412      FWORD_TKN_TIC(nam, FWORD_EXEC_FUNC, fwt, COMMON_FWORD )
00413 
00414 /*  Variants:  When Ignoring, SKip One Word  */
00415 #define SHR_FWD_SKOW( fwt, nam)   \
00416      DUALFUNC_FWT_TIC(nam, FWORD_EXEC_FUNC, fwt, skip_a_word, COMMON_FWORD )
00417 
00418 /*  Variants:  When Ignoring, SKip one Word in line  */
00419 #define SH_FW_SK_WIL( fwt, nam)   \
00420      DUALFUNC_FWT_TIC(nam, FWORD_EXEC_FUNC, fwt,     \
00421          skip_a_word_in_line, COMMON_FWORD )
00422 
00423 /*  When Ignoring, SKip Two Words in line  */
00424 #define SH_FW_SK2WIL( fwt, nam)   \
00425      DUALFUNC_FWT_TIC(nam, FWORD_EXEC_FUNC, fwt,     \
00426          skip_two_words_in_line, COMMON_FWORD )
00427 
00428 /* **************************************************************************
00429  *
00430  *      Some of the entries in the "FWords" list -- both "Normal" (Built-in)
00431  *          and "Shared" also act as an "Ignore-handler".
00432  *          
00433  *   Arguments:
00434  *       nam      (string)         Name of the entry as seen in the source
00435  *       afunc    (routine-name)   Name of internal "active" function
00436  *       pval     (integer)        The "param field" item
00437  *       ifunc    (routine-name)   Name of "ignore-handling" function
00438  *
00439  **************************************************************************** */
00440 
00441 #define SHARED_IG_HDLR(nam, afunc, pval, ifunc)     \
00442     DUFNC_FWT_PARM(nam, afunc, pval, ifunc, COMMON_FWORD )
00443 
00444 /*  A "Shared" entry that uses the same routine for both of its functions  */
00445 #define SHR_SAMIG_FWRD( fwt, nam)   \
00446     DUFNC_FWT_PARM(nam, FWORD_EXEC_FUNC, fwt, FWORD_EXEC_FUNC, COMMON_FWORD )
00447 
00448 /* **************************************************************************
00449  *
00450  *     But the "Normal" (Built-in) FWord Ignore-handler uses the same
00451  *          routine as the  BUILTIN_FWORD for both of its functions.
00452  *
00453  *   Arguments:
00454  *       fwt      (fword_token)    Value of the FWord Token (from Enum list)
00455  *       nam      (string)         Name of the entry as seen in the source
00456  *
00457  **************************************************************************** */
00458 #define BI_IG_FW_HDLR( fwt, nam)   \
00459     DUALFUNC_FWT_TIC(nam, FWORD_EXEC_FUNC, fwt, FWORD_EXEC_FUNC, BI_FWRD_DEFN )
00460 
00461 /*  A variant:  A "Built-In FWorD that SKiPs One Word", when Ignoring  */
00462 #define BI_FWD_SKP_OW( fwt, nam)   \
00463      DUALFUNC_FWT_TIC(nam, FWORD_EXEC_FUNC, fwt, skip_a_word, BI_FWRD_DEFN )
00464 
00465 /*  Another variant:  A "Built-In FWorD String".  skip_string when Ignoring  */
00466 #define BI_FWD_STRING( fwt, nam)   \
00467      DUALFUNC_FWT_TIC(nam, FWORD_EXEC_FUNC, fwt, skip_string, BI_FWRD_DEFN )
00468 
00469 /* **************************************************************************
00470  *
00471  *      In order to protect device-nodes' methods from being accessed 
00472  *          by other device-nodes (with the attendant potential for
00473  *          disastrous consequences), we must establish a few rules:
00474  *
00475  *      Each device-node has a separate vocabulary for its methods.
00476  *          New definitions are made to the "current" device's vocabulary.
00477  *          Searches for names go through the "current" device-node's
00478  *              vocabulary first, then through the core dictionary.
00479  *
00480  *      A new-device (in interpretation-mode) creates a new device-node
00481  *          vocabulary.  The node that had been current (presumably its
00482  *          parent) remains in memory but inactive.
00483  *
00484  *      A finish-device (again, only in interpretation-mode) removes the
00485  *          current device-node's vocabulary from memory; its presumed
00486  *          parent once again becomes current.
00487  *
00488  *      Tokenization starts with an implicit "new-device" in effect.
00489  *          The top-level device-node is never removed.
00490  *
00491  *      The Global Variable  current_definitions  points to the vocabulary
00492  *          to which we will add and through which we will search first.
00493  *
00494  *      If "global" scope is in effect, then  current_definitions  will
00495  *           point to the "Global" (also called "core") vocabulary.
00496  *
00497  **************************************************************************** */
00498 
00499 /* **************************************************************************
00500  *
00501  *      Support for operations in "current" -- i.e., "global" vis-a-vis
00502  *          "device" -- scope.
00503  *      "Global" scope will not recognize words defined in "device" scope,
00504  *           but "device" scope will recognize "global" words.
00505  *
00506  **************************************************************************** */
00507 
00508 /* **************************************************************************
00509  *
00510  *      Functions to enter "global" scope and resume "device" scope.
00511  *
00512  **************************************************************************** */
00513 
00514 static tic_hdr_t **save_device_definitions;
00515 /* Export the indication that "global" scope is in effect  */
00516 bool scope_is_global = FALSE;
00517 
00518 
00519 void enter_global_scope( void )
00520 {
00521     if ( scope_is_global )
00522 {
00523         tokenization_error( WARNING,
00524             "%s -- Global Scope already in effect; ignoring.\n",
00525                 strupr(statbuf) );
00526     }else{
00527         tokenization_error( INFO,
00528             "Initiating Global Scope definitions.\n" );
00529         scope_is_global = TRUE;
00530         save_device_definitions = current_definitions;
00531         current_definitions = &global_voc_dict_ptr;
00532     }
00533 }
00534 
00535 void resume_device_scope( void )
00536 {
00537     if ( scope_is_global )
00538     {
00539         tokenization_error( INFO,
00540             "Terminating Global Scope definitions; "
00541                 "resuming Device-node definitions.\n" );
00542         current_definitions = save_device_definitions;
00543         scope_is_global = FALSE;
00544     }else{
00545         tokenization_error( WARNING,
00546             "%s -- Device-node Scope already in effect; ignoring.\n",
00547                 strupr(statbuf) );
00548     }
00549 
00550 }
00551 
00552 /* **************************************************************************
00553  *
00554  *      Function name:  lookup_current
00555  *      Synopsis:       Return a pointer to the data-structure of the named
00556  *                          word, either in the Current Device-Node vocab,
00557  *                          or in the Global ("core") Vocabulary.
00558  *
00559  *      Inputs:
00560  *         Parameters:
00561  *             tname                     The name to look for
00562  *         Global Variables:
00563  *             current_definitions       Current vocabulary:  Device-Node, or
00564  *                                           "core" if "global" scope in effect.
00565  *             scope_is_global           TRUE if "global" scope is in effect
00566  *         Local Static Variables:
00567  *             global_voc_dict_ptr       "Tail" of Global Vocabulary
00568  *
00569  *      Outputs:
00570  *         Returned Value:               Pointer to the data-structure, or
00571  *                                           NULL if not found.
00572  *
00573  *      Process Explanation:
00574  *          If a current Device-Node Vocabulary in effect, search through it.
00575  *          If the given name was not found, and "global" scope is not in
00576  *              effect (i.e., "core" was not already searched), make a
00577  *              separate search through the Global ("core") Vocabulary
00578  *
00579  *      Extraneous Remarks:
00580  *          This is the central routine for doing general word-searches that
00581  *              make use of the "normal"-mode search-list.
00582  *
00583  **************************************************************************** */
00584 
00585 tic_hdr_t *lookup_current( char *tname)
00586 {
00587     /*  Search Current Device Vocabulary ahead of global (core) vocabulary  */
00588     tic_hdr_t *retval;
00589     retval = lookup_tic_entry( tname, *current_definitions);
00590     if ( (retval == NULL) && INVERSE(scope_is_global) )
00591 {
00592         retval = lookup_core_word( tname);
00593     }
00594     return ( retval );
00595 }
00596 
00597 /* **************************************************************************
00598  *
00599  *      Function name:  exists_in_current
00600  *      Synopsis:       Confirm whether the given name exists either
00601  *                          in the Current Device-Node vocab,
00602  *                          or in the Global ("core") Vocabulary,
00603  *                          or in Tokenizer Escape Mode, if that's current.
00604  *
00605  *      Inputs:
00606  *         Parameters:
00607  *             tname                     The name to look for
00608  *
00609  *      Outputs:
00610  *         Returned Value:               TRUE if name is found
00611  *
00612  **************************************************************************** */
00613 
00614 bool exists_in_current( char *tname)
00615 {
00616     tic_hdr_t *found = lookup_word( tname, NULL, NULL);
00617     bool retval = BOOLVAL ( found != NULL);
00618     return( retval);
00619         }
00620 
00621 
00622 /* **************************************************************************
00623  *
00624  *      Function name:  handle_current
00625  *      Synopsis:       Perform a function in the current device-node vocab,
00626  *                      if one is in effect, or in the "Global" Vocabulary.
00627  *                      Indicate whether the name is valid.
00628  *
00629  *      Inputs:
00630  *         Parameters:
00631  *             tname                      The name to handle
00632  *         Global Variables:
00633  *             current_definitions        Device-Node (or Global) Vocabulary
00634  *                                            currently in effect.
00635  *             scope_is_global            TRUE if "global" scope is in effect
00636  *         Local Static Variables:
00637  *
00638  *      Outputs:
00639  *         Returned Value:                TRUE if the given name is valid
00640  *
00641  **************************************************************************** */
00642 
00643 bool handle_current( char *tname )
00644 {
00645     bool retval = handle_tic_vocab( tname, *current_definitions );
00646 
00647     if ( INVERSE(retval) && INVERSE(scope_is_global) )
00648     {
00649         retval = handle_core_word( tname );
00650     }
00651     return ( retval );
00652 
00653 }
00654 
00655 
00656 /* **************************************************************************
00657  *
00658  *      Function name:  lookup_in_dev_node
00659  *      Synopsis:       Return a pointer to the data-structure of the
00660  *                          named word in the Current device node, if
00661  *                          in "Device" scope.  Used for error-reporting.
00662  *
00663  *      Inputs:
00664  *         Parameters:
00665  *             tname                     The name to look for
00666  *         Global Variables:
00667  *             current_definitions        Device-Node (or Global) Vocabulary
00668  *                                            currently in effect.
00669  *             scope_is_global            FALSE if "Device" scope is in effect
00670  *
00671  *      Outputs:
00672  *         Returned Value:                Pointer to the data-structure, or
00673  *                                            NULL if not found.
00674  *
00675  **************************************************************************** */
00676 
00677 tic_hdr_t *lookup_in_dev_node( char *tname)
00678 {
00679     tic_hdr_t *retval = NULL;
00680 
00681     if ( INVERSE(scope_is_global) )
00682 {
00683         retval = lookup_tic_entry( tname, *current_definitions);
00684 }
00685     return ( retval );
00686 }
00687 
00688 
00689 /* **************************************************************************
00690  *
00691  *     In order to avoid unintentional "recursive"-ness, we need a way
00692  *          to render a newly created colon-definition non-findable
00693  *          until it's completed.
00694  *
00695  *      We will accomplish this by saving and reverting the pointer to
00696  *          the newest entry, when we call the  hide_last_colon() , and
00697  *          by restoring the pointer when we call  reveal_last_colon()
00698  *
00699  *      We need, therefore, to save the pointer to the last entry before
00700  *          we create the new entry.
00701  *
00702  **************************************************************************** */
00703 
00704 /*  Update this each time a new definition is entered  */
00705 static tic_hdr_t *save_current = NULL;
00706 
00707 /* **************************************************************************
00708  *
00709  *      Function name:  add_to_current
00710  *      Synopsis:       Add a new entry to the "current" scope of definitions,
00711  *                          which may be either the Global Vocabulary or the
00712  *                          current Device-Node Vocabulary.
00713  *
00714  *      Inputs:
00715  *         Parameters:
00716  *             name                      The name of the new entry
00717  *             fc_token                  The new entry's assigned FCode-number
00718  *             fw_definer                The new entry's definer
00719  *             define_token              If FALSE, suppress adding the entry,
00720  *                                           but preserve the side-effect of
00721  *                                           setting  save_current 
00722  *         Global Variables:
00723  *             current_definitions       Pointer to pointer to "tail" of the
00724  *                                           Vocabulary currently in effect;
00725  *                                           either Device-node or Global.
00726  *
00727  *      Outputs:
00728  *         Returned Value:               NONE
00729  *         Global Variables:
00730  *             *current_definitions    Updated with the new entry
00731  *         Local Static Variables:
00732  *             save_current            Pointer to previous entry
00733  *         Memory Allocated
00734  *             For the new entry's copy of the name.
00735  *         When Freed?
00736  *             When the Device-Node is "finish"ed or the Global Vocabulary
00737  *                 is reset, or when the program exits.
00738  *
00739  *      Process Explanation:
00740  *          Because  current_definitions  points to the Global Vocabulary
00741  *              pointer during "global" scope, this routine is extremely
00742  *              straightforward.
00743  *          All user-defined words have the same action, i.e., emitting
00744  *              the assigned FCode-number.  The new entry's "parameter
00745  *              field" size is, of course, zero; the "ignore-function"
00746  *              is NULL.
00747  *
00748  *      Extraneous Remarks:
00749  *          The  define_token  parameter is a late addition, necessitated
00750  *              by the decision to continue processing after an erroneous
00751  *              attempt to create a definition inside a control-structure,
00752  *              in order to catch other errors. 
00753  *            
00754  *
00755  **************************************************************************** */
00756 
00757 void add_to_current( char *name,
00758                            TIC_P_DEFLT_TYPE fc_token,
00759                                fwtoken definer,
00760                                    bool define_token)
00761 {
00762     save_current = *current_definitions;
00763     if ( define_token )
00764 {
00765         char *nu_name = strdup( name);
00766         add_tic_entry( nu_name, FC_TOKEN_FUNC, fc_token,
00767                            definer, 0 , NULL, current_definitions );
00768     }
00769 }
00770 
00771 
00772 void hide_last_colon ( void )
00773 {
00774     tic_hdr_t *temp_vocab;
00775 
00776     /*  The  add_to_current()  function will have been called before this
00777      *      one when a new colon-definition is created, so  save_current
00778      *      will have been set to point to the entry that had been made
00779      *      just before the newest one, which we are hiding here.
00780      */
00781 
00782     temp_vocab = save_current ;
00783     save_current = *current_definitions;
00784     *current_definitions = temp_vocab;
00785 
00786 }
00787 
00788 void reveal_last_colon ( void )
00789 {
00790     /*  We call this function either when the colon-definition is
00791      *      completed, or when "recursive"-ness is intentional.
00792      */
00793     *current_definitions = save_current ;
00794 }
00795 
00796 
00797 /* **************************************************************************
00798  *
00799  *      Function name:  create_current_alias
00800  *      Synopsis:       Create an alias for OLD_NAME, called NEW_NAME, in
00801  *                          the "current" scope of definitions, which may
00802  *                          be either the Global ("core") Vocabulary or the
00803  *                          current Device-Node Vocabulary.  Indicate if
00804  *                          successful (i.e., OLD_NAME was valid).
00805  *                      This is actually a little trickier than it may at
00806  *                          first appear; read the Rules in the Process
00807  *                          Explanation for full details...
00808  *
00809  *      Inputs:
00810  *         Parameters:
00811  *             new_name          The name for the new alias to be created
00812  *             old_name          The name of the old function to be duplicated
00813  *         Global Variables:
00814  *             current_definitions        Device-node vocabulary currently
00815  *                                            in effect.
00816  *             scope_is_global            TRUE if "global" scope is in effect
00817  *         Local Static Variables:
00818  *             global_voc_dict_ptr        "Tail" of Global Vocabulary
00819  *
00820  *      Outputs:
00821  *         Returned Value:                TRUE if OLD_NAME was found.
00822  *         Global Variables:
00823  *             *current_definitions      Updated with the new entry 
00824  *         Memory Allocated
00825  *             By support routine.
00826  *         When Freed?
00827  *             When RESET-SYMBOLS is issued (if "global" scope is in effect)
00828  *                 or when the device-node is "finish"ed.
00829  *         Printout:
00830  *             Advisory message if Rule 3 (see below) is invoked.
00831  *
00832  *      Process Explanation:
00833  *          Both the "old" and "new" names are presumed to already point to
00834  *              stable, freshly allocated memory-spaces.
00835  *          Rules:
00836  *          (1)
00837  *          If "global" scope is in effect, and the "old" name is found in
00838  *              the Global Vocabulary, then the "new" name will be created
00839  *              in the Global Vocabulary.
00840  *          (2)
00841  *          Similarly, if "device" scope is in effect, and the "old" name is
00842  *              found in the current device-node's vocabulary, the "new" name
00843  *              will be created in the current device-node's vocabulary.
00844  *          (3)
00845  *          BUT!:  If "device" scope is in effect, and the "old" name is found
00846  *              in the Global Vocabulary, then the "new" name will be created
00847  *              in the current device-node's vocabulary.  It will only be
00848  *              recognized in the scope of that device-node, and will be
00849  *              removed from memory when the device-node is "finish"ed.
00850  *          And, yes, it *is* supposed to work that way...   ;-)
00851  *
00852  *          Again, because  current_definitions  points to the Global Vocab
00853  *              pointer during "global" scope, the first two rules of this
00854  *              routine are extremely straightforward; it's Rule 3 that you
00855  *              have to watch out for...  ;-)
00856  *
00857  *          And one other thing:
00858  *              We will always make the alias's  pfld_size  zero.  See the
00859  *              prolog for  create_tic_alias()  in  ticvocab.c  for details...
00860  *
00861  *      Extraneous Remarks:
00862  *          I will stretch the rules of well-structured code here, too.
00863  *
00864  **************************************************************************** */
00865 
00866 bool create_current_alias( char *new_name, char *old_name )
00867 {
00868     bool retval = FALSE;
00869 
00870     if ( create_tic_alias( new_name, old_name, current_definitions) )
00871     {
00872          return ( TRUE );
00873     }
00874     
00875     if ( INVERSE(scope_is_global) )
00876     {
00877         tic_hdr_t *found = lookup_core_word( old_name );
00878         if ( found != NULL )
00879         {
00880             add_tic_entry( new_name, found->funct,
00881                                found->pfield.deflt_elem,
00882                                    found->fword_defr,
00883                                        0, found->ign_func,
00884                                            current_definitions );
00885             retval = TRUE;
00886             {
00887                 tokenization_error( INFO,
00888                    "%s is a Global definition, but its alias, %s, "
00889                        "will only be defined %s",
00890                            strupr( old_name), new_name,
00891                                in_what_node( current_device_node) );
00892                 show_node_start();
00893             }
00894         }
00895     }
00896 
00897     return ( retval );
00898 }
00899 
00900 /* **************************************************************************
00901  *
00902  *      Support functions specific to the lists will be defined
00903  *          after the lists are created.
00904  *
00905  **************************************************************************** */
00906 
00907 /* **************************************************************************
00908  *
00909  *     Create the initial list (or "Table") of FCode-Tokens.
00910  *
00911  *     Most Standard FCode tokens are not specified as to their definition
00912  *         type, but a few have a definer specified as either a VALUE, a
00913  *         VARIABLE or a DEFER; we will enter them with the appropriate macro.
00914  *
00915  **************************************************************************** */
00916 
00917 static tic_hdr_t tokens_table[] =
00918 {
00919         BUILTIN_FCODE( 0x000, "end0" ) ,
00920         BUILTIN_FCODE( 0x010, "b(lit)" ) ,
00921         BUILTIN_FCODE( 0x011, "b(')" ) ,
00922         BUILTIN_FCODE( 0x012, "b(\")" ) ,
00923         BUILTIN_FCODE( 0x013, "bbranch" ) ,
00924         BUILTIN_FCODE( 0x014, "b?branch" ) ,
00925         BUILTIN_FCODE( 0x015, "b(loop)" ) ,
00926         BUILTIN_FCODE( 0x016, "b(+loop)" ) ,
00927         BUILTIN_FCODE( 0x017, "b(do)" ) ,
00928         BUILTIN_FCODE( 0x018, "b(?do)" ) ,
00929         BUILTIN_FCODE( 0x019, "i" ) ,
00930         BUILTIN_FCODE( 0x01a, "j" ) ,
00931         BUILTIN_FCODE( 0x01b, "b(leave)" ) ,
00932         BUILTIN_FCODE( 0x01c, "b(of)" ) ,
00933         BUILTIN_FCODE( 0x01d, "execute" ) ,
00934         BUILTIN_FCODE( 0x01e, "+" ) ,
00935         BUILTIN_FCODE( 0x01f, "-" ) ,
00936         BUILTIN_FCODE( 0x020, "*" ) ,
00937         BUILTIN_FCODE( 0x021, "/" ) ,
00938         BUILTIN_FCODE( 0x022, "mod" ) ,
00939         BUILTIN_FCODE( 0x023, "and" ) ,
00940         BUILTIN_FCODE( 0x024, "or" ) ,
00941         BUILTIN_FCODE( 0x025, "xor" ) ,
00942         BUILTIN_FCODE( 0x026, "invert" ) ,
00943         BUILTIN_FCODE( 0x026, "not" ) ,           /*  Synonym for "invert" */
00944         BUILTIN_FCODE( 0x027, "lshift" ) ,
00945         BUILTIN_FCODE( 0x027, "<<" ) ,            /*  Synonym for "lshift" */
00946         BUILTIN_FCODE( 0x028, "rshift" ) ,
00947         BUILTIN_FCODE( 0x028, ">>" ) ,            /*  Synonym for "rshift" */
00948         BUILTIN_FCODE( 0x029, ">>a" ) ,
00949         BUILTIN_FCODE( 0x02a, "/mod" ) ,
00950         BUILTIN_FCODE( 0x02b, "u/mod" ) ,
00951         BUILTIN_FCODE( 0x02c, "negate" ) ,
00952         BUILTIN_FCODE( 0x02d, "abs" ) ,
00953         BUILTIN_FCODE( 0x02e, "min" ) ,
00954         BUILTIN_FCODE( 0x02f, "max" ) ,
00955         BUILTIN_FCODE( 0x030, ">r" ) ,
00956         BUILTIN_FCODE( 0x031, "r>" ) ,
00957         BUILTIN_FCODE( 0x032, "r@" ) ,
00958         BUILTIN_FCODE( 0x033, "exit" ) ,
00959         BUILTIN_FCODE( 0x034, "0=" ) ,
00960         BUILTIN_FCODE( 0x035, "0<>" ) ,
00961         BUILTIN_FCODE( 0x036, "0<" ) ,
00962         BUILTIN_FCODE( 0x037, "0<=" ) ,
00963         BUILTIN_FCODE( 0x038, "0>" ) ,
00964         BUILTIN_FCODE( 0x039, "0>=" ) ,
00965         BUILTIN_FCODE( 0x03a, "<" ) ,
00966         BUILTIN_FCODE( 0x03b, ">" ) ,
00967         BUILTIN_FCODE( 0x03c, "=" ) ,
00968         BUILTIN_FCODE( 0x03d, "<>" ) ,
00969         BUILTIN_FCODE( 0x03e, "u>" ) ,
00970         BUILTIN_FCODE( 0x03f, "u<=" ) ,
00971         BUILTIN_FCODE( 0x040, "u<" ) ,
00972         BUILTIN_FCODE( 0x041, "u>=" ) ,
00973         BUILTIN_FCODE( 0x042, ">=" ) ,
00974         BUILTIN_FCODE( 0x043, "<=" ) ,
00975         BUILTIN_FCODE( 0x044, "between" ) ,
00976         BUILTIN_FCODE( 0x045, "within" ) ,
00977         BUILTIN_FCODE( 0x046, "drop" ) ,
00978         BUILTIN_FCODE( 0x047, "dup" ) ,
00979         BUILTIN_FCODE( 0x048, "over" ) ,
00980         BUILTIN_FCODE( 0x049, "swap" ) ,
00981         BUILTIN_FCODE( 0x04A, "rot" ) ,
00982         BUILTIN_FCODE( 0x04b, "-rot" ) ,
00983         BUILTIN_FCODE( 0x04c, "tuck" ) ,
00984         BUILTIN_FCODE( 0x04d, "nip" ) ,
00985         BUILTIN_FCODE( 0x04e, "pick" ) ,
00986         BUILTIN_FCODE( 0x04f, "roll" ) ,
00987         BUILTIN_FCODE( 0x050, "?dup" ) ,
00988         BUILTIN_FCODE( 0x051, "depth" ) ,
00989         BUILTIN_FCODE( 0x052, "2drop" ) ,
00990         BUILTIN_FCODE( 0x053, "2dup" ) ,
00991         BUILTIN_FCODE( 0x054, "2over" ) ,
00992         BUILTIN_FCODE( 0x055, "2swap" ) ,
00993         BUILTIN_FCODE( 0x056, "2rot" ) ,
00994         BUILTIN_FCODE( 0x057, "2/" ) ,
00995         BUILTIN_FCODE( 0x058, "u2/" ) ,
00996         BUILTIN_FCODE( 0x059, "2*" ) ,
00997         BUILTIN_FCODE( 0x05a, "/c" ) ,
00998         BUILTIN_FCODE( 0x05b, "/w" ) ,
00999         BUILTIN_FCODE( 0x05c, "/l" ) ,
01000         BUILTIN_FCODE( 0x05d, "/n" ) ,
01001         BUILTIN_FCODE( 0x05e, "ca+" ) ,
01002         BUILTIN_FCODE( 0x05f, "wa+" ) ,
01003         BUILTIN_FCODE( 0x060, "la+" ) ,
01004         BUILTIN_FCODE( 0x061, "na+" ) ,
01005         BUILTIN_FCODE( 0x062, "char+" ) ,
01006         BUILTIN_FCODE( 0x062, "ca1+" ) ,          /*  Synonym for char+" */
01007         BUILTIN_FCODE( 0x063, "wa1+" ) ,
01008         BUILTIN_FCODE( 0x064, "la1+" ) ,
01009         BUILTIN_FCODE( 0x065, "cell+" ) ,
01010         BUILTIN_FCODE( 0x065, "na1+" ) ,          /*  Synonym for "cell+" */
01011         BUILTIN_FCODE( 0x066, "chars" ) ,
01012         BUILTIN_FCODE( 0x066, "/c*" ) ,           /*  Synonym for "chars" */
01013         BUILTIN_FCODE( 0x067, "/w*" ) ,
01014         BUILTIN_FCODE( 0x068, "/l*" ) ,
01015         BUILTIN_FCODE( 0x069, "cells" ) ,
01016         BUILTIN_FCODE( 0x069, "/n*" ) ,           /*  Synonym for "cells" */
01017         BUILTIN_FCODE( 0x06a, "on" ) ,
01018         BUILTIN_FCODE( 0x06b, "off" ) ,
01019         BUILTIN_FCODE( 0x06c, "+!" ) ,
01020         BUILTIN_FCODE( 0x06d, "@" ) ,
01021         BUILTIN_FCODE( 0x06e, "l@" ) ,
01022         BUILTIN_FCODE( 0x06f, "w@" ) ,
01023         BUILTIN_FCODE( 0x070, "<w@" ) ,
01024         BUILTIN_FCODE( 0x071, "c@" ) ,
01025         BUILTIN_FCODE( 0x072, "!" ) ,
01026         BUILTIN_FCODE( 0x073, "l!" ) ,
01027         BUILTIN_FCODE( 0x074, "w!" ) ,
01028         BUILTIN_FCODE( 0x075, "c!" ) ,
01029         BUILTIN_FCODE( 0x076, "2@" ) ,
01030         BUILTIN_FCODE( 0x077, "2!" ) ,
01031         BUILTIN_FCODE( 0x078, "move" ) ,
01032         BUILTIN_FCODE( 0x079, "fill" ) ,
01033         BUILTIN_FCODE( 0x07a, "comp" ) ,
01034         BUILTIN_FCODE( 0x07b, "noop" ) ,
01035         BUILTIN_FCODE( 0x07c, "lwsplit" ) ,
01036         BUILTIN_FCODE( 0x07d, "wljoin" ) ,
01037         BUILTIN_FCODE( 0x07e, "lbsplit" ) ,
01038         BUILTIN_FCODE( 0x07f, "bljoin" ) ,
01039         BUILTIN_FCODE( 0x080, "wbflip" ) ,
01040         BUILTIN_FCODE( 0x080, "flip" ) ,   /*  Synonym for "wbflip"  */
01041         BUILTIN_FCODE( 0x081, "upc" ) ,
01042         BUILTIN_FCODE( 0x082, "lcc" ) ,
01043         BUILTIN_FCODE( 0x083, "pack" ) ,
01044         BUILTIN_FCODE( 0x084, "count" ) ,
01045         BUILTIN_FCODE( 0x085, "body>" ) ,
01046         BUILTIN_FCODE( 0x086, ">body" ) ,
01047         BUILTIN_FCODE( 0x087, "fcode-revision" ) ,
01048         BUILTIN_FCODE( 0x087, "version" ) , /*  Synonym for "fcode-revision" */
01049         BI_FCODE_VRBLE( 0x088, "span" ) ,
01050         BUILTIN_FCODE( 0x089, "unloop" ) ,
01051         BUILTIN_FCODE( 0x08a, "expect" ) ,
01052         BUILTIN_FCODE( 0x08b, "alloc-mem" ) ,
01053         BUILTIN_FCODE( 0x08c, "free-mem" ) ,
01054         BUILTIN_FCODE( 0x08d, "key?" ) ,
01055         BUILTIN_FCODE( 0x08e, "key" ) ,
01056         BUILTIN_FCODE( 0x08f, "emit" ) ,
01057         BUILTIN_FCODE( 0x090, "type" ) ,
01058         BUILTIN_FCODE( 0x091, "(cr" ) ,
01059         BUILTIN_FCODE( 0x092, "cr" ) ,
01060         BI_FCODE_VRBLE( 0x093, "#out" ) ,
01061         BI_FCODE_VRBLE( 0x094, "#line" ) ,
01062         BUILTIN_FCODE( 0x095, "hold" ) ,
01063         BUILTIN_FCODE( 0x096, "<#" ) ,
01064         BUILTIN_FCODE( 0x097, "u#>" ) ,
01065         BUILTIN_FCODE( 0x098, "sign" ) ,
01066         BUILTIN_FCODE( 0x099, "u#" ) ,
01067         BUILTIN_FCODE( 0x09a, "u#s" ) ,
01068         BUILTIN_FCODE( 0x09b, "u." ) ,
01069         BUILTIN_FCODE( 0x09c, "u.r" ) ,
01070         BUILTIN_FCODE( 0x09d, "." ) ,
01071         BUILTIN_FCODE( 0x09e, ".r" ) ,
01072         BUILTIN_FCODE( 0x09f, ".s" ) ,
01073         BI_FCODE_VRBLE( 0x0a0, "base" ) ,
01074         OBSOLETE_FCODE( 0x0a1, "convert" ) ,
01075         BUILTIN_FCODE( 0x0a2, "$number" ) ,
01076         BUILTIN_FCODE( 0x0a3, "digit" ) ,
01077         BI_FCODE_CONST( 0x0a4, "-1" ) ,
01078         BI_FCODE_CONST( 0x0a4, "true" ) ,          /*  Synonym for "-1" */
01079         BI_FCODE_CONST( 0x0a5, "0" ) ,
01080         BI_FCODE_CONST( 0x0a5, "false" ) ,         /*  Synonym for "0" */
01081         BI_FCODE_CONST( 0x0a5, "struct" ) ,        /*  Synonym for "0" */
01082         BI_FCODE_CONST( 0x0a6, "1" ) ,
01083         BI_FCODE_CONST( 0x0a7, "2" ) ,
01084         BI_FCODE_CONST( 0x0a8, "3" ) ,
01085         BI_FCODE_CONST( 0x0a9, "bl" ) ,
01086         BI_FCODE_CONST( 0x0aa, "bs" ) ,
01087         BI_FCODE_CONST( 0x0ab, "bell" ) ,
01088         BUILTIN_FCODE( 0x0ac, "bounds" ) ,
01089         BUILTIN_FCODE( 0x0ad, "here" ) ,
01090         BUILTIN_FCODE( 0x0ae, "aligned" ) ,
01091         BUILTIN_FCODE( 0x0af, "wbsplit" ) ,
01092         BUILTIN_FCODE( 0x0b0, "bwjoin" ) ,
01093         BUILTIN_FCODE( 0x0b1, "b(<mark)" ) ,
01094         BUILTIN_FCODE( 0x0b2, "b(>resolve)" ) ,
01095         OBSOLETE_FCODE( 0x0b3, "set-token-table" ) ,
01096         OBSOLETE_FCODE( 0x0b4, "set-table" ) ,
01097         BUILTIN_FCODE( 0x0b5, "new-token" ) ,
01098         BUILTIN_FCODE( 0x0b6, "named-token" ) ,
01099         BUILTIN_FCODE( 0x0b7, "b(:)" ) ,
01100         BUILTIN_FCODE( 0x0b8, "b(value)" ) ,
01101         BUILTIN_FCODE( 0x0b9, "b(variable)" ) ,
01102         BUILTIN_FCODE( 0x0ba, "b(constant)" ) ,
01103         BUILTIN_FCODE( 0x0bb, "b(create)" ) ,
01104         BUILTIN_FCODE( 0x0bc, "b(defer)" ) ,
01105         BUILTIN_FCODE( 0x0bd, "b(buffer:)" ) ,
01106         BUILTIN_FCODE( 0x0be, "b(field)" ) ,
01107         OBSOLETE_FCODE( 0x0bf, "b(code)" ) ,
01108         BUILTIN_FCODE( 0x0c0, "instance" ) ,
01109         BUILTIN_FCODE( 0x0c2, "b(;)" ) ,
01110         BUILTIN_FCODE( 0x0c3, "b(to)" ) ,
01111         BUILTIN_FCODE( 0x0c4, "b(case)" ) ,
01112         BUILTIN_FCODE( 0x0c5, "b(endcase)" ) ,
01113         BUILTIN_FCODE( 0x0c6, "b(endof)" ) ,
01114         BUILTIN_FCODE( 0x0c7, "#" ) ,
01115         BUILTIN_FCODE( 0x0c8, "#s" ) ,
01116         BUILTIN_FCODE( 0x0c9, "#>" ) ,
01117         BUILTIN_FCODE( 0x0ca, "external-token" ) ,
01118         BUILTIN_FCODE( 0x0cb, "$find" ) ,
01119         BUILTIN_FCODE( 0x0cc, "offset16" ) ,
01120         BUILTIN_FCODE( 0x0cd, "evaluate" ) ,
01121         BUILTIN_FCODE( 0x0cd, "eval" ) ,   /*  Synonym for "evaluate"  */
01122         BUILTIN_FCODE( 0x0d0, "c," ) ,
01123         BUILTIN_FCODE( 0x0d1, "w," ) ,
01124         BUILTIN_FCODE( 0x0d2, "l," ) ,
01125         BUILTIN_FCODE( 0x0d3, "," ) ,
01126         BUILTIN_FCODE( 0x0d4, "um*" ) ,
01127         BUILTIN_FCODE( 0x0d4, "u*x" ) ,        /*  Synonym for "um*" */
01128         BUILTIN_FCODE( 0x0d5, "um/mod" ) ,
01129         BUILTIN_FCODE( 0x0d5, "xu/mod" ) ,   /*  Synonym for "um/mod"  */
01130         BUILTIN_FCODE( 0x0d8, "d+" ) ,
01131         BUILTIN_FCODE( 0x0d8, "x+" ) ,   /*  Synonym for "d+"  */
01132         BUILTIN_FCODE( 0x0d9, "d-" ) ,
01133         BUILTIN_FCODE( 0x0d9, "x-" ) ,   /*  Synonym for "d-"  */
01134         BUILTIN_FCODE( 0x0da, "get-token" ) ,
01135         BUILTIN_FCODE( 0x0db, "set-token" ) ,
01136         BI_FCODE_VRBLE( 0x0dc, "state" ) ,
01137         BUILTIN_FCODE( 0x0dd, "compile" ) ,
01138         BUILTIN_FCODE( 0x0de, "behavior" ) ,
01139         BUILTIN_FCODE( 0x0f0, "start0" ) ,
01140         BUILTIN_FCODE( 0x0f1, "start1" ) ,
01141         BUILTIN_FCODE( 0x0f2, "start2" ) ,
01142         BUILTIN_FCODE( 0x0f3, "start4" ) ,
01143         BUILTIN_FCODE( 0x0fc, "ferror" ) ,
01144         BUILTIN_FCODE( 0x0fd, "version1" ) ,
01145         OBSOLETE_FCODE( 0x0fe, "4-byte-id" ) ,
01146         BUILTIN_FCODE( 0x0ff, "end1" ) ,
01147         OBSOLETE_FCODE( 0x101, "dma-alloc" ) ,
01148         BUILTIN_FCODE( 0x102, "my-address" ) ,
01149         BUILTIN_FCODE( 0x103, "my-space" ) ,
01150         OBSOLETE_FCODE( 0x104, "memmap" ) ,
01151         BUILTIN_FCODE( 0x105, "free-virtual" ) ,
01152         OBSOLETE_FCODE( 0x106, ">physical" ) ,
01153         OBSOLETE_FCODE( 0x10f, "my-params" ) ,
01154         BUILTIN_FCODE( 0x110, "property" ) ,
01155         BUILTIN_FCODE( 0x110, "attribute" ) ,    /*  Synonym for "property"  */
01156         BUILTIN_FCODE( 0x111, "encode-int" ) ,
01157         BUILTIN_FCODE( 0x111, "xdrint" ) ,     /*  Synonym for "encode-int"  */
01158         BUILTIN_FCODE( 0x112, "encode+" ) ,
01159         BUILTIN_FCODE( 0x112, "xdr+" ) ,          /*  Synonym for "encode+"  */
01160         BUILTIN_FCODE( 0x113, "encode-phys" ) ,
01161         BUILTIN_FCODE( 0x113, "xdrphys" ) ,   /*  Synonym for "encode-phys"  */
01162         BUILTIN_FCODE( 0x114, "encode-string" ) ,
01163         BUILTIN_FCODE( 0x114, "xdrstring" ) , /* Synonym for "encode-string" */
01164         BUILTIN_FCODE( 0x115, "encode-bytes" ) ,
01165         BUILTIN_FCODE( 0x115, "xdrbytes" ) ,  /*  Synonym for "encode-bytes" */
01166         BUILTIN_FCODE( 0x116, "reg" ) ,
01167         OBSOLETE_FCODE( 0x117, "intr" ) ,
01168         OBSOLETE_FCODE( 0x118, "driver" ) ,
01169         BUILTIN_FCODE( 0x119, "model" ) ,
01170         BUILTIN_FCODE( 0x11a, "device-type" ) ,
01171         BUILTIN_FCODE( 0x11b, "parse-2int" ) ,
01172         BUILTIN_FCODE( 0x11b, "decode-2int" ) , /*  Synonym for "parse-2int" */
01173         BUILTIN_FCODE( 0x11c, "is-install" ) ,
01174         BUILTIN_FCODE( 0x11d, "is-remove" ) ,
01175         BUILTIN_FCODE( 0x11e, "is-selftest" ) ,
01176         BUILTIN_FCODE( 0x11f, "new-device" ) ,
01177         BUILTIN_FCODE( 0x120, "diagnostic-mode?" ) ,
01178         BUILTIN_FCODE( 0x121, "display-status" ) ,
01179         BUILTIN_FCODE( 0x122, "memory-test-issue" ) ,
01180         OBSOLETE_FCODE( 0x123, "group-code" ) ,
01181         BI_FCODE_VRBLE( 0x124, "mask" ) ,
01182         BUILTIN_FCODE( 0x125, "get-msecs" ) ,
01183         BUILTIN_FCODE( 0x126, "ms" ) ,
01184         BUILTIN_FCODE( 0x127, "finish-device" ) ,
01185         BUILTIN_FCODE( 0x128, "decode-phys" ) ,
01186         BUILTIN_FCODE( 0x12b, "interpose" ) ,
01187         BUILTIN_FCODE( 0x130, "map-low" ) ,
01188         BUILTIN_FCODE( 0x130, "map-sbus" ) ,   /*  Synonym for "map-low"  */
01189         BUILTIN_FCODE( 0x131, "sbus-intr>cpu" ) ,
01190         BI_FCODE_VALUE( 0x150, "#lines" ) ,
01191         BI_FCODE_VALUE( 0x151, "#columns" ) ,
01192         BI_FCODE_VALUE( 0x152, "line#" ) ,
01193         BI_FCODE_VALUE( 0x153, "column#" ) ,
01194         BI_FCODE_VALUE( 0x154, "inverse?" ) ,
01195         BI_FCODE_VALUE( 0x155, "inverse-screen?" ) ,
01196         OBSOLETE_VALUE( 0x156, "frame-buffer-busy?" ) ,
01197         BI_FCODE_DEFER( 0x157, "draw-character" ) ,
01198         BI_FCODE_DEFER( 0x158, "reset-screen" ) ,
01199         BI_FCODE_DEFER( 0x159, "toggle-cursor" ) ,
01200         BI_FCODE_DEFER( 0x15a, "erase-screen" ) ,
01201         BI_FCODE_DEFER( 0x15b, "blink-screen" ) ,
01202         BI_FCODE_DEFER( 0x15c, "invert-screen" ) ,
01203         BI_FCODE_DEFER( 0x15d, "insert-characters" ) ,
01204         BI_FCODE_DEFER( 0x15e, "delete-characters" ) ,
01205         BI_FCODE_DEFER( 0x15f, "insert-lines" ) ,
01206         BI_FCODE_DEFER( 0x160, "delete-lines" ) ,
01207         BI_FCODE_DEFER( 0x161, "draw-logo" ) ,
01208         BI_FCODE_VALUE( 0x162, "frame-buffer-adr" ) ,
01209         BI_FCODE_VALUE( 0x163, "screen-height" ) ,
01210         BI_FCODE_VALUE( 0x164, "screen-width" ) ,
01211         BI_FCODE_VALUE( 0x165, "window-top" ) ,
01212         BI_FCODE_VALUE( 0x166, "window-left" ) ,
01213         BUILTIN_FCODE( 0x16a, "default-font" ) ,
01214         BUILTIN_FCODE( 0x16b, "set-font" ) ,
01215         BI_FCODE_VALUE( 0x16c, "char-height" ) ,
01216         BI_FCODE_VALUE( 0x16d, "char-width" ) ,
01217         BUILTIN_FCODE( 0x16e, ">font" ) ,
01218         BI_FCODE_VALUE( 0x16f, "fontbytes" ) ,
01219         OBSOLETE_FCODE( 0x170, "fb1-draw-character" ) ,
01220         OBSOLETE_FCODE( 0x171, "fb1-reset-screen" ) ,
01221         OBSOLETE_FCODE( 0x172, "fb1-toggle-cursor" ) ,
01222         OBSOLETE_FCODE( 0x173, "fb1-erase-screen" ) ,
01223         OBSOLETE_FCODE( 0x174, "fb1-blink-screen" ) ,
01224         OBSOLETE_FCODE( 0x175, "fb1-invert-screen" ) ,
01225         OBSOLETE_FCODE( 0x176, "fb1-insert-characters" ) ,
01226         OBSOLETE_FCODE( 0x177, "fb1-delete-characters" ) ,
01227         OBSOLETE_FCODE( 0x178, "fb1-insert-lines" ) ,
01228         OBSOLETE_FCODE( 0x179, "fb1-delete-lines" ) ,
01229         OBSOLETE_FCODE( 0x17a, "fb1-draw-logo" ) ,
01230         OBSOLETE_FCODE( 0x17b, "fb1-install" ) ,
01231         OBSOLETE_FCODE( 0x17c, "fb1-slide-up" ) ,
01232         BUILTIN_FCODE( 0x180, "fb8-draw-character" ) ,
01233         BUILTIN_FCODE( 0x181, "fb8-reset-screen" ) ,
01234         BUILTIN_FCODE( 0x182, "fb8-toggle-cursor" ) ,
01235         BUILTIN_FCODE( 0x183, "fb8-erase-screen" ) ,
01236         BUILTIN_FCODE( 0x184, "fb8-blink-screen" ) ,
01237         BUILTIN_FCODE( 0x185, "fb8-invert-screen" ) ,
01238         BUILTIN_FCODE( 0x186, "fb8-insert-characters" ) ,
01239         BUILTIN_FCODE( 0x187, "fb8-delete-characters" ) ,
01240         BUILTIN_FCODE( 0x188, "fb8-insert-lines" ) ,
01241         BUILTIN_FCODE( 0x189, "fb8-delete-lines" ) ,
01242         BUILTIN_FCODE( 0x18a, "fb8-draw-logo" ) ,
01243         BUILTIN_FCODE( 0x18b, "fb8-install" ) ,
01244         OBSOLETE_FCODE( 0x1a0, "return-buffer" ) ,
01245         OBSOLETE_FCODE( 0x1a1, "xmit-packet" ) ,
01246         OBSOLETE_FCODE( 0x1a2, "poll-packet" ) ,
01247         BUILTIN_FCODE( 0x1a4, "mac-address" ) ,
01248         BUILTIN_FCODE( 0x201, "device-name" ) ,
01249         BUILTIN_FCODE( 0x201, "name" ) ,   /*  Synonym for "device-name"  */
01250         BUILTIN_FCODE( 0x202, "my-args" ) ,
01251         BI_FCODE_VALUE( 0x203, "my-self" ) ,
01252         BUILTIN_FCODE( 0x204, "find-package" ) ,
01253         BUILTIN_FCODE( 0x205, "open-package" ) ,
01254         BUILTIN_FCODE( 0x206, "close-package" ) ,
01255         BUILTIN_FCODE( 0x207, "find-method" ) ,
01256         BUILTIN_FCODE( 0x208, "call-package" ) ,
01257         BUILTIN_FCODE( 0x209, "$call-parent" ) ,
01258         BUILTIN_FCODE( 0x20a, "my-parent" ) ,
01259         BUILTIN_FCODE( 0x20b, "ihandle>phandle" ) ,
01260         BUILTIN_FCODE( 0x20d, "my-unit" ) ,
01261         BUILTIN_FCODE( 0x20e, "$call-method" ) ,
01262         BUILTIN_FCODE( 0x20f, "$open-package" ) ,
01263         OBSOLETE_FCODE( 0x210, "processor-type" ) ,
01264         OBSOLETE_FCODE( 0x211, "firmware-version" ) ,
01265         OBSOLETE_FCODE( 0x212, "fcode-version" ) ,
01266         BUILTIN_FCODE( 0x213, "alarm" ) ,
01267         BUILTIN_FCODE( 0x214, "(is-user-word)" ) ,
01268         BUILTIN_FCODE( 0x215, "suspend-fcode" ) ,
01269         BUILTIN_FCODE( 0x216, "abort" ) ,
01270         BUILTIN_FCODE( 0x217, "catch" ) ,
01271         BUILTIN_FCODE( 0x218, "throw" ) ,
01272         BUILTIN_FCODE( 0x219, "user-abort" ) ,
01273         BUILTIN_FCODE( 0x21a, "get-my-property" ) ,
01274         BUILTIN_FCODE( 0x21a, "get-my-attribute" ) ,   /*  Synonym for "get-my-property"  */
01275         BUILTIN_FCODE( 0x21b, "decode-int" ) ,
01276         BUILTIN_FCODE( 0x21b, "xdrtoint" ) ,   /*  Synonym for "decode-int"  */
01277         BUILTIN_FCODE( 0x21c, "decode-string" ) ,
01278         BUILTIN_FCODE( 0x21c, "xdrtostring" ), /* Synonym for "decode-string" */
01279         BUILTIN_FCODE( 0x21d, "get-inherited-property" ) ,
01280         BUILTIN_FCODE( 0x21d, "get-inherited-attribute" ) ,   /*  Synonym for "get-inherited-property"  */
01281         BUILTIN_FCODE( 0x21e, "delete-property" ) ,
01282         BUILTIN_FCODE( 0x21e, "delete-attribute" ) ,   /*  Synonym for "delete-property"  */
01283         BUILTIN_FCODE( 0x21f, "get-package-property" ) ,
01284         BUILTIN_FCODE( 0x21f, "get-package-attribute" ) ,   /*  Synonym for "get-package-property"  */
01285         BUILTIN_FCODE( 0x220, "cpeek" ) ,
01286         BUILTIN_FCODE( 0x221, "wpeek" ) ,
01287         BUILTIN_FCODE( 0x222, "lpeek" ) ,
01288         BUILTIN_FCODE( 0x223, "cpoke" ) ,
01289         BUILTIN_FCODE( 0x224, "wpoke" ) ,
01290         BUILTIN_FCODE( 0x225, "lpoke" ) ,
01291         BUILTIN_FCODE( 0x226, "lwflip" ) ,
01292         BUILTIN_FCODE( 0x227, "lbflip" ) ,
01293         BUILTIN_FCODE( 0x228, "lbflips" ) ,
01294         OBSOLETE_FCODE( 0x229, "adr-mask" ) ,
01295         BUILTIN_FCODE( 0x230, "rb@" ) ,
01296         BUILTIN_FCODE( 0x231, "rb!" ) ,
01297         BUILTIN_FCODE( 0x232, "rw@" ) ,
01298         BUILTIN_FCODE( 0x233, "rw!" ) ,
01299         BUILTIN_FCODE( 0x234, "rl@" ) ,
01300         BUILTIN_FCODE( 0x235, "rl!" ) ,
01301         BUILTIN_FCODE( 0x236, "wbflips" ) ,
01302         BUILTIN_FCODE( 0x236, "wflips" ) ,   /*  Synonym for "wbflips"  */
01303         BUILTIN_FCODE( 0x237, "lwflips" ) ,
01304         BUILTIN_FCODE( 0x237, "lflips" ) ,   /*  Synonym for "lwflips"  */
01305         OBSOLETE_FCODE( 0x238, "probe" ) ,
01306         OBSOLETE_FCODE( 0x239, "probe-virtual" ) ,
01307         BUILTIN_FCODE( 0x23b, "child" ) ,
01308         BUILTIN_FCODE( 0x23c, "peer" ) ,
01309         BUILTIN_FCODE( 0x23d, "next-property" ) ,
01310         BUILTIN_FCODE( 0x23e, "byte-load" ) ,
01311         BUILTIN_FCODE( 0x23f, "set-args" ) ,
01312         BUILTIN_FCODE( 0x240, "left-parse-string" ) ,
01313 
01314         /* FCodes from 64bit extension addendum */
01315         BUILTIN_FCODE( 0x22e, "rx@" ) ,
01316         BUILTIN_FCODE( 0x22f, "rx!" ) ,
01317         BUILTIN_FCODE( 0x241, "bxjoin" ) ,
01318         BUILTIN_FCODE( 0x242, "<l@" ) ,
01319         BUILTIN_FCODE( 0x243, "lxjoin" ) ,
01320         BUILTIN_FCODE( 0x244, "wxjoin" ) ,
01321         BUILTIN_FCODE( 0x245, "x," ) ,
01322         BUILTIN_FCODE( 0x246, "x@" ) ,
01323         BUILTIN_FCODE( 0x247, "x!" ) ,
01324         BUILTIN_FCODE( 0x248, "/x" ) ,
01325         BUILTIN_FCODE( 0x249, "/x*" ) ,
01326         BUILTIN_FCODE( 0x24a, "xa+" ) ,
01327         BUILTIN_FCODE( 0x24b, "xa1+" ) ,
01328         BUILTIN_FCODE( 0x24c, "xbflip" ) ,
01329         BUILTIN_FCODE( 0x24d, "xbflips" ) ,
01330         BUILTIN_FCODE( 0x24e, "xbsplit" ) ,
01331         BUILTIN_FCODE( 0x24f, "xlflip" ) ,
01332         BUILTIN_FCODE( 0x250, "xlflips" ) ,
01333         BUILTIN_FCODE( 0x251, "xlsplit" ) ,
01334         BUILTIN_FCODE( 0x252, "xwflip" ) ,
01335         BUILTIN_FCODE( 0x253, "xwflips" ) ,
01336         BUILTIN_FCODE( 0x254, "xwsplit" )
01337 };
01338 
01339 static const int number_of_builtin_tokens =
01340          sizeof(tokens_table)/sizeof(tic_hdr_t);
01341 
01342 /* **************************************************************************
01343  *
01344  *      Support functions specific to the FCode-Tokens list.
01345  *
01346  **************************************************************************** */
01347 
01348 
01349 /* **************************************************************************
01350  *
01351  *      Function name:  emit_token
01352  *      Synopsis:       Emit the FCode token for the given FCode name.
01353  *
01354  *      Inputs:
01355  *         Parameters:
01356  *             fc_name                     The name of the FCode
01357  *         Local Static Variables:
01358  *             fc_tokens_list_start        "Tail" of the "FC-Tokens" list
01359  *
01360  *      Outputs:
01361  *         Returned Value:                 NONE
01362  *
01363  *      Error Detection:
01364  *          This routine should only be called with hard-coded names from
01365  *              within the program.  If the given name is not found in
01366  *              the Built-in Tokens Table, that is a FATAL error.
01367  *
01368  *      Process Explanation:
01369  *          Because the "FCode-Tokens" table was linked first, and the
01370  *              pointer kept for this purpose, the "FC-Tokens" list can
01371  *              be a subset of the "core" list, yet, when necessary, can
01372  *              be searched with the same routines.
01373  *
01374  *      Extraneous Remarks:
01375  *          I will bend the strict rules of well-structured code;
01376  *              the exception case should never occur.
01377  *
01378  **************************************************************************** */
01379 
01380 void emit_token( const char *fc_name)
01381 {
01382 
01383     if ( handle_tic_vocab( (char *)fc_name, fc_tokens_list_start) )
01384     {
01385         return;
01386     }
01387 
01388     tokenization_error( FATAL, "Did not recognize FCode name %s", fc_name);
01389 }
01390 
01391 
01392 /* **************************************************************************
01393  *
01394  *      Function name:  lookup_token
01395  *      Synopsis:       Return a pointer to the data-structure of the named
01396  *                      word in the "FC-Tokens" list
01397  *
01398  *      Inputs:
01399  *         Parameters:
01400  *             tname                       The name to look up
01401  *         Local Static Variables:
01402  *             fc_tokens_list_start        "Tail" of the "FC-Tokens" list
01403  *
01404  *      Outputs:
01405  *         Returned Value:                Pointer to the data-structure, or
01406  *                                            NULL if not found.
01407  *
01408  **************************************************************************** */
01409 
01410 tic_hdr_t *lookup_token( char *tname)
01411 {
01412     tic_hdr_t *found ;
01413 
01414     found = lookup_tic_entry( tname, fc_tokens_list_start);
01415     return ( found ) ;
01416 }
01417 
01418 /* **************************************************************************
01419  *
01420  *      Function name:  entry_is_token
01421  *      Synopsis:       Indicate whether the supplied pointer to a tic_hdr_t
01422  *                      data-structure is one for which a single-token FCode
01423  *                      number is assigned.
01424  *
01425  *      Inputs:
01426  *         Parameters:
01427  *             test_entry                The entry to test; may be NULL
01428  *         Local macros:
01429  *             FC_TOKEN_FUNC             The function associated with
01430  *                                           most single-token entries.
01431  *             OBSO_FC_FUNC              The function associated with
01432  *                                           "obsolete" FCode tokens.
01433  *
01434  *      Outputs:
01435  *         Returned Value:               TRUE if the data-structure is
01436  *                                           a single-token entry.
01437  *
01438  *      Process Explanation:
01439  *          We cannot rely on the "definer" field to indicate whether
01440  *              it is a single-token entry; instead, we will look at
01441  *              the associated function.
01442  *          Keep this routine here to avoid needing to export the names
01443  *              of the permitted functions or their synonymous macros.
01444  *              If we ever need to change it, we can do so at a single
01445  *              point of maintenance.
01446  *          Because the entry might have been found in the initial list
01447  *              of entries to the "FCode-Tokens" list, we need to check
01448  *              whether the associated function is either the general
01449  *              single-token emitting function,  FC_TOKEN_FUNC , or the
01450  *              function  OBSO_FC_FUNC , which presents a message before
01451  *              emitting, but is still a valid single-token function.
01452  *
01453  **************************************************************************** */
01454 
01455 bool entry_is_token( tic_hdr_t *test_entry )
01456 {
01457     bool retval = FALSE;
01458     if ( test_entry != NULL )
01459     {
01460         if ( ( test_entry->funct == FC_TOKEN_FUNC )  ||
01461              ( test_entry->funct ==  OBSO_FC_FUNC )  )
01462         {
01463             retval = TRUE;
01464         }
01465     }
01466     return ( retval );
01467 }
01468 
01469 /* **************************************************************************
01470  *
01471  *      Function name:  token_entry_warning
01472  *      Synopsis:       Issue whatever warnings the given token_entry
01473  *                      requires.  F['] needs this.
01474  *      Inputs:
01475  *         Parameters:
01476  *             test_entry                The entry to test; may be NULL
01477  *         Local macro:
01478  *             OBSO_FC_FUNC              The function associated with
01479  *                                           "obsolete" entries.
01480  *      Outputs:
01481  *         Returned Value:               NONE
01482  *
01483  *      Error Detection:
01484  *          Warnings required by the given token_entry.
01485  *
01486  *      Extraneous Remarks:
01487  *          At present, it's only the "Obsolete" warning.
01488  *          But this is the place to add others, 
01489  *              should they become necessary.
01490  *
01491  **************************************************************************** */
01492 
01493 void token_entry_warning( tic_hdr_t *t_entry)
01494 {
01495     if ( t_entry->funct == OBSO_FC_FUNC )
01496     {
01497         obsolete_warning();
01498     }
01499 }
01500 
01501 
01502 /* **************************************************************************
01503  *
01504  *      Create the initial "FWords" list.
01505  *
01506  **************************************************************************** */
01507 
01508 static tic_fwt_hdr_t fwords_list[] = {
01509 
01510         BI_FWD_SKP_OW(COLON,            ":") ,
01511         BUILTIN_FWORD(SEMICOLON,        ";") ,
01512         BI_FWD_SKP_OW(TICK,             "'") ,
01513         BUILTIN_FWORD(AGAIN,            "again") ,
01514         BI_FWD_SKP_OW(BRACK_TICK,        "[']") ,
01515         BI_FWD_SKP_OW(ASCII,            "ascii") ,
01516         BUILTIN_FWORD(BEGIN,            "begin") ,
01517         BI_FWD_SKP_OW(BUFFER,           "buffer:") ,
01518         BUILTIN_FWORD(CASE,             "case") ,
01519         BI_FWD_SKP_OW(CONST,            "constant") ,
01520         BI_FWD_SKP_OW(CONTROL,          "control") ,
01521         BI_FWD_SKP_OW(CREATE,           "create") ,
01522 
01523         BI_FWD_SKP_OW(DEFER,            "defer") ,
01524         BUILTIN_FWORD(CDO,              "?do") ,
01525         BUILTIN_FWORD(DO,               "do") ,
01526         BUILTIN_FWORD(ELSE,             "else") ,
01527         BUILTIN_FWORD(ENDCASE,          "endcase") ,
01528         BUILTIN_FWORD(ENDOF,            "endof") ,
01529         BUILTIN_FWORD(EXTERNAL,         "external") ,
01530         BI_FWD_SKP_OW(FIELD,            "field") ,
01531         BUILTIN_FWORD(FINISH_DEVICE,    "finish-device" ) ,
01532         BUILTIN_FWORD(HEADERLESS,       "headerless") ,
01533         BUILTIN_FWORD(HEADERS,          "headers") ,
01534 
01535         BUILTIN_FWORD(INSTANCE ,        "instance") ,
01536 
01537         BUILTIN_FWORD(IF,               "if") ,
01538         BUILTIN_FWORD(UNLOOP,           "unloop") ,
01539         BUILTIN_FWORD(LEAVE,            "leave") ,
01540         BUILTIN_FWORD(PLUS_LOOP,        "+loop") ,
01541         BUILTIN_FWORD(LOOP,             "loop") ,
01542 
01543         BUILTIN_FWORD(OF,               "of") ,
01544         BUILTIN_FWORD(REPEAT,           "repeat") ,
01545         BUILTIN_FWORD(THEN,             "then") ,
01546         BI_FWD_SKP_OW(TO,               "to") ,
01547         BI_FWD_SKP_OW(IS,               "is") , /*  Deprecated synonym to TO  */
01548         BUILTIN_FWORD(UNTIL,            "until") ,
01549         BI_FWD_SKP_OW(VALUE,            "value") ,
01550         BI_FWD_SKP_OW(VARIABLE,         "variable") ,
01551         BUILTIN_FWORD(WHILE,            "while") ,
01552         BUILTIN_FWORD(OFFSET16,         "offset16") ,
01553 
01554         BI_FWD_STRING(STRING,           "\"") ,     /*  XXXXX  */
01555         BI_FWD_STRING(PSTRING,          ".\"") ,    /*  XXXXX  */
01556         BI_FWD_STRING(PBSTRING,         ".(") ,     /*  XXXXX  */
01557         BI_FWD_STRING(SSTRING,          "s\"") ,    /*  XXXXX  */
01558         BUILTIN_FWORD(IFILE_NAME,       "[input-file-name]"),
01559         BUILTIN_FWORD(ILINE_NUM,        "[line-number]"),
01560         BUILTIN_FWORD(RECURSE,          "recurse") ,
01561         BUILTIN_FWORD(RECURSIVE,        "recursive") ,
01562         BUILTIN_FWORD(RET_STK_FETCH,    "r@") ,
01563         BUILTIN_FWORD(RET_STK_FROM,     "r>") ,
01564         BUILTIN_FWORD(RET_STK_TO,       ">r") ,
01565         BUILTIN_FWORD(THEN,             "endif" ) ,  /*  Synonym for "then"  */
01566         BUILTIN_FWORD(NEW_DEVICE,       "new-device" ) ,
01567         BUILTIN_FWORD(LOOP_I,           "i") ,
01568         BUILTIN_FWORD(LOOP_J,           "j") ,
01569         /* version1 is also an fcode word, but it 
01570          * needs to trigger some tokenizer internals */
01571         BUILTIN_FWORD(VERSION1,         "version1") ,
01572         BUILTIN_FWORD(START0,           "start0") ,
01573         BUILTIN_FWORD(START1,           "start1") ,
01574         BUILTIN_FWORD(START2,           "start2") ,
01575         BUILTIN_FWORD(START4,           "start4") ,
01576         BUILTIN_FWORD(END0,             "end0") ,
01577         BUILTIN_FWORD(END1,             "end1") ,
01578         BUILTIN_FWORD(FCODE_V1,         "fcode-version1") ,
01579         BUILTIN_FWORD(FCODE_V2,         "fcode-version2") ,
01580         BUILTIN_FWORD(FCODE_V3,         "fcode-version3") ,
01581         BUILTIN_FWORD(FCODE_END,        "fcode-end") ,
01582 
01583         /*  Support for IBM-style Locals  */
01584         BI_FWD_STRING(CURLY_BRACE,      "{") ,
01585         BI_FWD_STRING(DASH_ARROW,       "->") ,
01586         BUILTIN_FWORD(EXIT,             "exit") ,
01587 
01588 
01589         BUILTIN_FWORD(CHAR,             "char") ,
01590         BUILTIN_FWORD(CCHAR,            "[char]") ,
01591         BI_FWD_STRING(ABORTTXT,         "abort\"") ,
01592 
01593         BUILTIN_FWORD(ENCODEFILE,       "encode-file") ,
01594 
01595         BI_IG_FW_HDLR(ESCAPETOK,        "tokenizer[") ,
01596         BI_IG_FW_HDLR(ESCAPETOK,        "f[") ,       /*  An IBM-ish synonym  */
01597 };
01598 
01599 static const int number_of_builtin_fwords =
01600          sizeof(fwords_list)/sizeof(tic_hdr_t);
01601 
01602 /* **************************************************************************
01603  *
01604  *      Create the initial list of "Shared_Words" (words that can
01605  *          be executed similarly both during normal tokenization,
01606  *          and also within "Tokenizer Escape Mode").
01607  *
01608  **************************************************************************** */
01609 
01610 static tic_fwt_hdr_t shared_words_list[] = {
01611         SHARED_FWORD(FLOAD,             "fload") ,
01612         /*  As does the "Allow Multi-Line" directive   */
01613         SHR_SAMIG_FWRD(ALLOW_MULTI_LINE, "multi-line") ,
01614 
01615         SHR_FWD_SKOW( F_BRACK_TICK,      "f[']") ,
01616 
01617         SH_FW_SK2WIL(ALIAS,             "alias") ,
01618         SHARED_FWORD(DECIMAL,           "decimal") ,
01619         SHARED_FWORD(HEX,               "hex") ,
01620         SHARED_FWORD(OCTAL,             "octal") ,
01621         SH_FW_SK_WIL(HEXVAL,            "h#") ,
01622         SH_FW_SK_WIL(DECVAL,            "d#") ,
01623         SH_FW_SK_WIL(OCTVAL,            "o#") ,
01624 
01625         SH_FW_SK_WIL(ASC_NUM,           "a#") ,
01626         SH_FW_SK_WIL(ASC_LEFT_NUM,      "al#") ,
01627 
01628         /* IBM-style extension.  Might be generalizable...  */
01629         SHARED_FWORD(FLITERAL,  "fliteral") ,
01630 
01631         /*  Directives to extract the value of a Command-Line symbol */
01632         SH_FW_SK_WIL(DEFINED,           "[defined]") ,
01633         SH_FW_SK_WIL(DEFINED,           "#defined") ,
01634         SH_FW_SK_WIL(DEFINED,           "[#defined]") ,
01635 
01636         /*  Present the current date or time, either as an  */
01637         /*  in-line string or as a user-generated message.  */
01638         SHARED_FWORD(FCODE_DATE,        "[fcode-date]") ,
01639         SHARED_FWORD(FCODE_TIME,        "[fcode-time]") ,
01640 
01641         /*  Current definition under construction, similarly  */
01642         SHARED_FWORD(FUNC_NAME, "[function-name]"),
01643 
01644         /*  Synonymous forms of the #ELSE and #THEN operators,
01645          *      associated with Conditional-Compilation,
01646          *      allowing for various syntax-styles, and for
01647          *      expansion by alias.
01648          */
01649 
01650         /*  #ELSE  operators */
01651         SHARED_FWORD(CONDL_ELSE,        "#else") ,
01652         SHARED_FWORD(CONDL_ELSE,        "[else]") ,
01653         SHARED_FWORD(CONDL_ELSE,        "[#else]") ,
01654 
01655         /*  #THEN  operators */
01656         SHARED_FWORD(CONDL_ENDER,       "#then") ,
01657         SHARED_FWORD(CONDL_ENDER,       "[then]") ,
01658         SHARED_FWORD(CONDL_ENDER,       "[#then]") ,
01659         /*   #ENDIF variants for users who favor C-style notation   */
01660         SHARED_FWORD(CONDL_ENDER,       "#endif") ,
01661         SHARED_FWORD(CONDL_ENDER,       "[endif]") ,
01662         SHARED_FWORD(CONDL_ENDER,       "[#endif]") ,
01663 
01664 
01665         SHARED_FWORD(OVERLOAD,  "overload" ) ,
01666 
01667         SHARED_FWORD(GLOB_SCOPE , "global-definitions" ) ,
01668         SHARED_FWORD(DEV_SCOPE , "device-definitions" ) ,
01669 
01670         /*  Directives to change a command-line flag value from source   */
01671         SH_FW_SK_WIL(CL_FLAG,   "[FLAG]") ,
01672         SH_FW_SK_WIL(CL_FLAG,   "#FLAG") ,
01673         SH_FW_SK_WIL(CL_FLAG,   "[#FLAG]") ,
01674 
01675         /*  Directives to force display of a command-line flags' values   */
01676         SHARED_FWORD(SHOW_CL_FLAGS,     "[FLAGS]") ,
01677         SHARED_FWORD(SHOW_CL_FLAGS,     "#FLAGS") ,
01678         SHARED_FWORD(SHOW_CL_FLAGS,     "[#FLAGS]") ,
01679         SHARED_FWORD(SHOW_CL_FLAGS,     "SHOW-FLAGS") ,
01680 
01681         /*  Directives to save and retrieve the FCode Assignment number  */
01682         SHARED_FWORD(PUSH_FCODE,        "FCODE-PUSH") ,
01683         SHARED_FWORD(POP_FCODE,         "FCODE-POP") ,
01684 
01685         /*  Directive to reset the FCode Assignment number and
01686          *      re-initialize FCode Range overlap checking.
01687          */
01688         SHARED_FWORD(RESET_FCODE,       "FCODE-RESET") ,
01689 
01690         /* pci header generation is done differently 
01691          * across the available tokenizers. We try to
01692          * be compatible to all of them
01693          */
01694         SHARED_FWORD(PCIHDR,      "pci-header") ,
01695         SHARED_FWORD(PCIEND,      "pci-end") ,           /* SUN syntax */
01696         SHARED_FWORD(PCIEND,      "pci-header-end") ,    /* Firmworks syntax */
01697         SHARED_FWORD(PCIREV,      "pci-revision") ,      /* SUN syntax */
01698         SHARED_FWORD(PCIREV,      "pci-code-revision") , /* SUN syntax */
01699         SHARED_FWORD(PCIREV,      "set-rev-level") ,     /* Firmworks syntax */
01700         SHARED_FWORD(NOTLAST,     "not-last-image") ,
01701         SHARED_FWORD(NOTLAST,     "not-last-img") ,      /* Shorthand form  */
01702         SHARED_FWORD(ISLAST,      "last-image") ,
01703         SHARED_FWORD(ISLAST,      "last-img") ,          /* Shorthand form  */
01704         SHARED_FWORD(SETLAST,     "set-last-image") ,
01705         SHARED_FWORD(SETLAST,     "set-last-img") ,      /* Shorthand form  */
01706 
01707         SH_FW_SK_WIL(SAVEIMG,     "save-image") ,
01708         SH_FW_SK_WIL(SAVEIMG,     "save-img") ,          /* Shorthand form  */
01709 
01710         SHARED_FWORD(RESETSYMBS,  "reset-symbols") ,
01711 
01712         /*  User-Macro definers    */
01713         SHARED_IG_HDLR("[MACRO]", add_user_macro,  0 ,  skip_user_macro) ,
01714 
01715         /*  Comments and Remarks   */
01716         SHARED_IG_HDLR("\\",      process_remark, '\n', process_remark) ,
01717         SHARED_IG_HDLR("(",       process_remark, ')',  process_remark) ,
01718 
01719         /*  Directives to print or discard a user-generated message */
01720         SHARED_IG_HDLR("[MESSAGE]",  user_message, '\n', skip_user_message) ,
01721         SHARED_IG_HDLR("#MESSAGE",   user_message, '\n', skip_user_message) ,
01722         SHARED_IG_HDLR("[#MESSAGE]", user_message, '\n', skip_user_message) ,
01723         SHARED_IG_HDLR("#MESSAGE\"", user_message, '"' , skip_user_message) ,
01724 };
01725 
01726 static const int number_of_shared_words =
01727         sizeof(shared_words_list)/sizeof(tic_hdr_t);
01728 
01729 /* **************************************************************************
01730  *
01731  *      Function name:  lookup_shared_word
01732  *      Synopsis:       Return a pointer to the data-structure of the named
01733  *                      word, only if it is a "Shared Word"
01734  *
01735  *      Inputs:
01736  *         Parameters:
01737  *             tname                     The name to look for
01738  *         Local Static Variables:
01739  *             global_voc_dict_ptr       "Tail" of Global Vocabulary
01740  *
01741  *      Outputs:
01742  *         Returned Value:                Pointer to the data-structure, or
01743  *                                            NULL if not found.
01744  *
01745  *      Process Explanation:
01746  *          The "Shared Words" are scattered among the Global Vocabulary;
01747  *              the user is allowed to create aliases, which may be in the
01748  *              Current-Device.  We will search through the "current" scope
01749  *              and decide whether the name we found is a "Shared Word" by
01750  *              looking for  COMMON_FWORD  in the "definer" field.
01751  *
01752  *      Extraneous Remarks:
01753  *          This is the only place where an additional check of the
01754  *              "definer" field is required to identify a desired entry.
01755  *              Should another "definer"-type be required, I recommend 
01756  *              defining a general-purpose function in  ticvocab.c  and
01757  *              applying it here and in the other place(s).
01758  *
01759  **************************************************************************** */
01760  
01761 tic_hdr_t *lookup_shared_word( char *tname)
01762 {
01763     tic_hdr_t *found ;
01764     tic_hdr_t *retval = NULL ;
01765 
01766     found = lookup_current( tname );
01767     if ( found != NULL )
01768     {
01769         if ( found->fword_defr == COMMON_FWORD )
01770         {
01771             retval = found ;
01772         }
01773     }
01774 
01775     return ( retval );
01776 
01777 }
01778 
01779 /* **************************************************************************
01780  *
01781  *      Function name:  handle_shared_word
01782  *      Synopsis:       Perform the function associated with the given name
01783  *                      only if it is a "Shared Word".  Indicate if it was.
01784  *
01785  *      Inputs:
01786  *         Parameters:
01787  *             tname                The "target" name for which to look
01788  *
01789  *      Outputs:
01790  *         Returned Value:          TRUE if the name is a valid "Shared Word"
01791  *
01792  *      Extraneous Remarks:
01793  *          This is very similar to a call to  handle_tic_vocab() except
01794  *              for the additional filtering for a "Shared Word" definer.
01795  *
01796  **************************************************************************** */
01797 
01798 bool handle_shared_word( char *tname )
01799 {
01800     tic_hdr_t *found ;
01801     bool retval = FALSE;
01802     
01803     found = lookup_shared_word( tname );
01804     if ( found != NULL )
01805     {
01806         found->funct(found->pfield);
01807         retval = TRUE;
01808     }
01809 
01810     return ( retval ) ;
01811 }
01812 
01813 
01814 /* **************************************************************************
01815  *
01816  *      Function name:  lookup_shared_f_exec_word
01817  *      Synopsis:       Return a pointer to the data-structure of the named
01818  *                      word, only if it is a "Shared F-Exec Word"
01819  *
01820  *      Inputs:
01821  *         Parameters:
01822  *             tname                     The name to look for
01823  *         Local Static Variables:
01824  *             global_voc_dict_ptr       "Tail" of Global Vocabulary
01825  *         Macro Definitions:
01826  *             FWORD_EXEC_FUNC           The "Active" function of the
01827  *                                           sub-class of "Shared Word"s
01828  *                                           that is the object of this
01829  *                                           routine's search
01830  *
01831  *      Outputs:
01832  *         Returned Value:                Pointer to the data-structure, or
01833  *                                            NULL if not found.
01834  *
01835  *      Process Explanation:
01836  *          The "Shared F-Exec Words" are the subset of "Shared Words" that
01837  *              have the  FWORD_EXEC_FUNC  as their "Active" function.
01838  *
01839  *      Extraneous Remarks:
01840  *          This is the only routine that requires a check of two fields;
01841  *              it seems unlikely that there will be any need to generalize
01842  *              the core of this routine...
01843  *
01844  **************************************************************************** */
01845  
01846 tic_hdr_t *lookup_shared_f_exec_word( char *tname)
01847 {
01848     tic_hdr_t *found ;
01849     tic_hdr_t *retval = NULL ;
01850 
01851     found = lookup_shared_word( tname );
01852     if ( found != NULL )
01853     {
01854         if ( found->funct == FWORD_EXEC_FUNC )
01855         {
01856             retval = found ;
01857         }
01858     }
01859 
01860     return ( retval );
01861 
01862 }
01863 
01864 /* **************************************************************************
01865  *
01866  *      Function name:  init_dictionary
01867  *      Synopsis:       Initialize all the vocabularies.  For the Global
01868  *                      Vocabulary, fill in the link fields in each of the
01869  *                      otherwise pre-initialized built-in lists, link the
01870  *                      lists together, and set the relevant pointers.   For
01871  *                      other lists, call their initialization routines.
01872  *
01873  *      Inputs:
01874  *         Parameters:                         NONE
01875  *         Global Variables:
01876  *         Local Static Variables:
01877  *             tokens_table                    Base of the "FC-Tokens" list
01878  *             number_of_builtin_tokens        Number of "FC-Token" entries
01879  *             fwords_list                     Base of the "FWords" list
01880  *             number_of_builtin_fwords        Number of "FWord" entries
01881  *             shared_words_list               Base of the "Shared Words" list
01882  *             number_of_shared_words          Number of "Shared Words" entries
01883  *
01884  *      Outputs:
01885  *         Returned Value:                      NONE
01886  *         Local Static Variables:
01887  *             global_voc_dict_ptr              "Tail" of Global Vocabulary
01888  *             fc_tokens_list_start             "Tail" of "FC-Tokens" list
01889  *             fc_tokens_list_ender             End of "FC-Tokens" search
01890  *             shared_fwords_ender              End of Shared Words" search
01891  *             global_voc_reset_ptr             Reset-point for Global Vocab
01892  *
01893  *      Process Explanation:
01894  *          The first linked will be the last searched.
01895  *              Link the "FC-Tokens" first, and mark their limits
01896  *              Link the "FWords" next,
01897  *              Mark the end-limit of the "Shared Words", and link them
01898  *              The "Conditionals", defined in another file, are also "Shared";
01899  *                  link them next.
01900  *              Then link the Built-In Macros, also defined in another file.
01901  *          These constitute the Global Vocabulary.
01902  *              Mark the reset-point for the Global Vocabulary.
01903  *          The "Tokenizer Escape" mode vocabulary is not linked to the Global
01904  *              Vocabulary; call its initialization routine.
01905  *
01906  *      Extraneous Remarks:
01907  *          I only wish I had done this sooner...
01908  *
01909  **************************************************************************** */
01910 
01911 void init_dictionary( void )
01912 {
01913 
01914     global_voc_dict_ptr  = NULL;   /*  Belt-and-suspenders...  */
01915 
01916     /*  The "FC-Tokens" list must be linked first.  */
01917     fc_tokens_list_ender = global_voc_dict_ptr;
01918     init_tic_vocab( tokens_table,
01919                         number_of_builtin_tokens,
01920                             &global_voc_dict_ptr ) ;
01921     fc_tokens_list_start = global_voc_dict_ptr;
01922 
01923     /*  Link the "FWords" next */
01924    init_tic_vocab( (tic_hdr_t *)fwords_list,
01925                         number_of_builtin_fwords,
01926                             &global_voc_dict_ptr ) ;
01927 
01928     /*  Mark the end-limit of the "Shared Words", and link them. */
01929     shared_fwords_ender = global_voc_dict_ptr;
01930     init_tic_vocab( (tic_hdr_t *)shared_words_list,
01931                         number_of_shared_words,
01932                             &global_voc_dict_ptr ) ;
01933 
01934     /*  Link the "Conditionals" to the Global Vocabulary.  */
01935     init_conditionals_vocab( &global_voc_dict_ptr ) ;
01936 
01937     /*  Link the Built-In Macros */
01938     init_macros( &global_voc_dict_ptr ) ;
01939 
01940     /*  Mark the reset-point for the Global Vocabulary.  */
01941     global_voc_reset_ptr = global_voc_dict_ptr;
01942 
01943     /*   Initialize the "Tokenizer Escape" mode vocabulary  */
01944     init_tokz_esc_vocab();
01945 
01946     /*   Locals and Device-Node vocabularies are initially empty  */
01947 
01948 }
01949 
01950 /* **************************************************************************
01951  *
01952  *      Function name:  reset_normal_vocabs
01953  *      Synopsis:       Reset the vocabularies that were created in "Normal"
01954  *                          (as distinguished from "Tokenizer Escape") mode
01955  *                          to the proper state for a fresh tokenization.
01956  *
01957  *      Associated FORTH words:              END0  END1
01958  *      Associated Tokenizer directives:     RESET-SYMBOLS  (in "Normal" mode)
01959  *                                           FCODE-END
01960  *
01961  *      Inputs:
01962  *         Parameters:                NONE
01963  *         Global Variables:
01964  *             global_voc_reset_ptr       Position to which to reset
01965  *                                            the "Global" Vocabulary
01966  *             current_device_node        Vocab struct of current dev-node
01967  *
01968  *      Outputs:
01969  *         Returned Value:            NONE
01970  *         Global Variables:    
01971  *             global_voc_dict_ptr       Reset to "Built-In" position 
01972  *             current_device_node       Reset to point at "root" dev-node
01973  *         Memory Freed
01974  *             All memory allocated by user-definitions in "normal" mode
01975  *             -- Macros, Conditionals and Device-node Vocabularies -- are
01976  *             reset via function call.
01977  *
01978  *      Error Detection:
01979  *          Presence of extra device-node data structure(s) indicates that
01980  *              there were more "new-device" calls than "finish-device";
01981  *              report each as an ERROR 
01982  *
01983  *      Process Explanation:
01984  *          Vocabularies created in other files, that have different
01985  *              data-structures, will have "reset" routines of their
01986  *              own associated with them in the files in which they
01987  *              are created.  Those routines will be called from here.
01988  *          Definitions in the "Tokenizer Escape Vocabulary", i.e.,
01989  *              the one in effect in "Tokenizer Escape" mode, are
01990  *              specifically not touched by this routine.
01991  *
01992  **************************************************************************** */
01993 
01994 void reset_normal_vocabs( void )
01995 {
01996     reset_tic_vocab( &global_voc_dict_ptr, global_voc_reset_ptr );
01997 
01998     /*  Delete the top-level device-node vocab.
01999      *      If there are extra device-nodes,
02000      *      delete their data structures and show errors
02001      */
02002     do
02003     {
02004         if ( current_device_node->parent_node != NULL )
02005         {
02006             tokenization_error( TKERROR,
02007                  "Missing FINISH-DEVICE for new device");
02008             started_at( current_device_node->ifile_name,
02009                  current_device_node->line_no );
02010         }
02011             delete_device_vocab();
02012     }  while ( current_device_node->parent_node != NULL );
02013 
02014 }
02015 
02016 
02017 /* **************************************************************************
02018  *
02019  *      Function name:  reset_vocabs
02020  *      Synopsis:       Reset all the vocabularies to the proper state
02021  *                      for beginning a fresh tokenization, particularly
02022  *                      when multiple files are named on the command-line
02023  *      
02024  *      Inputs:
02025  *         Parameters:                NONE
02026  *
02027  *      Outputs:
02028  *         Returned Value:            NONE
02029  *         Memory Freed
02030  *             All memory allocated by user-definitions will be freed
02031  *
02032  *      Process Explanation:
02033  *          Call the  reset_normal_vocabs()  routine to get the vocabularies
02034  *              that apply to "Normal" mode, then call the "reset" routine
02035  *              for the "Tokenizer Escape Vocabulary", which is supposed
02036  *              to persist across device-nodes but not across input-files
02037  *              named on the command-line.
02038  *
02039  **************************************************************************** */
02040 
02041 void reset_vocabs( void )
02042 {
02043     reset_normal_vocabs();
02044     reset_tokz_esc();
02045 }

Generated on Fri Aug 18 14:03:38 2006 for Toke1.0 by  doxygen 1.4.4