File: lexi.c

package info (click to toggle)
indent 2.2.12-4%2Bdeb12u3
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 5,980 kB
  • sloc: ansic: 37,897; sh: 5,187; makefile: 708; yacc: 291; sed: 16; cpp: 5
file content (728 lines) | stat: -rw-r--r-- 19,413 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
/* Copyright (c) 1992, Free Software Foundation, Inc.  All rights reserved.

   Copyright (c) 1985 Sun Microsystems, Inc. Copyright (c) 1980 The Regents
   of the University of California. Copyright (c) 1976 Board of Trustees of
   the University of Illinois. All rights reserved.

   Redistribution and use in source and binary forms are permitted
   provided that
   the above copyright notice and this paragraph are duplicated in all such
   forms and that any documentation, advertising materials, and other
   materials related to such distribution and use acknowledge that the
   software was developed by the University of California, Berkeley, the
   University of Illinois, Urbana, and Sun Microsystems, Inc.  The name of
   either University or Sun Microsystems may not be used to endorse or
   promote products derived from this software without specific prior written
   permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES
   OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */


/* Here we have the token scanner for indent.  It scans off one token and
   puts it in the global variable "token".  It returns a code, indicating the
   type of token scanned. */

#include "sys.h"
#include "indent.h"
#include <ctype.h>

/* Stuff that needs to be shared with the rest of indent. Documented in
   indent.h.  */
char *token;
char *token_end;

#define alphanum 1
#define opchar 3

struct templ
{
  char *rwd;
  enum rwcodes rwcode;
};

/* Pointer to a vector of keywords specified by the user.  */
static struct templ *user_specials = 0;

/* Allocated size of user_specials.  */
static unsigned int user_specials_max;

/* Index in user_specials of the first unused entry.  */
static unsigned int user_specials_idx;

char chartype[128] =
{				/* this is used to facilitate the decision of
				   what type (alphanumeric, operator) each
				   character is */
  0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0,
  0, 3, 0, 0, 1, 3, 3, 0,
  0, 0, 3, 3, 0, 3, 0, 3,
  1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 0, 0, 3, 3, 3, 3,
  0, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 0, 0, 0, 3, 1,
  0, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 1, 1, 1, 1, 1,
  1, 1, 1, 0, 3, 0, 3, 0
};

/* C code produced by gperf version 2.0 (K&R C version)
   Command-line:
   gperf -c -p -t -T -g -j1 -o -K rwd -N is_reserved indent.gperf  */

#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 8
#define MIN_HASH_VALUE 4
#define MAX_HASH_VALUE 42

/* 31 keywords, 39 is the maximum key range */

INLINE static int
hash (str, len)
     register char *str;
     register unsigned int len;
{
  static unsigned char hash_table[] =
  {
    42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
    42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
    42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
    42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
    42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
    42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
    42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
    42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
    42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
    42, 42, 42, 42, 42, 42, 42, 42, 6, 9,
    10, 0, 16, 5, 4, 24, 42, 0, 20, 4,
    20, 0, 42, 42, 6, 0, 0, 10, 10, 2,
    42, 42, 42, 42, 42, 42, 42, 42,
  };
  return len + hash_table[str[len - 1]] + hash_table[str[0]];
}

INLINE struct templ *
is_reserved (str, len)
     register char *str;
     register unsigned int len;
{

  static struct templ wordlist[] =
  {
    {"",},
    {"",},
    {"",},
    {"",},
    {"else", rw_sp_nparen,},
    {"short", rw_decl,},
    {"struct", rw_struct_like,},
    {"while", rw_sp_paren,},
    {"enum", rw_struct_like,},
    {"goto", rw_break,},
    {"switch", rw_switch,},
    {"break", rw_break,},
    {"do", rw_sp_nparen,},
    {"case", rw_case,},
    {"const", rw_decl,},
    {"static", rw_decl,},
    {"double", rw_decl,},
    {"default", rw_case,},
    {"volatile", rw_decl,},
    {"char", rw_decl,},
    {"register", rw_decl,},
    {"float", rw_decl,},
    {"sizeof", rw_sizeof,},
    {"typedef", rw_decl,},
    {"void", rw_decl,},
    {"for", rw_sp_paren,},
    {"extern", rw_decl,},
    {"int", rw_decl,},
    {"unsigned", rw_decl,},
    {"long", rw_decl,},
    {"",},
    {"global", rw_decl,},
    {"return", rw_break,},
    {"",},
    {"",},
    {"union", rw_struct_like,},
    {"va_dcl", rw_decl,},
    {"",},
    {"",},
    {"",},
    {"",},
    {"",},
    {"if", rw_sp_paren,},
  };

  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    {
      register int key = hash (str, len);

      if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
	{
	  register char *s = wordlist[key].rwd;

	  if (*s == *str && !strncmp (str + 1, s + 1, len - 1))
	    return &wordlist[key];
	}
    }
  return 0;
}

enum codes
lexi ()
{
  int unary_delim;		/* this is set to 1 if the current token
				   forces a following operator to be unary */
  static enum codes last_code;	/* the last token type returned */
  static int l_struct;		/* set to 1 if the last token was 'struct' */
  enum codes code;		/* internal code to be returned */
  char qchar;			/* the delimiter character for a string */

  unary_delim = false;
  /* tell world that this token started in column 1 iff the last
     thing scanned was nl */
  parser_state_tos->col_1 = parser_state_tos->last_nl;
  parser_state_tos->last_nl = false;

  while (*buf_ptr == ' ' || *buf_ptr == '\t')
    {				/* get rid of blanks */
      parser_state_tos->col_1 = false;	/* leading blanks imply token is not
					   in column 1 */
      if (++buf_ptr >= buf_end)
	fill_buffer ();
    }

  token = buf_ptr;

  /* Scan an alphanumeric token */
  if (chartype[*buf_ptr] == alphanum
      || (buf_ptr[0] == '.' && isdigit (buf_ptr[1])))
    {
      /* we have a character or number */
      register struct templ *p;

      if (isdigit (*buf_ptr) || (buf_ptr[0] == '.' && isdigit (buf_ptr[1])))
	{
	  int seendot = 0, seenexp = 0;
	  if (*buf_ptr == '0' &&
	      (buf_ptr[1] == 'x' || buf_ptr[1] == 'X'))
	    {
	      buf_ptr += 2;
	      while (isxdigit (*buf_ptr))
		buf_ptr++;
	    }
	  else
	    while (1)
	      {
		if (*buf_ptr == '.')
		  if (seendot)
		    break;
		  else
		    seendot++;
		buf_ptr++;
		if (!isdigit (*buf_ptr) && *buf_ptr != '.')
		  if ((*buf_ptr != 'E' && *buf_ptr != 'e') || seenexp)
		    break;
		  else
		    {
		      seenexp++;
		      seendot++;
		      buf_ptr++;
		      if (*buf_ptr == '+' || *buf_ptr == '-')
			buf_ptr++;
		    }
	      }
	  /* Accept unsigned and unsigned long constants
	     (U and UL suffixes).  I'm not sure if LU is ansii. */
	  if (*buf_ptr == 'U' || *buf_ptr == 'u')
	    buf_ptr++;
	  if (*buf_ptr == 'L' || *buf_ptr == 'l')
	    buf_ptr++;
	}
      else
	while (chartype[*buf_ptr] == alphanum)
	  {			/* copy it over */
	    buf_ptr++;
	    if (buf_ptr >= buf_end)
	      fill_buffer ();
	  }
      token_end = buf_ptr;
      while (*buf_ptr == ' ' || *buf_ptr == '\t')
	{
	  if (++buf_ptr >= buf_end)
	    fill_buffer ();
	}
      parser_state_tos->its_a_keyword = false;
      parser_state_tos->sizeof_keyword = false;

      /* if last token was 'struct', then this token should be treated
	 as a declaration */
      if (l_struct)
	{
	  l_struct = false;
	  last_code = ident;
	  parser_state_tos->last_u_d = true;
	  return (decl);
	}

      /* Operator after indentifier is binary */
      parser_state_tos->last_u_d = false;
      last_code = ident;

      /* Check whether the token is a reserved word.  Use perfect hashing... */
      p = is_reserved (token, token_end - token);

      if (!p && user_specials != 0)
	{
	  for (p = &user_specials[0];
	       p < &user_specials[0] + user_specials_idx;
	       p++)
	    {
	      char *q = token;
	      char *r = p->rwd;

	      /* This string compare is a little nonstandard because token
	         ends at the character before token_end and p->rwd is
	         null-terminated.  */
	      while (1)
		{
		  /* If we have come to the end of both the keyword in
		     user_specials and the keyword in token they are equal.  */
		  if (q >= token_end && !*r)
		    goto found_keyword;

		  /* If we have come to the end of just one, they are not
		     equal.  */
		  if (q >= token_end || !*r)
		    break;

		  /* If the characters in corresponding characters are not
		     equal, the strings are not equal.  */
		  if (*q++ != *r++)
		    break;
		}
	    }
	  /* Didn't find anything in user_specials.  */
	  p = 0;
	}

      if (p)
	{			/* we have a keyword */
	found_keyword:
	  parser_state_tos->its_a_keyword = true;
	  parser_state_tos->last_u_d = true;
	  parser_state_tos->last_rw = p->rwcode;
	  switch (p->rwcode)
	    {
	    case rw_switch:	/* it is a switch */
	      return (swstmt);
	    case rw_case:	/* a case or default */
	      return (casestmt);

	    case rw_struct_like:	/* a "struct" */
	      if (parser_state_tos->p_l_follow
		  && !(parser_state_tos->noncast_mask
		       & 1 << parser_state_tos->p_l_follow))
		/* inside parens: cast */
		{
		  parser_state_tos->cast_mask
		    |= 1 << parser_state_tos->p_l_follow;
		  break;
		}
	      l_struct = true;

	      /* Next time around, we will want to know that we have had a
	         'struct' */
	    case rw_decl:	/* one of the declaration keywords */
	      if (parser_state_tos->p_l_follow
		  && !(parser_state_tos->noncast_mask
		       & 1 << parser_state_tos->p_l_follow))
		/* inside parens: cast */
		{
		  parser_state_tos->cast_mask
		    |= 1 << parser_state_tos->p_l_follow;
		  break;
		}
	      last_code = decl;
	      return (decl);

	    case rw_sp_paren:	/* if, while, for */
	      return (sp_paren);

	    case rw_sp_nparen:	/* do, else */
	      return (sp_nparen);

	    case rw_sizeof:
	      parser_state_tos->sizeof_keyword = true;
	      return (ident);

	    case rw_return:
	    case rw_break:
	    default:		/* all others are treated like any other
				   identifier */
	      return (ident);
	    }			/* end of switch */
	}			/* end of if (found_it) */

      if (*buf_ptr == '('
	  && parser_state_tos->tos <= 1
	  && parser_state_tos->ind_level == 0
	  && parser_state_tos->paren_depth == 0)
	{
	  /* We have found something which might be the name in a function
	     definition.  */
	  register char *tp;
	  int paren_count = 1;

	  /* Skip to the matching ')'.  */
	  for (tp = buf_ptr + 1;
	       paren_count > 0 && tp < in_prog + in_prog_size;
	       tp++)
	    {
	      if (*tp == '(')
		paren_count++;
	      if (*tp == ')')
		paren_count--;
	      /* Can't occur in parameter list; this way we don't search the
	         whole file in the case of unbalanced parens.  */
	      if (*tp == ';')
		goto not_proc;
	    }

	  if (paren_count == 0)
	    {
	      while (isspace (*tp))
		tp++;
	      /* If the next char is ';' or ',' or '(' we have a function
	         declaration, not a definition.

		 I've added '=' to this list to keep from breaking
		 a non-valid C macro from libc.  -jla */
	      if (*tp != ';' && *tp != ',' && *tp != '(' && *tp != '=')
		{
		  parser_state_tos->procname = token;
		  parser_state_tos->procname_end = token_end;
		  parser_state_tos->in_parameter_declaration = 1;
		}
	    }

	not_proc:;
	}

      /* The following hack attempts to guess whether or not the
	 current token is in fact a declaration keyword -- one that
	 has been typedef'd */
      if (((*buf_ptr == '*' && buf_ptr[1] != '=')
	   || isalpha (*buf_ptr) || *buf_ptr == '_')
	  && !parser_state_tos->p_l_follow
	  && !parser_state_tos->block_init
	  && (parser_state_tos->last_token == rparen
	      || parser_state_tos->last_token == semicolon
	      || parser_state_tos->last_token == decl
	      || parser_state_tos->last_token == lbrace
	      || parser_state_tos->last_token == rbrace))
	{
	  parser_state_tos->its_a_keyword = true;
	  parser_state_tos->last_u_d = true;
	  last_code = decl;
	  return decl;
	}

      if (last_code == decl)	/* if this is a declared variable, then
				   following sign is unary */
	parser_state_tos->last_u_d = true;	/* will make "int a -1" work */
      last_code = ident;
      return (ident);		/* the ident is not in the list */
    }				/* end of procesing for alpanum character */
  /* Scan a non-alphanumeric token */

  /* If it is not a one character token, token_end will get changed later.  */
  token_end = buf_ptr + 1;

  if (++buf_ptr >= buf_end)
    fill_buffer ();

  switch (*token)
    {
    case '\0':
      code = code_eof;
      break;

    case '\n':
      unary_delim = parser_state_tos->last_u_d;
      parser_state_tos->last_nl = true;
      code = newline;
      break;

    case '\'':			/* start of quoted character */
    case '"':			/* start of string */
      qchar = *token;

      /* Find out how big the literal is so we can set token_end.  */

      /* Invariant:  before loop test buf_ptr points to the next */
      /* character that we have not yet checked. */
      while (*buf_ptr != qchar && *buf_ptr != 0 && *buf_ptr != '\n')
	{
	  if (*buf_ptr == '\\')
	    {
	      buf_ptr++;
	      if (buf_ptr >= buf_end)
		fill_buffer ();
	      if (*buf_ptr == '\n')
		++line_no;
	      if (*buf_ptr == 0)
		break;
	    }
	  buf_ptr++;
	  if (buf_ptr >= buf_end)
	    fill_buffer ();
	}
      if (*buf_ptr == '\n' || *buf_ptr == 0)
	{
	  diag (1,
		qchar == '\''
		? "Unterminated character constant"
		: "Unterminated string constant"
	    );
	}
      else
	{
	  /* Advance over end quote char.  */
	  buf_ptr++;
	  if (buf_ptr >= buf_end)
	    fill_buffer ();
	}

      code = ident;
      break;

    case ('('):
    case ('['):
      unary_delim = true;
      code = lparen;
      break;

    case (')'):
    case (']'):
      code = rparen;
      break;

    case '#':
      unary_delim = parser_state_tos->last_u_d;
      code = preesc;
      break;

    case '?':
      unary_delim = true;
      code = question;
      break;

    case (':'):
      code = colon;
      unary_delim = true;
      break;

    case (';'):
      unary_delim = true;
      code = semicolon;
      break;

    case ('{'):
      unary_delim = true;

      /* This check is made in the code for '='.  No one who writes
         initializers without '=' these days deserves to have indent work on
         their code (besides which, uncommenting this would screw up anything
         which assumes that parser_state_tos->block_init really means you are
         in an initializer.  */
      /* if (parser_state_tos->in_or_st) parser_state_tos->block_init = 1; */

      /* The following neat hack causes the braces in structure
         initializations to be treated as parentheses, thus causing
         initializations to line up correctly, e.g. struct foo bar = {{a, b,
         c}, {1, 2}}; If lparen is returned, token can be used to distinguish
         between '{' and '(' where necessary.  */

      code = parser_state_tos->block_init ? lparen : lbrace;
      break;

    case ('}'):
      unary_delim = true;
      /* The following neat hack is explained under '{' above.  */
      code = parser_state_tos->block_init ? rparen : rbrace;

      break;

    case 014:			/* a form feed */
      unary_delim = parser_state_tos->last_u_d;
      parser_state_tos->last_nl = true;	/* remember this so we can set
					   'parser_state_tos->col_1' right */
      code = form_feed;
      break;

    case (','):
      unary_delim = true;
      code = comma;
      break;

    case '.':
      unary_delim = false;
      code = period;
      break;

    case '-':
    case '+':			/* check for -, +, --, ++ */
      code = (parser_state_tos->last_u_d ? unary_op : binary_op);
      unary_delim = true;

      if (*buf_ptr == token[0])
	{
	  /* check for doubled character */
	  buf_ptr++;
	  /* buffer overflow will be checked at end of loop */
	  if (last_code == ident || last_code == rparen)
	    {
	      code = (parser_state_tos->last_u_d ? unary_op : postop);
	      /* check for following ++ or -- */
	      unary_delim = false;
	    }
	}
      else if (*buf_ptr == '=')
	/* check for operator += */
	buf_ptr++;
      else if (*buf_ptr == '>')
	{
	  /* check for operator -> */
	  buf_ptr++;
	  if (!pointer_as_binop)
	    {
	      unary_delim = false;
	      code = unary_op;
	      parser_state_tos->want_blank = false;
	    }
	}
      break;			/* buffer overflow will be checked at end of
				   switch */

    case '=':
      if (parser_state_tos->in_or_st)
	parser_state_tos->block_init = 1;

      if (*buf_ptr == '=')	/* == */
	buf_ptr++;
      else if (*buf_ptr == '-'
	       || *buf_ptr == '+'
	       || *buf_ptr == '*'
	       || *buf_ptr == '&')
	{
	  /* Something like x=-1, which can mean x -= 1 ("old style" in K&R1)
	     or x = -1 (ANSI).  Note that this is only an ambiguity if the
	     character can also be a unary operator.  If not, just produce
	     output code that produces a syntax error (the theory being that
	     people want to detect and eliminate old style assignments but
	     they don't want indent to silently change the meaning of their
	     code).  */
	  diag (0,
	  "old style assignment ambiguity in \"=%c\".  Assuming \"= %c\"\n",
		*buf_ptr, *buf_ptr);
	}

      code = binary_op;
      unary_delim = true;
      break;
      /* can drop thru!!! */

    case '>':
    case '<':
    case '!':
      /* ops like <, <<, <=, !=, <<=, etc */
      /* This will of course scan sequences like "<=>", "!=>", "<<>", etc. as
         one token, but I don't think that will cause any harm.  */
      while (*buf_ptr == '>' || *buf_ptr == '<' || *buf_ptr == '=')
	{
	  if (++buf_ptr >= buf_end)
	    fill_buffer ();
	  if (*buf_ptr == '=')
	    {
	      if (++buf_ptr >= buf_end)
		fill_buffer ();
	    }
	}

      code = (parser_state_tos->last_u_d ? unary_op : binary_op);
      unary_delim = true;
      break;

    default:
      if (token[0] == '/' && *buf_ptr == '*')
	{
	  /* it is start of comment */

	  if (++buf_ptr >= buf_end)
	    fill_buffer ();

	  code = comment;
	  unary_delim = parser_state_tos->last_u_d;
	  break;
	}
      while (*(buf_ptr - 1) == *buf_ptr || *buf_ptr == '=')
	{
	  /* handle ||, &&, etc, and also things as in int *****i */
	  if (++buf_ptr >= buf_end)
	    fill_buffer ();
	}
      code = (parser_state_tos->last_u_d ? unary_op : binary_op);
      unary_delim = true;


    }				/* end of switch */
  if (code != newline)
    {
      l_struct = false;
      last_code = code;
    }
  token_end = buf_ptr;
  if (buf_ptr >= buf_end)	/* check for input buffer empty */
    fill_buffer ();
  parser_state_tos->last_u_d = unary_delim;

  return (code);
}

/* Add the given keyword to the keyword table, using val as the keyword type */
addkey (key, val)
     char *key;
     enum rwcodes val;
{
  register struct templ *p;

  /* Check to see whether key is a reserved word or not. */
  if (is_reserved (key, strlen (key)) != 0)
    return;

  if (user_specials == 0)
    {
      user_specials = (struct templ *) xmalloc (5 * sizeof (struct templ));
      user_specials_max = 5;
      user_specials_idx = 0;
    }
  else if (user_specials_idx == user_specials_max)
    {
      user_specials_max += 5;
      user_specials = (struct templ *) xrealloc ((char *) user_specials,
						 user_specials_max
						 * sizeof (struct templ));
    }

  p = &user_specials[user_specials_idx++];
  p->rwd = key;
  p->rwcode = val;
  return;
}