1 /*
2  *                     OpenBIOS - free your system!
3  *                         ( FCode tokenizer )
4  *
5  *  This program is part of a free implementation of the IEEE 1275-1994
6  *  Standard for Boot (Initialization Configuration) Firmware.
7  *
8  *  Copyright (C) 2001-2005 Stefan Reinauer, <stepan@openbios.org>
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; version 2 of the License.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
22  *
23  */
24 
25 /* **************************************************************************
26  *
27  *      Process activity inside "Tokenizer Escape" mode.
28  *
29  *      (C) Copyright 2005 IBM Corporation.  All Rights Reserved.
30  *      Module Author:  David L. Paktor    dlpaktor@us.ibm.com
31  *
32  **************************************************************************** */
33 
34 /* **************************************************************************
35  *
36  *      Functions Exported:
37  *          init_tokz_esc_vocab      Initialize the relevant vocabulary.
38  *          enter_tokz_esc           Enter "Tokenizer Escape" mode
39  *          create_tokz_esc_alias    Add an alias to "Tokenizer Escape" space
40  *          reset_tokz_esc           Reset the "Tokenizer Escape" Vocabulary
41  *                                      to its "Built-In" position.
42  *
43  **************************************************************************** */
44 
45 #include <stdlib.h>
46 #include <string.h>
47 #include <stdio.h>
48 
49 #include "tokzesc.h"
50 #include "ticvocab.h"
51 #include "stack.h"
52 #include "emit.h"
53 #include "stream.h"
54 #include "scanner.h"
55 #include "errhandler.h"
56 #include "strsubvocab.h"
57 #include "nextfcode.h"
58 #include "tracesyms.h"
59 
60 #undef TOKZTEST     /*  Define for testing only; else undef   */
61 #ifdef TOKZTEST         /*  For testing only   */
62    #include "vocabfuncts.h"
63    #include "date_stamp.h"
64 #endif                  /*  For testing only   */
65 
66 /* **************************************************************************
67  *
68  *          Global Variables Imported
69  *              in_tokz_esc    State of the tokenization operation.
70  *                                Value is FALSE if it's operating normally
71  *                                or TRUE if it's in "Tokenizer Escape" mode.
72  *              nextfcode
73  *              statbuf
74  *              dstack         Pointer to current item on top of Data Stack.
75  *              base           Current tokenizer numeric conversion radix
76  *
77  **************************************************************************** */
78 
79 /* **************************************************************************
80  *
81  *      We are going to implement a mini-forth using a strategy based
82  *          on the concept of Threaded Interpretive Code  (well, okay,
83  *          it won't really be interpretive ... )
84  *
85  **************************************************************************** */
86 
87 /* **************************************************************************
88  *
89  *              Internal Static Variables -- (well, almost)
90  *      tokz_esc_vocab        Pointer to "tail" of "Tokenizer Escape" Vocab
91  *
92  *      While we would prefer to keep  tokz_esc_vocab  private to this file,
93  *          we find we need it in one other place, namely, macros.c
94  *      We will declare it "extern" within that file, rather than
95  *          exporting it widely by including it in a  .h  file
96  *
97  **************************************************************************** */
98 
99 /* **************************************************************************
100  *
101  *      We will define and initialize a structure consisting of all the
102  *          functions we initially support for "Tokenizer Escape" mode,
103  *          called  tokz_esc_vocab_tbl  for "Tokenizer Escape Vocab Table".
104  *      I expect we can initialize its body, but I don't think there's a
105  *          convenient way in "C" to initialize its links; we'll have to
106  *          do that dynamically, at run-time.  Oh, well...
107  *
108  *      We'll call the pointer to it the "Tokenizer Escape" Vocabulary.
109  *          We have to declare it here, because we need to refer to it in
110  *          a function that will be entered into the Table.
111  *
112  *      We would like to pre-initialize it; to do so, we would have to
113  *          declare it extern here, then later create its instance and
114  *          assign its initial value.  That would be all well and good,
115  *          except that some linkers don't handle that very well, so, to
116  *          accommodate those, we have to include its initialization in
117  *          the same routine where we initialize the Table's links.
118  *
119  *      Revision History:
120  *          Updated Wed, 04 Jan 2006 by David L. Paktor
121  *          Initialization of tokz_esc_vocab is now included with
122  *              the call to  init_tic_vocab()
123  *
124  **************************************************************************** */
125 
126 tic_hdr_t *tokz_esc_vocab = NULL ;
127 
128 /* **************************************************************************
129  *
130  *      We'll give short prologs to the simpler functions that will be
131  *          used in the "Tokenizer Escape" Vocabulary.
132  *
133  *      All these take, as an argument, the "parameter field" pointer.
134  *          To satisfy C's strong-typing, it will always be declared
135  *          of a consistent type.  The routine itself can internally
136  *          recast -- or ignore -- it, as needed.
137  *      Many of these will refer to the Global Variable  statbuf .  It
138  *          all such cases, it is used for Error reporting.
139  *
140  **************************************************************************** */
141 
142 /* **************************************************************************
143  *
144  *      Function name:  enter_tokz_esc
145  *      Synopsis:       When you start "Tokenizer Escape" mode.
146  *
147  *      Associated Tokenizer directive:        TOKENIZER[
148  *
149  *      Process Explanation:
150  *          Enter "Tokenizer Escape" mode ...  Save the current tokenizer
151  *              numeric conversion radix, and set the radix to sixteen
152  *              (hexadecimal)
153  *
154  **************************************************************************** */
155 
156 static int saved_base ;    /*  Place to save the numeric conversion radix  */
157 
enter_tokz_esc(void)158 void enter_tokz_esc( void )
159 {
160     saved_base = base ;
161     base = 16;
162     in_tokz_esc = TRUE;
163 }
164 
165 /* **************************************************************************
166  *
167  *      Function name:  end_tokz_esc
168  *      Synopsis:       When you've reached the end of "Tokenizer Escape" mode.
169  *
170  *      Associated Tokenizer directive:        ]TOKENIZER
171  *
172  *      Process Explanation:
173  *          Exit "Tokenizer Escape" mode, resume "Normal"-mode behavior.
174  *              Restore the tokenizer numeric conversion radix to the value
175  *              saved by tokenizer[ and exit "Tokenizer Escape" mode . . .
176  *
177  **************************************************************************** */
178 
end_tokz_esc(tic_param_t pfield)179 static void end_tokz_esc( tic_param_t pfield )
180 {
181     in_tokz_esc = FALSE;
182     base = saved_base ;
183 }
184 
185 /* **************************************************************************
186  *
187  *      Function name:  tokz_esc_emit_byte
188  *      Synopsis:       Emit the byte found on the data-stack
189  *
190  *      Associated Tokenizer directive:        EMIT-BYTE
191  *
192  *      Error Detection:
193  *          If number on stack is larger than a byte:  Truncate and Warn
194  *
195  **************************************************************************** */
196 
tokz_esc_emit_byte(tic_param_t pfield)197 static void tokz_esc_emit_byte ( tic_param_t pfield )
198 {
199     long num_on_stk = dpop();
200     u8 byt_to_emit = (u8)num_on_stk;
201     if ( byt_to_emit != num_on_stk )
202     {
203         tokenization_error( WARNING,
204 	    "Value on stack for %s command is 0x%0x.  "
205 		"Truncating to 0x%02x.\n",
206 		     strupr(statbuf), num_on_stk, byt_to_emit);
207     }
208     user_emit_byte(byt_to_emit);
209 }
210 
211 /* **************************************************************************
212  *
213  *      Function name:  get_fcode_from_stack
214  *      Synopsis:       Retrieve an FCode value from the data-stack.
215  *                          Indicate if erroneous
216  *
217  *      Inputs:
218  *         Parameters:
219  *             the_num           Pointer to where to put the number
220  *             setting_fc        TRUE if number is to be set as next fcode,
221  *                                   FALSE if the number is to be emitted
222  *         Data-Stack Items:
223  *             Top:              Value to be retrieved
224  *
225  *      Outputs:
226  *         Returned Value:       TRUE if number is within valid FCode range
227  *         Supplied Pointers:
228  *             *the_num          Value retrieved from the data-stack
229  *
230  *      Process Explanation:
231  *          From the value of   setting_fc  we will deduce both the legal
232  *              minimum and the phrase to be used in the ERROR message.
233  *              If the number is to be emitted, it can be any legal FCode
234  *              token number down to  0x10 but if it is to be set, the
235  *              legal minimum is 0x0800.
236  *          In either case, 0x0fff is the legal maximum.
237  *
238  *      Error Detection:
239  *          If the number on the stack is larger than 16 bits, truncate
240  *              it, with a WARNING message.
241  *          If the (possibly truncated) number taken from the stack is
242  *              larger than the legal maximum for an FCode, or if it is
243  *              less than the legal minimum, issue an ERROR message,
244  *              leave the_num unchanged and return FALSE.
245  *
246  *      Extraneous Remarks:
247  *          If this function is ever used in more than the two ways allowed
248  *              by the  setting_fc  parameter, then the Right Thing would
249  *              be to define a local ENUM type for the possible uses, and
250  *              use a SWITCH statement to set the internal variables.  (But
251  *              I really don't see any way that could become necessary...)
252  *
253  **************************************************************************** */
254 
get_fcode_from_stack(u16 * the_num,bool setting_fc)255 static bool get_fcode_from_stack( u16 *the_num, bool setting_fc)
256 {
257     bool retval = FALSE;
258     char *the_action = "emit FCode value of";
259     u16 legal_minimum = 0x10;
260     long num_on_stk = dpop();
261     u16 test_fcode = (u16)num_on_stk;
262 
263     if ( setting_fc )
264     {
265         the_action = "set next fcode to";
266 	legal_minimum = 0x800;
267     }
268     if ( test_fcode != num_on_stk )
269     {
270         tokenization_error( WARNING,
271 	    "Value on stack for %s command is 0x%0x.  "
272 		"Truncating to 0x%03x.\n",
273 		     strupr(statbuf), num_on_stk, test_fcode);
274     }
275     if ( ( test_fcode >= legal_minimum ) && ( test_fcode <= 0xfff ) )
276     {
277 	retval = TRUE;
278 	*the_num = test_fcode;
279     }else{	tokenization_error( TKERROR, "Attempt to %s "
280 	    "0x%x, which violates limit specified by IEEE-1275.  "
281 		"Disallowing.\n", the_action, test_fcode );
282     }
283     return( retval );
284 }
285 
286 
287 /* **************************************************************************
288  *
289  *      Function name:  tokz_esc_next_fcode
290  *      Synopsis:       Set the next-fcode to the value on the data-stack
291  *
292  *      Associated Tokenizer Directive:          next-fcode
293  *
294  *      Error Detection:
295  *          If the number on the stack is not legal for an FCode, as
296  *              detected by  get_fcode_from_stack(), issue an ERROR
297  *              message and don't change nextfcode.
298  *
299  *         Printout:
300  *             Advisory showing change in FCode token Assignment Counter
301  *
302  **************************************************************************** */
303 
tokz_esc_next_fcode(tic_param_t pfield)304 static void tokz_esc_next_fcode( tic_param_t pfield )
305 {
306     u16 test_fcode;
307 
308     if ( get_fcode_from_stack( &test_fcode, TRUE) )
309     {
310 	if ( test_fcode == nextfcode )
311 	{
312 	    tokenization_error( INFO, "FCode-token Assignment Counter "
313 		"is unchanged from 0x%x.\n",
314 		    nextfcode);
315 	}else{
316 	    tokenization_error( INFO, "FCode-token Assignment Counter "
317 		"was 0x%x; has been %s to 0x%x.\n",
318 		    nextfcode,
319 			test_fcode > nextfcode ? "advanced" : "reset",
320 			    test_fcode );
321 	    set_next_fcode( test_fcode);
322 	}
323     }
324 }
325 
326 /* **************************************************************************
327  *
328  *      Function name:  tokz_emit_fcode
329  *      Synopsis:       Emit the value on the data-stack as an FCode token
330  *
331  *      Associated Tokenizer Directive:          emit-fcode
332  *
333  *      Error Detection:
334  *          If the number on the stack is not legal for an FCode, as
335  *              detected by  get_fcode_from_stack(), issue an ERROR
336  *              message and don't emit anything.
337  *
338  *         Printout:
339  *             Advisory showing FCode being emitted.
340  *
341  **************************************************************************** */
342 
tokz_emit_fcode(tic_param_t pfield)343 static void tokz_emit_fcode( tic_param_t pfield )
344 {
345     u16 test_fcode;
346 
347     if ( get_fcode_from_stack( &test_fcode, FALSE) )
348     {
349 	tokenization_error( INFO,
350 	    "Emitting FCode value of 0x%x\n", test_fcode);
351 	emit_fcode( test_fcode);
352     }
353 }
354 
355 
356 /* **************************************************************************
357  *
358  *      Function name:  zero_equals
359  *      Synopsis:       Boolean-inversion of item on top of stack.
360  *                      If zero, make it minus-one; if non-zero, make it zero.
361  *
362  *      Associated FORTH word-name:          0=
363  *
364  **************************************************************************** */
365 
zero_equals(tic_param_t pfield)366 static void  zero_equals ( tic_param_t pfield )
367 {
368     *dstack = (*dstack == 0) ? -1 : 0 ;
369 }
370 
371 /* **************************************************************************
372  *
373  *      Function name:  tokz_esc_swap
374  *      Synopsis:       "Tokenizer Escape" mode-time data-stack SWAP operation
375  *
376  *      Associated FORTH word-name:          swap
377  *
378  **************************************************************************** */
379 
tokz_esc_swap(tic_param_t pfield)380 static void  tokz_esc_swap ( tic_param_t pfield )
381 {
382     swap();
383 }
384 
385 /* **************************************************************************
386  *
387  *      Function name:  tokz_esc_two_swap
388  *      Synopsis:       "Tokenizer Escape" mode-time data-stack 2SWAP operation
389  *
390  *      Associated FORTH word-name:          2swap
391  *
392  **************************************************************************** */
393 
tokz_esc_two_swap(tic_param_t pfield)394 static void  tokz_esc_two_swap ( tic_param_t pfield )
395 {
396     two_swap();
397 }
398 
399 /* **************************************************************************
400  *
401  *      Function name:  tokz_esc_noop
402  *      Synopsis:       "Tokenizer Escape" mode-time non-operation
403  *
404  *      Associated FORTH word-name:          noop
405  *
406  **************************************************************************** */
407 
tokz_esc_noop(tic_param_t pfield)408 static void  tokz_esc_noop ( tic_param_t pfield )
409 {
410     return;
411 }
412 
413 #ifdef TOKZTEST         /*  For testing only   */
414 
tokz_esc_emit_string(tic_param_t pfield)415    static void  tokz_esc_emit_string( tic_param_t pfield )
416    {
417       int lenny ;
418       lenny = strlen ( pfield.chr_ptr );
419       emit_token("b(\")");
420       emit_string(pfield.chr_ptr, lenny);
421    }
422 
423 #endif                  /*  For testing only   */
424 
425 /* **************************************************************************
426  *
427  *      Function name:  do_constant
428  *      Synopsis:       The function to perform when a named constant
429  *                          that was defined in "Tokenizer Escape" mode
430  *                          is invoked in "Tokenizer Escape" mode
431  *
432  *      Associated FORTH word:                 A user-defined constant
433  *
434  *      Inputs:
435  *         Parameters:
436  *             The param-field of the table-entry contains
437  *                 the value of the constant
438  *
439  *      Outputs:
440  *         Returned Value:         NONE
441  *         Items Pushed onto Data-Stack:
442  *             Top:              The table-entry's param-field's value
443  *
444  *      Error Detection:
445  *          An attempt, while operating in normal tokenization mode, to invoke
446  *              a named constant that was defined in "Tokenizer Escape" mode
447  *              will be detected by the main scanning loop, and need not
448  *              concern us here.
449  *
450  **************************************************************************** */
451 
do_constant(tic_param_t pfield)452 static void do_constant ( tic_param_t pfield )
453 {
454     dpush( pfield.long_val );
455 }
456 
457 /* **************************************************************************
458  *
459  *      Function name:  create_constant
460  *      Synopsis:       Create a user-defined constant that will be
461  *                          recognized in "Tokenizer Escape" mode
462  *
463  *      Associated FORTH word-name:             CONSTANT  (when issued
464  *                                                  in "Tokenizer Escape" mode)
465  *
466  *      Inputs:
467  *         Parameters:                NONE
468  *         Global Variables:
469  *             statbuf         The constant's name will be taken from the
470  *                                 next word in the input stream.
471  *             do_constant     The function assigned to the definition
472  *             tokz_esc_vocab  The "Tokenizer Escape" Vocabulary pointer
473  *         Data-Stack Items:
474  *             Top:            The constant's value is popped from the stack
475  *
476  *      Outputs:
477  *         Returned Value:            NONE
478  *         Global Variables:
479  *             statbuf         Advanced to the next word in the input stream.
480  *             tokz_esc_vocab      Updated to point to new vocab entry.
481  *         Memory Allocated:
482  *             for the name and for the new entry.
483  *         When Freed?
484  *             When RESET-SYMBOLS is issued in "Tokenizer Escape" mode,
485  *                or upon end of tokenization.
486  *         Data-Stack, # of Items Popped:             1
487  *
488  *      Error Detection:
489  *          Failure to allocate memory is a Fatal Error.
490  *          Warning on excessively long name
491  *          Name to be defined not in same file, ERROR
492  *              Warning on duplicate name handled by support routine
493  *
494  *      Process Explanation:
495  *          Get the next word, STRDUP it (which implicitly allocates memory).
496  *              Get the number popped off the stack.
497  *              Pass the pointer and the value to the add_tic_entry() routine.
498  *
499  **************************************************************************** */
500 
create_constant(tic_param_t pfield)501 static void create_constant( tic_param_t pfield )
502 {
503     char *c_name_space ;          /*  Space for copy of the name    */
504     long valu ;                   /*  Value, popped off the stack   */
505     signed long wlen;
506 
507     /*  Get the name that is to be defined  */
508     wlen = get_word();
509     if ( wlen <= 0 )
510     {
511 	warn_unterm( TKERROR, "Constant definition", lineno);
512 	return;
513     }
514 
515     valu = dpop();
516 
517     /*  If ever we implement more than just this one
518      *      defining-word in "Tokenizer Escape" mode,
519      *      the lines from here to the end of the
520      *      routine should be re-factored...
521      */
522     c_name_space = strdup( statbuf );
523 
524     add_tic_entry(
525 	 c_name_space,
526 	     do_constant,
527 		  (TIC_P_DEFLT_TYPE)valu,
528 		       CONST ,
529 			  0 , FALSE , NULL,
530 		               &tokz_esc_vocab );
531 
532     check_name_length( wlen );
533 
534 }
535 
536 /* **************************************************************************
537  *
538  *      Let's create usable named constants for "Tokenizer Escape" mode.
539  *          It's useful, it's easy and ...  well, you get the idea.
540  *
541  **************************************************************************** */
542 /*  I don't think we need to any more
543 static const int zero = 0 ;
544 static const int minus_one = -1 ;
545 static const char double_quote = '"' ;
546 static const char close_paren = ')' ;
547  *  Except for this next one, of course...   */
548 #ifdef TOKZTEST        /*  For testing only   */
549    static const char date_me[] =  DATE_STAMP;
550 #endif                 /*  For testing only   */
551 
552 /* **************************************************************************
553  *
554  *      Here, at long last, we define and initialize the structure containing
555  *          all the functions we support in "Tokenizer Escape" mode.
556  *      Let's call it the "Tokenizer Escape Vocabulary Table" and the
557  *          pointer to it, the "Tokenizer Escape" Vocabulary.
558  *      We can initialize the start of the "Tokenizer Escape" Vocabulary
559  *          easily, except for the link-pointers, as an array.
560  *
561  **************************************************************************** */
562 
563 #define TKZESC_CONST(nam, pval)   \
564                         VALPARAM_TIC(nam, do_constant, pval, CONST, FALSE )
565 #define TKZ_ESC_FUNC(nam, afunc, pval, ifunc)   \
566                         DUALFUNC_TIC(nam, afunc, pval, ifunc, UNSPECIFIED)
567 
568 static tic_hdr_t tokz_esc_vocab_tbl[] = {
569     NO_PARAM_IGN( "]tokenizer" , end_tokz_esc                           ) ,
570 
571     /*  An IBM-ish synonym.  */
572     NO_PARAM_IGN( "f]"         , end_tokz_esc                           ) ,
573     /*  An alternate synonym.  */
574     NO_PARAM_IGN( "]f"         , end_tokz_esc                           ) ,
575 
576     NO_PARAM_TIC( "emit-byte"  , tokz_esc_emit_byte                     ) ,
577     NO_PARAM_TIC( "next-fcode" , tokz_esc_next_fcode                    ) ,
578     NO_PARAM_TIC( "emit-fcode" , tokz_emit_fcode                        ) ,
579     NO_PARAM_TIC( "constant"   , create_constant                        ) ,
580     NO_PARAM_TIC( "0="         , zero_equals                            ) ,
581     NO_PARAM_TIC( "swap"       , tokz_esc_swap                          ) ,
582     NO_PARAM_TIC( "2swap"      , tokz_esc_two_swap                      ) ,
583     NO_PARAM_TIC( "noop"       , tokz_esc_noop                          ) ,
584     TKZESC_CONST( "false"      ,  0                                     ) ,
585     TKZESC_CONST( "true"       , -1                                     ) ,
586     TKZ_ESC_FUNC( ".("         , user_message, ')', skip_user_message   ) ,
587     TKZ_ESC_FUNC( ".\""        , user_message, '"', skip_user_message   ) ,
588 #ifdef TOKZTEST        /*  For testing only   */
589     /*  Data is a pointer to a constant string in the compiler;    */
590     /*      no need to copy, hence data_size can remain zero.      */
591     /*  We could almost use the Macro macro, except for the type.  */
592     TKZ_ESC_FUNC( "emit-date"  , tokz_esc_emit_string, date_me , NULL   ) ,
593 #endif                 /*  For testing only   */
594 };
595 
596 /* **************************************************************************
597  *
598  *      Also, keep a pointer to the "Built-In" position of
599  *          the "Tokenizer Escape" Vocabulary
600  *
601  **************************************************************************** */
602 
603 static const tic_hdr_t *built_in_tokz_esc =
604     &tokz_esc_vocab_tbl[(sizeof(tokz_esc_vocab_tbl)/sizeof(tic_hdr_t))-1];
605 
606 /* **************************************************************************
607  *
608  *      Function name:  init_tokz_esc_vocab
609  *      Synopsis:       Initialize the "Tokenizer Escape" Vocabulary
610  *                          link-pointers dynamically.
611  *
612  *      Process Explanation:
613  *          While this is going on, set  in_tokz_esc  to TRUE; clear it
614  *              when done.  This will be used by the  trace_builtin
615  *              routine...
616  *
617  **************************************************************************** */
618 
init_tokz_esc_vocab(void)619 void init_tokz_esc_vocab ( void )
620 {
621     static const int tokz_esc_vocab_max_indx =
622 	 sizeof(tokz_esc_vocab_tbl)/sizeof(tic_hdr_t) ;
623 
624     in_tokz_esc = TRUE;
625     tokz_esc_vocab = NULL ;   /*  Belt-and-suspenders...  */
626     init_tic_vocab(tokz_esc_vocab_tbl,
627                        tokz_esc_vocab_max_indx,
628 		           &tokz_esc_vocab );
629     in_tokz_esc = FALSE;
630 }
631 
632 /* **************************************************************************
633  *
634  *      Function name:  lookup_tokz_esc
635  *      Synopsis:       Return a pointer to the data-structure of the named
636  *                      word in the"Tokenizer Escape" Vocabulary
637  *
638  *      Inputs:
639  *         Parameters:
640  *             name                 The given name for which to look
641  *         Local Static Variables:
642  *             tokz_esc_vocab       Pointer to "Tokenizer Escape" Vocabulary
643  *
644  *      Outputs:
645  *         Returned Value:     TRUE if name is found,
646  *
647  **************************************************************************** */
648 
lookup_tokz_esc(char * name)649 tic_hdr_t *lookup_tokz_esc(char *name)
650 {
651     tic_hdr_t *retval = lookup_tic_entry( name, tokz_esc_vocab );
652     return ( retval );
653 }
654 
655 
656 /* **************************************************************************
657  *
658  *      Function name:  create_tokz_esc_alias
659  *      Synopsis:       Create an alias in the "Tokenizer Escape" Vocabulary
660  *
661  *      Associated FORTH word:              ALIAS (in "Tokenizer Escape" mode)
662  *
663  *      Inputs:
664  *         Parameters:
665  *             old_name             Name of existing entry
666  *             new_name             New name for which to create an entry
667  *
668  *      Outputs:
669  *         Returned Value:          TRUE if  old_name  found in "Tok Esc" vocab
670  *         Global Variables:
671  *             tokz_esc_vocab       Will point to the new entry
672  *         Memory Allocated:
673  *             Memory for the new entry will be allocated
674  *                 by the support routine
675  *         When Freed?
676  *             When RESET-SYMBOLS is issued in "Tokenizer Escape" mode,
677  *                or upon end of tokenization.
678  *
679  **************************************************************************** */
680 
create_tokz_esc_alias(char * new_name,char * old_name)681 bool create_tokz_esc_alias(char *new_name, char *old_name)
682 {
683     bool retval = create_tic_alias( new_name, old_name, &tokz_esc_vocab );
684     return ( retval );
685 }
686 
687 
688 /* **************************************************************************
689  *
690  *      Function name:  reset_tokz_esc
691  *      Synopsis:       Reset the "Tokenizer Escape" Vocabulary to
692  *                          its "Built-In" position.
693  *
694  *      Associated Tokenizer directive:       RESET-SYMBOLS  (when issued
695  *                                                in "Tokenizer Escape" mode)
696  *
697  *      Inputs:
698  *         Parameters:                 NONE
699  *         Global Variables:
700  *             tokz_esc_vocab      Pointer to "Tokenizer Escape" Vocabulary
701  *             built_in_tokz_esc   Pointer to "Built-In" position
702  *
703  *      Outputs:
704  *         Returned Value:             NONE
705  *         Global Variables:
706  *             tokz_esc_vocab      Reset to "Built-In" position
707  *         Memory Freed
708  *             Memory will be freed by the support routine
709  *
710  **************************************************************************** */
711 
reset_tokz_esc(void)712 void reset_tokz_esc( void )
713 {
714     reset_tic_vocab( &tokz_esc_vocab, (tic_hdr_t *)built_in_tokz_esc);
715 }
716 
717 /* **************************************************************************
718  *
719  *      Function name:  pop_next_fcode
720  *      Synopsis:       Vector off to the  tokz_esc_next_fcode  function,
721  *                      but without the pseudo-param.  A retro-fit...
722  *
723  *      Associated Tokenizer directive:   FCODE-POP  (issued in either mode)
724  *
725  *      Inputs:
726  *         Parameters:                    NONE
727  *         Data-Stack Items:
728  *             Top:                       Next FCode value, presumably saved
729  *                                            by an  FCODE-PUSH  issued earlier.
730  *
731  *      Outputs:
732  *         Returned Value:
733  *         Global Variables:
734  *             nextfcode                  FCode token Assignment Counter
735  *
736  **************************************************************************** */
737 
pop_next_fcode(void)738 void pop_next_fcode( void)
739 {
740    tic_param_t dummy_param;
741    tokz_esc_next_fcode( dummy_param);
742 }
743