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