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

tokzesc.c

Go to the documentation of this file.
00001 /*
00002  *                     OpenBIOS - free your system!
00003  *                         ( FCode tokenizer )
00004  *
00005  *  This program is part of a free implementation of the IEEE 1275-1994
00006  *  Standard for Boot (Initialization Configuration) Firmware.
00007  *
00008  *  Copyright (C) 2001-2005 Stefan Reinauer, <stepan@openbios.org>
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; version 2 of the License.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program; if not, write to the Free Software
00021  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
00022  *
00023  */
00024 
00025 /* **************************************************************************
00026  *
00027  *      Process activity inside "Tokenizer Escape" mode.
00028  *
00029  *      (C) Copyright 2005 IBM Corporation.  All Rights Reserved.
00030  *      Module Author:  David L. Paktor    dlpaktor@us.ibm.com
00031  *
00032  **************************************************************************** */
00033 
00034 /* **************************************************************************
00035  *
00036  *      Functions Exported:
00037  *          init_tokz_esc_vocab      Initialize the relevant vocabulary.
00038  *          enter_tokz_esc           Enter "Tokenizer Escape" mode
00039  *          handle_tokz_esc          Perform a function in the
00040  *                                       "Tokenizer Escape" Vocabulary
00041  *          exists_in_tokz_esc       Confirm whether a given name exists in 
00042  *                                       the "Tokz_Esc_Vocabulary"
00043  *          create_tokz_esc_alias    Add an alias to "Tokenizer Escape" space
00044  *          reset_tokz_esc           Reset the "Tokenizer Escape" Vocabulary
00045  *                                      to its "Built-In" position.
00046  *
00047  **************************************************************************** */
00048 
00049 #include <stdlib.h>
00050 #include <string.h>
00051 #include <stdio.h>
00052 #include "ticvocab.h"
00053 #include "tokzesc.h"
00054 #include "stack.h"
00055 #include "emit.h"
00056 #include "stream.h"
00057 #include "scanner.h"
00058 #include "errhandler.h"
00059 #include "strsubvocab.h"
00060 #include "nextfcode.h"
00061 
00062 #undef TOKZTEST     /*  Define for testing only; else undef   */
00063 #ifdef TOKZTEST         /*  For testing only   */
00064    #include "vocabfuncts.h"
00065    #include "date_stamp.h"
00066 #endif                  /*  For testing only   */
00067 
00068 /* **************************************************************************
00069  *
00070  *          Global Variables Imported
00071  *              in_tokz_esc    State of the tokenization operation.
00072  *                                Value is FALSE if it's operating normally
00073  *                                or TRUE if it's in "Tokenizer Escape" mode.
00074  *              nextfcode  
00075  *              statbuf    
00076  *              dstack         Pointer to current item on top of Data Stack.   
00077  *              base           Current tokenizer numeric conversion radix
00078  *
00079  **************************************************************************** */
00080 
00081 /* **************************************************************************
00082  *
00083  *      We are going to implement a mini-forth using a strategy based
00084  *          on the concept of Threaded Interpretive Code  (well, okay,
00085  *          it won't really be interpretive ... )
00086  *
00087  **************************************************************************** */
00088 
00089 /* **************************************************************************
00090  *
00091  *              Internal Static Variables -- (well, almost)
00092  *      tokz_esc_vocab        Pointer to "tail" of "Tokenizer Escape" Vocab
00093  *
00094  *      While we would prefer to keep  tokz_esc_vocab  private to this file,
00095  *          we find we need it in one other place, namely, macros.c
00096  *      We will declare it "extern" within that file, rather than
00097  *          exporting it widely by including it in a  .h  file
00098  *
00099  **************************************************************************** */
00100 
00101 /* **************************************************************************
00102  *
00103  *      We will define and initialize a structure consisting of all the
00104  *          functions we initially support for "Tokenizer Escape" mode,
00105  *          called  tokz_esc_vocab_tbl  for "Tokenizer Escape Vocab Table".
00106  *      I expect we can initialize its body, but I don't think there's a
00107  *          convenient way in "C" to initialize its links; we'll have to
00108  *          do that dynamically, at run-time.  Oh, well...
00109  *
00110  *      We'll call the pointer to it the "Tokenizer Escape" Vocabulary.
00111  *          We have to declare it here, because we need to refer to it in
00112  *          a function that will be entered into the Table.
00113  *
00114  *      We would like to pre-initialize it; to do so, we would have to
00115  *          declare it extern here, then later create its instance and
00116  *          assign its initial value.  That would be all well and good,
00117  *          except that some linkers don't handle that very well, so, to
00118  *          accommodate those, we have to include its initialization in
00119  *          the same routine where we initialize the Table's links.
00120  *
00121  *      Revision History:
00122  *          Updated Wed, 04 Jan 2006 by David L. Paktor
00123  *          Initialization of tokz_esc_vocab is now included with
00124  *              the call to  init_tic_vocab()
00125  *
00126  **************************************************************************** */
00127 
00128 tic_hdr_t *tokz_esc_vocab = NULL ;
00129 
00130 /* **************************************************************************
00131  *
00132  *      We'll give short prologs to the simpler functions that will be
00133  *          used in the "Tokenizer Escape" Vocabulary.
00134  *
00135  *      All these take, as an argument, the "parameter field" pointer.
00136  *          To satisfy C's strong-typing, it will always be declared
00137  *          of a consistent type.  The routine itself can internally
00138  *          recast -- or ignore -- it, as needed.
00139  *      Many of these will refer to the Global Variable  statbuf .  It
00140  *          all such cases, it is used for Error reporting.
00141  *
00142  **************************************************************************** */
00143 
00144 /* **************************************************************************
00145  *
00146  *      Function name:  enter_tokz_esc
00147  *      Synopsis:       When you start "Tokenizer Escape" mode.
00148  *
00149  *      Associated Tokenizer directive:        TOKENIZER[
00150  *
00151  *      Process Explanation:
00152  *          Enter "Tokenizer Escape" mode ...  Save the current tokenizer
00153  *              numeric conversion radix, and set the radix to sixteen
00154  *              (hexadecimal)
00155  *
00156  **************************************************************************** */
00157 
00158 static int saved_base ;    /*  Place to save the numeric conversion radix  */
00159 
00160 void enter_tokz_esc( void )
00161 {
00162     saved_base = base ;
00163     base = 16;
00164     in_tokz_esc = TRUE;
00165 }
00166 
00167 /* **************************************************************************
00168  *
00169  *      Function name:  end_tokz_esc
00170  *      Synopsis:       When you've reached the end of "Tokenizer Escape" mode.
00171  *
00172  *      Associated Tokenizer directive:        ]TOKENIZER
00173  *
00174  *      Process Explanation:
00175  *          Exit "Tokenizer Escape" mode, resume "Normal"-mode behavior.
00176  *              Restore the tokenizer numeric conversion radix to the value
00177  *              saved by tokenizer[ and exit "Tokenizer Escape" mode . . .
00178  *
00179  **************************************************************************** */
00180 
00181 static void end_tokz_esc( tic_param_t pfield )
00182 {
00183     in_tokz_esc = FALSE;
00184     base = saved_base ;
00185 }
00186 
00187 /* **************************************************************************
00188  *
00189  *      Function name:  tokz_esc_emit_byte
00190  *      Synopsis:       Emit the byte found on the data-stack
00191  *                      
00192  *      Associated Tokenizer directive:        EMIT-BYTE
00193  *                      
00194  *      Error Detection:
00195  *          If number on stack is larger than a byte:  Truncate and Warn
00196  *
00197  **************************************************************************** */
00198 
00199 static void tokz_esc_emit_byte ( tic_param_t pfield )
00200 {
00201     long num_on_stk = dpop();
00202     u8 byt_to_emit = (u8)num_on_stk;
00203     if ( byt_to_emit != num_on_stk )
00204     {
00205         tokenization_error( WARNING,
00206             "Value on stack for %s command is 0x%0x.  "
00207                 "Truncating to 0x%02x.\n",
00208                      strupr(statbuf), num_on_stk, byt_to_emit);
00209     }
00210     user_emit_byte(byt_to_emit);
00211 }
00212 
00213 /* **************************************************************************
00214  *
00215  *      Function name:  get_fcode_from_stack
00216  *      Synopsis:       Retrieve an FCode value from the data-stack.
00217  *                          Indicate if erroneous
00218  *
00219  *      Inputs:
00220  *         Parameters:
00221  *             the_num           Pointer to where to put the number
00222  *             the_action        Phrase to be used in ERROR message
00223  *         Data-Stack Items:
00224  *             Top:              Value to be retrieved
00225  *
00226  *      Outputs:
00227  *         Returned Value:       TRUE if number is within valid FCode range
00228  *         Supplied Pointers:
00229  *             *the_num          Value retrieved from the data-stack
00230  *
00231  *      Error Detection:
00232  *          If the number on the stack is larger than 16 bits, truncate
00233  *              it, with a WARNING message.
00234  *          If the (possibly truncated) number from the stack is larger
00235  *              than the legal maximum for an FCode (0x0fff), or
00236  *              less than the legal minimum (0x0800), issue an ERROR,
00237  *              leave the_num unchanged and return FALSE.
00238  *
00239  **************************************************************************** */
00240 
00241 static bool get_fcode_from_stack( u16 *the_num, char *the_action)
00242 {
00243     bool retval = FALSE;
00244     long num_on_stk = dpop();
00245     u16 test_fcode = (u16)num_on_stk;
00246     if ( test_fcode != num_on_stk )
00247     {
00248         tokenization_error( WARNING,
00249             "Value on stack for %s command is 0x%0x.  "
00250                 "Truncating to 0x%03x.\n",
00251                      strupr(statbuf), num_on_stk, test_fcode);
00252     }
00253     if ( ( test_fcode >= 0x800 ) && ( test_fcode <= 0xfff ) )
00254     {
00255         retval = TRUE;
00256         *the_num = test_fcode;
00257     }else{      tokenization_error( TKERROR, "Attempt to %s "
00258             "0x%x, which violates limit specified by IEEE-1275.  "
00259                 "Disallowing.\n", the_action, test_fcode );
00260     }
00261     return( retval );
00262 }
00263 
00264 
00265 /* **************************************************************************
00266  *
00267  *      Function name:  tokz_esc_next_fcode
00268  *      Synopsis:       Set the next-fcode to the value on the data-stack
00269  *                      
00270  *      Associated Tokenizer Directive:          next-fcode
00271  *                      
00272  *      Error Detection:
00273  *          If the number on the stack is not legal for an FCode, as
00274  *              detected by  get_fcode_from_stack(), issue an ERROR
00275  *              message and don't change nextfcode.
00276  *
00277  *         Printout:
00278  *             Advisory showing change in FCode token Assignment Counter
00279  *
00280  **************************************************************************** */
00281 
00282 static void tokz_esc_next_fcode( tic_param_t pfield )
00283 {
00284     u16 test_fcode;
00285 
00286     if ( get_fcode_from_stack( &test_fcode, "set next fcode to") )
00287     {
00288         if ( test_fcode == nextfcode )
00289         {
00290             tokenization_error( INFO, "FCode-token Assignment Counter "
00291                 "is unchanged from 0x%x.\n",
00292                     nextfcode);
00293         }else{
00294             tokenization_error( INFO, "FCode-token Assignment Counter "
00295                 "was 0x%x; has been %s to 0x%x.\n",
00296                     nextfcode,
00297                         test_fcode > nextfcode ? "advanced" : "reset",
00298                             test_fcode );
00299             set_next_fcode( test_fcode);
00300         }
00301     }
00302 }
00303 
00304 /* **************************************************************************
00305  *
00306  *      Function name:  tokz_emit_fcode
00307  *      Synopsis:       Emit the value on the data-stack as an FCode token
00308  *                      
00309  *      Associated Tokenizer Directive:          emit-fcode
00310  *                      
00311  *      Error Detection:
00312  *          If the number on the stack is not legal for an FCode, as
00313  *              detected by  get_fcode_from_stack(), issue an ERROR
00314  *              message and don't emit anything.
00315  *
00316  *         Printout:
00317  *             Advisory showing FCode being emitted.
00318  *
00319  **************************************************************************** */
00320 
00321 static void tokz_emit_fcode( tic_param_t pfield )
00322 {
00323     u16 test_fcode;
00324 
00325     if ( get_fcode_from_stack( &test_fcode, "Emit FCode value of") )
00326     {
00327         tokenization_error( INFO,
00328             "Emitting FCode value of 0x%x\n", test_fcode);
00329         emit_fcode( test_fcode);
00330     }
00331 }
00332 
00333 
00334 /* **************************************************************************
00335  *
00336  *      Function name:  zero_equals
00337  *      Synopsis:       Boolean-inversion of item on top of stack.
00338  *                      If zero, make it minus-one; if non-zero, make it zero. 
00339  *
00340  *      Associated FORTH word-name:          0=
00341  *
00342  **************************************************************************** */
00343 
00344 static void  zero_equals ( tic_param_t pfield )
00345 {
00346     *dstack = (*dstack == 0) ? -1 : 0 ;
00347 }
00348 
00349 /* **************************************************************************
00350  *
00351  *      Function name:  tokz_esc_swap
00352  *      Synopsis:       "Tokenizer Escape" mode-time data-stack SWAP operation
00353  *                      
00354  *      Associated FORTH word-name:          swap
00355  *
00356  **************************************************************************** */
00357 
00358 static void  tokz_esc_swap ( tic_param_t pfield )
00359 {
00360     swap();
00361 }
00362 
00363 /* **************************************************************************
00364  *
00365  *      Function name:  tokz_esc_two_swap
00366  *      Synopsis:       "Tokenizer Escape" mode-time data-stack 2SWAP operation
00367  *                      
00368  *      Associated FORTH word-name:          2swap
00369  *
00370  **************************************************************************** */
00371 
00372 static void  tokz_esc_two_swap ( tic_param_t pfield )
00373 {
00374     two_swap();
00375 }
00376 
00377 /* **************************************************************************
00378  *
00379  *      Function name:  tokz_esc_noop
00380  *      Synopsis:       "Tokenizer Escape" mode-time non-operation
00381  *                      
00382  *      Associated FORTH word-name:          noop
00383  *
00384  **************************************************************************** */
00385 
00386 static void  tokz_esc_noop ( tic_param_t pfield )
00387 {
00388     return;
00389 }
00390 
00391 #ifdef TOKZTEST         /*  For testing only   */
00392 
00393    static void  tokz_esc_emit_string( tic_param_t pfield )
00394    {
00395       int lenny ;
00396       lenny = strlen ( pfield.chr_ptr );
00397       emit_token("b(\")");
00398       emit_string(pfield.chr_ptr, lenny);
00399    }
00400 
00401 #endif                  /*  For testing only   */
00402 
00403 /* **************************************************************************
00404  *
00405  *      Function name:  do_constant
00406  *      Synopsis:       The function to perform when a named constant
00407  *                          that was defined in "Tokenizer Escape" mode
00408  *                          is invoked in "Tokenizer Escape" mode
00409  *
00410  *      Associated FORTH word:                 A user-defined constant
00411  *      
00412  *      Inputs:
00413  *         Parameters:
00414  *             The param-field of the table-entry contains
00415  *                 the value of the constant
00416  *
00417  *      Outputs:
00418  *         Returned Value:         NONE
00419  *         Items Pushed onto Data-Stack:
00420  *             Top:              The table-entry's param-field's value
00421  *
00422  *      Error Detection:
00423  *          An attempt, while operating in normal tokenization mode, to invoke
00424  *              a named constant that was defined in "Tokenizer Escape" mode
00425  *              will be detected by the main scanning loop, and need not
00426  *              concern us here.
00427  *
00428  **************************************************************************** */
00429 
00430 static void do_constant ( tic_param_t pfield )
00431 {
00432     dpush( pfield.long_val );
00433 }
00434 
00435 /* **************************************************************************
00436  *
00437  *      Function name:  create_constant
00438  *      Synopsis:       Create a user-defined constant that will be
00439  *                          recognized in "Tokenizer Escape" mode
00440  *
00441  *      Associated FORTH word-name:             CONSTANT  (when issued
00442  *                                                  in "Tokenizer Escape" mode)
00443  *
00444  *      Inputs:
00445  *         Parameters:                NONE
00446  *         Global Variables:
00447  *             statbuf         The constant's name will be taken from the
00448  *                                 next word in the input stream.
00449  *             do_constant     The function assigned to the definition
00450  *             tokz_esc_vocab  The "Tokenizer Escape" Vocabulary pointer
00451  *         Data-Stack Items:
00452  *             Top:            The constant's value is popped from the stack
00453  *
00454  *      Outputs:
00455  *         Returned Value:            NONE
00456  *         Global Variables:
00457  *             statbuf         Advanced to the next word in the input stream.
00458  *             tokz_esc_vocab      Updated to point to new vocab entry.
00459  *         Memory Allocated:
00460  *             for the name and for the new entry.
00461  *         When Freed?
00462  *             When RESET-SYMBOLS is issued in "Tokenizer Escape" mode,
00463  *                or upon end of tokenization.
00464  *         Data-Stack, # of Items Popped:             1
00465  *
00466  *      Error Detection:
00467  *          Failure to allocate memory is a Fatal Error.
00468  *          Warning on excessively long name
00469  *          Warning on duplicate name
00470  *          Name to be defined not in same file, ERROR
00471  *
00472  *      Process Explanation:
00473  *          Get the next word, STRDUP it (which implicitly allocates memory). 
00474  *              Get the number popped off the stack.
00475  *              Pass the pointer and the value to the add_tic_entry() routine.
00476  *
00477  **************************************************************************** */
00478 
00479 static void create_constant( tic_param_t pfield )
00480 {
00481     char *c_name_space ;          /*  Space for copy of the name    */
00482     long valu ;                   /*  Value, popped off the stack   */
00483     signed long wlen;
00484 
00485     /*  Get the name that is to be defined  */
00486     wlen = get_word();
00487     if ( wlen <= 0 )
00488     {
00489         warn_unterm( TKERROR, "Constant definition", lineno);
00490         return;
00491     }
00492 
00493     valu = dpop();
00494 
00495     /*  If ever we implement more than just this one
00496      *      defining-word in "Tokenizer Escape" mode,
00497      *      the lines from here to the end of the
00498      *      routine should be re-factored...
00499      */
00500     trace_creation( CONST, statbuf);
00501 
00502     warn_if_duplicate( statbuf );
00503     check_name_length( wlen );
00504 
00505     c_name_space = strdup( statbuf );
00506 
00507     add_tic_entry(
00508          c_name_space,
00509              do_constant,
00510                   (TIC_P_DEFLT_TYPE)valu,
00511                        CONST ,
00512                            0 , NULL,
00513                                &tokz_esc_vocab );
00514 
00515 }
00516 
00517 /* **************************************************************************
00518  *
00519  *      Let's create usable named constants for "Tokenizer Escape" mode.
00520  *          It's useful, it's easy and ...  well, you get the idea.
00521  *
00522  **************************************************************************** */
00523 /*  I don't think we need to any more
00524 static const int zero = 0 ;
00525 static const int minus_one = -1 ;
00526 static const char double_quote = '"' ;
00527 static const char close_paren = ')' ;
00528  *  Except for this next one, of course...   */
00529 #ifdef TOKZTEST        /*  For testing only   */
00530    static const char date_me[] =  DATE_STAMP;
00531 #endif                 /*  For testing only   */
00532 
00533 /* **************************************************************************
00534  *
00535  *      Here, at long last, we define and initialize the structure containing
00536  *          all the functions we support in "Tokenizer Escape" mode.
00537  *      Let's call it the "Tokenizer Escape Vocabulary Table" and the
00538  *          pointer to it, the "Tokenizer Escape" Vocabulary.
00539  *      We can initialize the start of the "Tokenizer Escape" Vocabulary
00540  *          easily, except for the link-pointers, as an array.
00541  *
00542  **************************************************************************** */
00543 
00544 #define TKZESC_CONST(nam, pval)   \
00545                         VALPARAM_TIC(nam, do_constant, pval, CONST )
00546 #define TKZ_ESC_FUNC(nam, afunc, pval, ifunc)   \
00547                         DUALFUNC_TIC(nam, afunc, pval, ifunc, UNSPECIFIED)
00548 
00549 static tic_hdr_t tokz_esc_vocab_tbl[] = {
00550     NO_PARAM_IGN( "]tokenizer" , end_tokz_esc                           ) ,
00551 
00552     /*  An IBM-ish synonym.  */
00553     NO_PARAM_IGN( "f]"         , end_tokz_esc                           ) ,
00554     /*  An alternate synonym.  */
00555     NO_PARAM_IGN( "]f"         , end_tokz_esc                           ) ,
00556 
00557     NO_PARAM_TIC( "emit-byte"  , tokz_esc_emit_byte                     ) ,
00558     NO_PARAM_TIC( "next-fcode" , tokz_esc_next_fcode                    ) ,
00559     NO_PARAM_TIC( "emit-fcode" , tokz_emit_fcode                        ) ,
00560     NO_PARAM_TIC( "constant"   , create_constant                        ) ,
00561     NO_PARAM_TIC( "0="         , zero_equals                            ) ,
00562     NO_PARAM_TIC( "swap"       , tokz_esc_swap                          ) ,
00563     NO_PARAM_TIC( "2swap"      , tokz_esc_two_swap                      ) ,
00564     NO_PARAM_TIC( "noop"       , tokz_esc_noop                          ) ,
00565     TKZESC_CONST( "false"      ,  0                                     ) ,
00566     TKZESC_CONST( "true"       , -1                                     ) ,
00567     TKZ_ESC_FUNC( ".("         , user_message, ')', skip_user_message   ) ,
00568     TKZ_ESC_FUNC( ".\""        , user_message, '"', skip_user_message   ) ,
00569 #ifdef TOKZTEST        /*  For testing only   */
00570     /*  Data is a pointer to a constant string in the compiler;    */
00571     /*      no need to copy, hence data_size can remain zero.      */
00572     /*  We could almost use the Macro macro, except for the type.  */
00573     TKZ_ESC_FUNC( "emit-date"  , tokz_esc_emit_string, date_me , NULL   ) ,
00574 #endif                 /*  For testing only   */
00575 };
00576 
00577 /* **************************************************************************
00578  *
00579  *      Also, keep a pointer to the "Built-In" position of
00580  *          the "Tokenizer Escape" Vocabulary
00581  *
00582  **************************************************************************** */
00583 
00584 static const tic_hdr_t *built_in_tokz_esc =
00585     &tokz_esc_vocab_tbl[(sizeof(tokz_esc_vocab_tbl)/sizeof(tic_hdr_t))-1];
00586 
00587 /* **************************************************************************
00588  *
00589  *      Function name:  init_tokz_esc_vocab
00590  *      Synopsis:       Initialize the "Tokenizer Escape" Vocabulary
00591  *                          link-pointers dynamically.
00592  *
00593  **************************************************************************** */
00594 
00595 void init_tokz_esc_vocab ( void )
00596 {
00597     static const int tokz_esc_vocab_max_indx =
00598          sizeof(tokz_esc_vocab_tbl)/sizeof(tic_hdr_t) ;
00599 
00600     tokz_esc_vocab = NULL ;   /*  Belt-and-suspenders...  */
00601     init_tic_vocab(tokz_esc_vocab_tbl,
00602                        tokz_esc_vocab_max_indx,
00603                            &tokz_esc_vocab );
00604 }
00605 
00606 /* **************************************************************************
00607  *
00608  *      Function name:  handle_tokz_esc
00609  *      Synopsis:       Perform a function in the "Tokenizer Escape" Vocabulary
00610  *                      Indicate whether the name is valid in this vocabulary.
00611  *                      Handle "Tokenizer Escape" aliases implicitly.
00612  *
00613  *      Inputs:
00614  *         Parameters:
00615  *             tname                The name to handle
00616  *         Global Variables:  
00617  *             tokz_esc_vocab       Pointer to "Tokenizer Escape" Vocabulary 
00618  *
00619  *      Outputs:
00620  *         Returned Value:   TRUE if the given name is valid in tokz_esc
00621  *
00622  *      Process Explanation:
00623  *          Find the name and execute its associated function.
00624  *          If the name is not in the "Tokenizer Escape" Vocabulary,
00625  *              let the calling routine determine whether to try it
00626  *              out as a number or to print an error message.
00627  *
00628  **************************************************************************** */
00629 
00630 bool handle_tokz_esc( char *tname )
00631 {
00632     bool retval = handle_tic_vocab( tname, tokz_esc_vocab );
00633     return ( retval ) ;
00634 }
00635 
00636 
00637 /* **************************************************************************
00638  *
00639  *      Function name:  lookup_tokz_esc
00640  *      Synopsis:       Return a pointer to the data-structure of the named
00641  *                      word in the"Tokenizer Escape" Vocabulary
00642  *
00643  *      Inputs:
00644  *         Parameters:
00645  *             name                 The given name for which to look
00646  *         Local Static Variables:
00647  *             tokz_esc_vocab       Pointer to "Tokenizer Escape" Vocabulary  
00648  *
00649  *      Outputs:
00650  *         Returned Value:     TRUE if name is found,
00651  *
00652  **************************************************************************** */
00653 
00654 tic_hdr_t *lookup_tokz_esc(char *name)
00655 {
00656     tic_hdr_t *retval = lookup_tic_entry( name, tokz_esc_vocab );
00657     return ( retval );
00658 }
00659 
00660 
00661 /* **************************************************************************
00662  *
00663  *      Function name:  exists_in_tokz_esc
00664  *      Synopsis:       Confirm whether a given name exists in the
00665  *                          "Tokenizer Escape" Vocabulary
00666  *
00667  *      Inputs:
00668  *         Parameters:
00669  *             name                 The given name to confirm
00670  *         Global Variables:  
00671  *             tokz_esc_vocab       Pointer to "Tokenizer Escape" Vocabulary  
00672  *
00673  *      Outputs:
00674  *         Returned Value:     TRUE if name is found,
00675  *
00676  **************************************************************************** */
00677 
00678 bool exists_in_tokz_esc(char *name)
00679 {
00680     bool retval = exists_in_tic_vocab( name, tokz_esc_vocab );
00681     return ( retval );
00682 }
00683 
00684 
00685 /* **************************************************************************
00686  *
00687  *      Function name:  create_tokz_esc_alias
00688  *      Synopsis:       Create an alias in the "Tokenizer Escape" Vocabulary
00689  *
00690  *      Associated FORTH word:              ALIAS (in "Tokenizer Escape" mode)
00691  *
00692  *      Inputs:
00693  *         Parameters:
00694  *             old_name             Name of existing entry
00695  *             new_name             New name for which to create an entry
00696  *
00697  *      Outputs:
00698  *         Returned Value:          TRUE if  old_name  found in "Tok Esc" vocab
00699  *         Global Variables:    
00700  *             tokz_esc_vocab       Will point to the new entry
00701  *         Memory Allocated:
00702  *             Memory for the new entry will be allocated
00703  *                 by the support routine
00704  *         When Freed?
00705  *             When RESET-SYMBOLS is issued in "Tokenizer Escape" mode,
00706  *                or upon end of tokenization.
00707  *
00708  **************************************************************************** */
00709 
00710 bool create_tokz_esc_alias(char *new_name, char *old_name)
00711 {
00712     bool retval = create_tic_alias( new_name, old_name, &tokz_esc_vocab );
00713     return ( retval );
00714 }
00715 
00716 
00717 /* **************************************************************************
00718  *
00719  *      Function name:  reset_tokz_esc
00720  *      Synopsis:       Reset the "Tokenizer Escape" Vocabulary to
00721  *                          its "Built-In" position.
00722  *
00723  *      Associated Tokenizer directive:       RESET-SYMBOLS  (when issued
00724  *                                                in "Tokenizer Escape" mode)
00725  *
00726  *      Inputs:
00727  *         Parameters:                 NONE
00728  *         Global Variables:
00729  *             tokz_esc_vocab      Pointer to "Tokenizer Escape" Vocabulary
00730  *             built_in_tokz_esc   Pointer to "Built-In" position
00731  *
00732  *      Outputs:
00733  *         Returned Value:             NONE
00734  *         Global Variables:
00735  *             tokz_esc_vocab      Reset to "Built-In" position
00736  *         Memory Freed
00737  *             Memory will be freed by the support routine
00738  *
00739  **************************************************************************** */
00740 
00741 void reset_tokz_esc( void )
00742 {
00743     reset_tic_vocab( &tokz_esc_vocab, (tic_hdr_t *)built_in_tokz_esc);
00744 }
00745 
00746 /* **************************************************************************
00747  *
00748  *      Function name:  pop_next_fcode
00749  *      Synopsis:       Vector off to the  tokz_esc_next_fcode  function,
00750  *                      but without the pseudo-param.  A retro-fit...
00751  *
00752  *      Associated Tokenizer directive:   FCODE-POP  (issued in either mode)
00753  *
00754  *      Inputs:
00755  *         Parameters:                    NONE
00756  *         Data-Stack Items:
00757  *             Top:                       Next FCode value, presumably saved
00758  *                                            by an  FCODE-PUSH  issued earlier.
00759  *
00760  *      Outputs:
00761  *         Returned Value: 
00762  *         Global Variables:
00763  *             nextfcode                  FCode token Assignment Counter
00764  *
00765  **************************************************************************** */
00766 
00767 void pop_next_fcode( void)
00768 {
00769    tic_param_t dummy_param;
00770    tokz_esc_next_fcode( dummy_param);
00771 }

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