home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / cexp.y < prev    next >
Text File  |  1991-06-03  |  17KB  |  760 lines

  1. /* Parse C expressions for CCCP.
  2.    Copyright (C) 1987 Free Software Foundation.
  3.  
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 2, or (at your option) any
  7. later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  In other words, you are welcome to use, share and improve this program.
  19.  You are forbidden to forbid anyone else to use, share and improve
  20.  what you give them.   Help stamp out software-hoarding!
  21.  
  22.  Adapted from expread.y of GDB by Paul Rubin, July 1986.
  23.  
  24. /* Parse a C expression from text in a string  */
  25.    
  26. %{
  27. #include "config.h"
  28. #include <setjmp.h>
  29. /* #define YYDEBUG 1 */
  30.  
  31. typedef unsigned char U_CHAR;
  32.  
  33. /* This is used for communicating lists of keywords with cccp.c.  */
  34. struct arglist {
  35.   struct arglist *next;
  36.   U_CHAR *name;
  37.   int length;
  38.   int argno;
  39. };
  40.  
  41. int yylex ();
  42. void yyerror ();
  43. int expression_value;
  44.  
  45. static jmp_buf parse_return_error;
  46.  
  47. /* Nonzero means count most punctuation as part of a name.  */
  48. static int keyword_parsing = 0;
  49.  
  50. /* some external tables of character types */
  51. extern unsigned char is_idstart[], is_idchar[], is_hor_space[];
  52.  
  53. /* Flag for -pedantic.  */
  54. extern int pedantic;
  55.  
  56. #ifndef CHAR_TYPE_SIZE
  57. #define CHAR_TYPE_SIZE BITS_PER_UNIT
  58. #endif
  59. %}
  60.  
  61. %union {
  62.   struct constant {long value; int unsignedp;} integer;
  63.   struct name {U_CHAR *address; int length;} name;
  64.   struct arglist *keywords;
  65.   int voidval;
  66.   char *sval;
  67. }
  68.  
  69. %type <integer> exp exp1 start
  70. %type <keywords> keywords
  71. %token <integer> INT CHAR
  72. %token <name> NAME
  73. %token <integer> ERROR
  74.  
  75. %right '?' ':'
  76. %left ','
  77. %left OR
  78. %left AND
  79. %left '|'
  80. %left '^'
  81. %left '&'
  82. %left EQUAL NOTEQUAL
  83. %left '<' '>' LEQ GEQ
  84. %left LSH RSH
  85. %left '+' '-'
  86. %left '*' '/' '%'
  87. %right UNARY
  88.  
  89. /* %expect 40 */
  90.  
  91. %%
  92.  
  93. start   :    exp1
  94.         { expression_value = $1.value; }
  95.     ;
  96.  
  97. /* Expressions, including the comma operator.  */
  98. exp1    :    exp
  99.     |    exp1 ',' exp
  100.             { if (pedantic)
  101.                 warning ("comma operator in operand of `#if'");
  102.               $$ = $3; }
  103.     ;
  104.  
  105. /* Expressions, not including the comma operator.  */
  106. exp    :    '-' exp    %prec UNARY
  107.             { $$.value = - $2.value;
  108.               $$.unsignedp = $2.unsignedp; }
  109.     |    '!' exp    %prec UNARY
  110.             { $$.value = ! $2.value;
  111.               $$.unsignedp = 0; }
  112.     |    '+' exp    %prec UNARY
  113.             { $$ = $2; }
  114.     |    '~' exp    %prec UNARY
  115.             { $$.value = ~ $2.value;
  116.               $$.unsignedp = $2.unsignedp; }
  117.     |    '#' NAME
  118.               { $$.value = check_assertion ($2.address, $2.length,
  119.                               0, 0);
  120.               $$.unsignedp = 0; }
  121.     |    '#' NAME
  122.             { keyword_parsing = 1; }
  123.         '(' keywords ')'
  124.               { $$.value = check_assertion ($2.address, $2.length,
  125.                               1, $5);
  126.               keyword_parsing = 0;
  127.               $$.unsignedp = 0; }
  128.     |    '(' exp1 ')'
  129.             { $$ = $2; }
  130.     ;
  131.  
  132. /* Binary operators in order of decreasing precedence.  */
  133. exp    :    exp '*' exp
  134.             { $$.unsignedp = $1.unsignedp || $3.unsignedp;
  135.               if ($$.unsignedp)
  136.                 $$.value = (unsigned) $1.value * $3.value;
  137.               else
  138.                 $$.value = $1.value * $3.value; }
  139.     |    exp '/' exp
  140.             { if ($3.value == 0)
  141.                 {
  142.                   error ("division by zero in #if");
  143.                   $3.value = 1;
  144.                 }
  145.               $$.unsignedp = $1.unsignedp || $3.unsignedp;
  146.               if ($$.unsignedp)
  147.                 $$.value = (unsigned) $1.value / $3.value;
  148.               else
  149.                 $$.value = $1.value / $3.value; }
  150.     |    exp '%' exp
  151.             { if ($3.value == 0)
  152.                 {
  153.                   error ("division by zero in #if");
  154.                   $3.value = 1;
  155.                 }
  156.               $$.unsignedp = $1.unsignedp || $3.unsignedp;
  157.               if ($$.unsignedp)
  158.                 $$.value = (unsigned) $1.value % $3.value;
  159.               else
  160.                 $$.value = $1.value % $3.value; }
  161.     |    exp '+' exp
  162.             { $$.value = $1.value + $3.value;
  163.               $$.unsignedp = $1.unsignedp || $3.unsignedp; }
  164.     |    exp '-' exp
  165.             { $$.value = $1.value - $3.value;
  166.               $$.unsignedp = $1.unsignedp || $3.unsignedp; }
  167.     |    exp LSH exp
  168.             { $$.unsignedp = $1.unsignedp;
  169.               if ($$.unsignedp)
  170.                 $$.value = (unsigned) $1.value << $3.value;
  171.               else
  172.                 $$.value = $1.value << $3.value; }
  173.     |    exp RSH exp
  174.             { $$.unsignedp = $1.unsignedp;
  175.               if ($$.unsignedp)
  176.                 $$.value = (unsigned) $1.value >> $3.value;
  177.               else
  178.                 $$.value = $1.value >> $3.value; }
  179.     |    exp EQUAL exp
  180.             { $$.value = ($1.value == $3.value);
  181.               $$.unsignedp = 0; }
  182.     |    exp NOTEQUAL exp
  183.             { $$.value = ($1.value != $3.value);
  184.               $$.unsignedp = 0; }
  185.     |    exp LEQ exp
  186.             { $$.unsignedp = 0;
  187.               if ($1.unsignedp || $3.unsignedp)
  188.                 $$.value = (unsigned) $1.value <= $3.value;
  189.               else
  190.                 $$.value = $1.value <= $3.value; }
  191.     |    exp GEQ exp
  192.             { $$.unsignedp = 0;
  193.               if ($1.unsignedp || $3.unsignedp)
  194.                 $$.value = (unsigned) $1.value >= $3.value;
  195.               else
  196.                 $$.value = $1.value >= $3.value; }
  197.     |    exp '<' exp
  198.             { $$.unsignedp = 0;
  199.               if ($1.unsignedp || $3.unsignedp)
  200.                 $$.value = (unsigned) $1.value < $3.value;
  201.               else
  202.                 $$.value = $1.value < $3.value; }
  203.     |    exp '>' exp
  204.             { $$.unsignedp = 0;
  205.               if ($1.unsignedp || $3.unsignedp)
  206.                 $$.value = (unsigned) $1.value > $3.value;
  207.               else
  208.                 $$.value = $1.value > $3.value; }
  209.     |    exp '&' exp
  210.             { $$.value = $1.value & $3.value;
  211.               $$.unsignedp = $1.unsignedp || $3.unsignedp; }
  212.     |    exp '^' exp
  213.             { $$.value = $1.value ^ $3.value;
  214.               $$.unsignedp = $1.unsignedp || $3.unsignedp; }
  215.     |    exp '|' exp
  216.             { $$.value = $1.value | $3.value;
  217.               $$.unsignedp = $1.unsignedp || $3.unsignedp; }
  218.     |    exp AND exp
  219.             { $$.value = ($1.value && $3.value);
  220.               $$.unsignedp = 0; }
  221.     |    exp OR exp
  222.             { $$.value = ($1.value || $3.value);
  223.               $$.unsignedp = 0; }
  224.     |    exp '?' exp ':' exp
  225.             { $$.value = $1.value ? $3.value : $5.value;
  226.               $$.unsignedp = $3.unsignedp || $5.unsignedp; }
  227.     |    INT
  228.             { $$ = yylval.integer; }
  229.     |    CHAR
  230.             { $$ = yylval.integer; }
  231.     |    NAME
  232.             { $$.value = 0;
  233.               $$.unsignedp = 0; }
  234.     ;
  235.  
  236. keywords :
  237.             { $$ = 0; } 
  238.     |    '(' keywords ')' keywords
  239.             { struct arglist *temp;
  240.               $$ = (struct arglist *) xmalloc (sizeof (struct arglist));
  241.               $$->next = $2;
  242.               $$->name = (U_CHAR *) "(";
  243.               $$->length = 1;
  244.               temp = $$;
  245.               while (temp != 0 && temp->next != 0)
  246.                 temp = temp->next;
  247.               temp->next = (struct arglist *) xmalloc (sizeof (struct arglist));
  248.               temp->next->next = $4;
  249.               temp->next->name = (U_CHAR *) ")";
  250.               temp->next->length = 1; }
  251.     |    NAME keywords
  252.             { $$ = (struct arglist *) xmalloc (sizeof (struct arglist));
  253.               $$->name = $1.address;
  254.               $$->length = $1.length;
  255.               $$->next = $2; } 
  256.     ;
  257. %%
  258.  
  259. /* During parsing of a C expression, the pointer to the next character
  260.    is in this variable.  */
  261.  
  262. static char *lexptr;
  263.  
  264. /* Take care of parsing a number (anything that starts with a digit).
  265.    Set yylval and return the token type; update lexptr.
  266.    LEN is the number of characters in it.  */
  267.  
  268. /* maybe needs to actually deal with floating point numbers */
  269.  
  270. int
  271. parse_number (olen)
  272.      int olen;
  273. {
  274.   register char *p = lexptr;
  275.   register long n = 0;
  276.   register int c;
  277.   register int base = 10;
  278.   register int len = olen;
  279.  
  280.   for (c = 0; c < len; c++)
  281.     if (p[c] == '.') {
  282.       /* It's a float since it contains a point.  */
  283.       yyerror ("floating point numbers not allowed in #if expressions");
  284.       return ERROR;
  285.     }
  286.  
  287.   yylval.integer.unsignedp = 0;
  288.  
  289.   if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2))) {
  290.     p += 2;
  291.     base = 16;
  292.     len -= 2;
  293.   }
  294.   else if (*p == '0')
  295.     base = 8;
  296.  
  297.   while (len > 0) {
  298.     c = *p++;
  299.     len--;
  300.     if (c >= 'A' && c <= 'Z') c += 'a' - 'A';
  301.  
  302.     if (c >= '0' && c <= '9') {
  303.       n *= base;
  304.       n += c - '0';
  305.     } else if (base == 16 && c >= 'a' && c <= 'f') {
  306.       n *= base;
  307.       n += c - 'a' + 10;
  308.     } else {
  309.       /* `l' means long, and `u' means unsigned.  */
  310.       while (1) {
  311.     if (c == 'l' || c == 'L')
  312.       ;
  313.     else if (c == 'u' || c == 'U')
  314.       yylval.integer.unsignedp = 1;
  315.     else
  316.       break;
  317.  
  318.     if (len == 0)
  319.       break;
  320.     c = *p++;
  321.     len--;
  322.       }
  323.       /* Don't look for any more digits after the suffixes.  */
  324.       break;
  325.     }
  326.   }
  327.  
  328.   if (len != 0) {
  329.     yyerror ("Invalid number in #if expression");
  330.     return ERROR;
  331.   }
  332.  
  333.   /* If too big to be signed, consider it unsigned.  */
  334.   if (n < 0)
  335.     yylval.integer.unsignedp = 1;
  336.  
  337.   lexptr = p;
  338.   yylval.integer.value = n;
  339.   return INT;
  340. }
  341.  
  342. struct token {
  343.   char *operator;
  344.   int token;
  345. };
  346.  
  347. #ifndef NULL
  348. #define NULL 0
  349. #endif
  350.  
  351. static struct token tokentab2[] = {
  352.   {"&&", AND},
  353.   {"||", OR},
  354.   {"<<", LSH},
  355.   {">>", RSH},
  356.   {"==", EQUAL},
  357.   {"!=", NOTEQUAL},
  358.   {"<=", LEQ},
  359.   {">=", GEQ},
  360.   {"++", ERROR},
  361.   {"--", ERROR},
  362.   {NULL, ERROR}
  363. };
  364.  
  365. /* Read one token, getting characters through lexptr.  */
  366.  
  367. int
  368. yylex ()
  369. {
  370.   register int c;
  371.   register int namelen;
  372.   register char *tokstart;
  373.   register struct token *toktab;
  374.  
  375.  retry:
  376.  
  377.   tokstart = lexptr;
  378.   c = *tokstart;
  379.   /* See if it is a special token of length 2.  */
  380.   if (! keyword_parsing)
  381.     for (toktab = tokentab2; toktab->operator != NULL; toktab++)
  382.       if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) {
  383.     lexptr += 2;
  384.     if (toktab->token == ERROR)
  385.       yyerror ("`%s' not allowed in operand of `#if'", toktab->operator);
  386.     return toktab->token;
  387.       }
  388.  
  389.   switch (c) {
  390.   case 0:
  391.     return 0;
  392.     
  393.   case ' ':
  394.   case '\t':
  395.   case '\r':
  396.   case '\n':
  397.     lexptr++;
  398.     goto retry;
  399.     
  400.   case '\'':
  401.     lexptr++;
  402.     if (keyword_parsing) {
  403.       char *start_ptr = lexptr - 1;
  404.       while (1) {
  405.     c = *lexptr++;
  406.     if (c == '\\')
  407.       c = parse_escape (&lexptr);
  408.     else if (c == '\'')
  409.       break;
  410.       }
  411.       yylval.name.address = (U_CHAR *) tokstart;
  412.       yylval.name.length = lexptr - start_ptr;
  413.       return NAME;
  414.     }
  415.  
  416.     c = *lexptr++;
  417.     if (c == '\\')
  418.       c = parse_escape (&lexptr);
  419.  
  420.     /* Sign-extend the constant if chars are signed on target machine.  */
  421.     {
  422.       if (lookup ("__CHAR_UNSIGNED__", sizeof ("__CHAR_UNSIGNED__")-1, -1)
  423.       || ((c >> (CHAR_TYPE_SIZE - 1)) & 1) == 0)
  424.     yylval.integer.value = c & ((1 << CHAR_TYPE_SIZE) - 1);
  425.       else
  426.     yylval.integer.value = c | ~((1 << CHAR_TYPE_SIZE) - 1);
  427.     }
  428.  
  429.     yylval.integer.unsignedp = 0;
  430.     c = *lexptr++;
  431.     if (c != '\'') {
  432.       yyerror ("Invalid character constant in #if");
  433.       return ERROR;
  434.     }
  435.     
  436.     return CHAR;
  437.  
  438.     /* some of these chars are invalid in constant expressions;
  439.        maybe do something about them later */
  440.   case '/':
  441.   case '+':
  442.   case '-':
  443.   case '*':
  444.   case '%':
  445.   case '|':
  446.   case '&':
  447.   case '^':
  448.   case '~':
  449.   case '!':
  450.   case '@':
  451.   case '<':
  452.   case '>':
  453.   case '[':
  454.   case ']':
  455.   case '.':
  456.   case '?':
  457.   case ':':
  458.   case '=':
  459.   case '{':
  460.   case '}':
  461.   case ',':
  462.   case '#':
  463.     if (keyword_parsing)
  464.       break;
  465.   case '(':
  466.   case ')':
  467.     lexptr++;
  468.     return c;
  469.  
  470.   case '"':
  471.     if (keyword_parsing) {
  472.       char *start_ptr = lexptr;
  473.       lexptr++;
  474.       while (1) {
  475.     c = *lexptr++;
  476.     if (c == '\\')
  477.       c = parse_escape (&lexptr);
  478.     else if (c == '"')
  479.       break;
  480.       }
  481.       yylval.name.address = (U_CHAR *) tokstart;
  482.       yylval.name.length = lexptr - start_ptr;
  483.       return NAME;
  484.     }
  485.     yyerror ("string constants not allowed in #if expressions");
  486.     return ERROR;
  487.   }
  488.  
  489.   if (c >= '0' && c <= '9' && !keyword_parsing) {
  490.     /* It's a number */
  491.     for (namelen = 0;
  492.      c = tokstart[namelen], is_idchar[c] || c == '.'; 
  493.      namelen++)
  494.       ;
  495.     return parse_number (namelen);
  496.   }
  497.  
  498.   /* It is a name.  See how long it is.  */
  499.  
  500.   if (keyword_parsing) {
  501.     for (namelen = 0;; namelen++) {
  502.       if (is_hor_space[tokstart[namelen]])
  503.     break;
  504.       if (tokstart[namelen] == '(' || tokstart[namelen] == ')')
  505.     break;
  506.       if (tokstart[namelen] == '"' || tokstart[namelen] == '\'')
  507.     break;
  508.     }
  509.   } else {
  510.     if (!is_idstart[c]) {
  511.       yyerror ("Invalid token in expression");
  512.       return ERROR;
  513.     }
  514.  
  515.     for (namelen = 0; is_idchar[tokstart[namelen]]; namelen++)
  516.       ;
  517.   }
  518.   
  519.   lexptr += namelen;
  520.   yylval.name.address = (U_CHAR *) tokstart;
  521.   yylval.name.length = namelen;
  522.   return NAME;
  523. }
  524.  
  525.  
  526. /* Parse a C escape sequence.  STRING_PTR points to a variable
  527.    containing a pointer to the string to parse.  That pointer
  528.    is updated past the characters we use.  The value of the
  529.    escape sequence is returned.
  530.  
  531.    A negative value means the sequence \ newline was seen,
  532.    which is supposed to be equivalent to nothing at all.
  533.  
  534.    If \ is followed by a null character, we return a negative
  535.    value and leave the string pointer pointing at the null character.
  536.  
  537.    If \ is followed by 000, we return 0 and leave the string pointer
  538.    after the zeros.  A value of 0 does not mean end of string.  */
  539.  
  540. int
  541. parse_escape (string_ptr)
  542.      char **string_ptr;
  543. {
  544.   register int c = *(*string_ptr)++;
  545.   switch (c)
  546.     {
  547.     case 'a':
  548.       return TARGET_BELL;
  549.     case 'b':
  550.       return TARGET_BS;
  551.     case 'e':
  552.       return 033;
  553.     case 'f':
  554.       return TARGET_FF;
  555.     case 'n':
  556.       return TARGET_NEWLINE;
  557.     case 'r':
  558.       return TARGET_CR;
  559.     case 't':
  560.       return TARGET_TAB;
  561.     case 'v':
  562.       return TARGET_VT;
  563.     case '\n':
  564.       return -2;
  565.     case 0:
  566.       (*string_ptr)--;
  567.       return 0;
  568.     case '^':
  569.       c = *(*string_ptr)++;
  570.       if (c == '\\')
  571.     c = parse_escape (string_ptr);
  572.       if (c == '?')
  573.     return 0177;
  574.       return (c & 0200) | (c & 037);
  575.       
  576.     case '0':
  577.     case '1':
  578.     case '2':
  579.     case '3':
  580.     case '4':
  581.     case '5':
  582.     case '6':
  583.     case '7':
  584.       {
  585.     register int i = c - '0';
  586.     register int count = 0;
  587.     while (++count < 3)
  588.       {
  589.         c = *(*string_ptr)++;
  590.         if (c >= '0' && c <= '7')
  591.           i = (i << 3) + c - '0';
  592.         else
  593.           {
  594.         (*string_ptr)--;
  595.         break;
  596.           }
  597.       }
  598.     if ((i & ~((1 << CHAR_TYPE_SIZE) - 1)) != 0)
  599.       {
  600.         i &= (1 << CHAR_TYPE_SIZE) - 1;
  601.         warning ("octal character constant does not fit in a byte");
  602.       }
  603.     return i;
  604.       }
  605.     case 'x':
  606.       {
  607.     register int i = 0;
  608.     for (;;)
  609.       {
  610.         c = *(*string_ptr)++;
  611.         if (c >= '0' && c <= '9')
  612.           i = (i << 4) + c - '0';
  613.         else if (c >= 'a' && c <= 'f')
  614.           i = (i << 4) + c - 'a' + 10;
  615.         else if (c >= 'A' && c <= 'F')
  616.           i = (i << 4) + c - 'A' + 10;
  617.         else
  618.           {
  619.         (*string_ptr)--;
  620.         break;
  621.           }
  622.       }
  623.     if ((i & ~((1 << BITS_PER_UNIT) - 1)) != 0)
  624.       {
  625.         i &= (1 << BITS_PER_UNIT) - 1;
  626.         warning ("hex character constant does not fit in a byte");
  627.       }
  628.     return i;
  629.       }
  630.     default:
  631.       return c;
  632.     }
  633. }
  634.  
  635. void
  636. yyerror (s)
  637.      char *s;
  638. {
  639.   error (s);
  640.   longjmp (parse_return_error, 1);
  641. }
  642.  
  643. /* This page contains the entry point to this file.  */
  644.  
  645. /* Parse STRING as an expression, and complain if this fails
  646.    to use up all of the contents of STRING.  */
  647. /* We do not support C comments.  They should be removed before
  648.    this function is called.  */
  649.  
  650. int
  651. parse_c_expression (string)
  652.      char *string;
  653. {
  654.   lexptr = string;
  655.   
  656.   if (lexptr == 0 || *lexptr == 0) {
  657.     error ("empty #if expression");
  658.     return 0;            /* don't include the #if group */
  659.   }
  660.  
  661.   /* if there is some sort of scanning error, just return 0 and assume
  662.      the parsing routine has printed an error message somewhere.
  663.      there is surely a better thing to do than this.     */
  664.   if (setjmp (parse_return_error))
  665.     return 0;
  666.  
  667.   if (yyparse ())
  668.     return 0;            /* actually this is never reached
  669.                    the way things stand. */
  670.   if (*lexptr)
  671.     error ("Junk after end of expression.");
  672.  
  673.   return expression_value;    /* set by yyparse () */
  674. }
  675.  
  676. #ifdef TEST_EXP_READER
  677. /* main program, for testing purposes. */
  678. main ()
  679. {
  680.   int n, c;
  681.   char buf[1024];
  682.   extern int yydebug;
  683. /*
  684.   yydebug = 1;
  685. */
  686.   initialize_random_junk ();
  687.  
  688.   for (;;) {
  689.     printf ("enter expression: ");
  690.     n = 0;
  691.     while ((buf[n] = getchar ()) != '\n' && buf[n] != EOF)
  692.       n++;
  693.     if (buf[n] == EOF)
  694.       break;
  695.     buf[n] = '\0';
  696.     printf ("parser returned %d\n", parse_c_expression (buf));
  697.   }
  698. }
  699.  
  700. /* table to tell if char can be part of a C identifier. */
  701. unsigned char is_idchar[256];
  702. /* table to tell if char can be first char of a c identifier. */
  703. unsigned char is_idstart[256];
  704. /* table to tell if c is horizontal space.  isspace () thinks that
  705.    newline is space; this is not a good idea for this program. */
  706. char is_hor_space[256];
  707.  
  708. /*
  709.  * initialize random junk in the hash table and maybe other places
  710.  */
  711. initialize_random_junk ()
  712. {
  713.   register int i;
  714.  
  715.   /*
  716.    * Set up is_idchar and is_idstart tables.  These should be
  717.    * faster than saying (is_alpha (c) || c == '_'), etc.
  718.    * Must do set up these things before calling any routines tthat
  719.    * refer to them.
  720.    */
  721.   for (i = 'a'; i <= 'z'; i++) {
  722.     ++is_idchar[i - 'a' + 'A'];
  723.     ++is_idchar[i];
  724.     ++is_idstart[i - 'a' + 'A'];
  725.     ++is_idstart[i];
  726.   }
  727.   for (i = '0'; i <= '9'; i++)
  728.     ++is_idchar[i];
  729.   ++is_idchar['_'];
  730.   ++is_idstart['_'];
  731. #if DOLLARS_IN_IDENTIFIERS
  732.   ++is_idchar['$'];
  733.   ++is_idstart['$'];
  734. #endif
  735.  
  736.   /* horizontal space table */
  737.   ++is_hor_space[' '];
  738.   ++is_hor_space['\t'];
  739. }
  740.  
  741. error (msg)
  742. {
  743.   printf ("error: %s\n", msg);
  744. }
  745.  
  746. warning (msg)
  747. {
  748.   printf ("warning: %s\n", msg);
  749. }
  750.  
  751. struct hashnode *
  752. lookup (name, len, hash)
  753.      char *name;
  754.      int len;
  755.      int hash;
  756. {
  757.   return (DEFAULT_SIGNED_CHAR) ? 0 : ((struct hashnode *) -1);
  758. }
  759. #endif
  760.