Annotation of gcc/c-parse.y, revision 1.1.1.12

1.1       root        1: /* YACC parser for C syntax.
1.1.1.9   root        2:    Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
1.1       root        3: 
                      4: This file is part of GNU CC.
                      5: 
1.1.1.9   root        6: GNU CC is free software; you can redistribute it and/or modify
                      7: it under the terms of the GNU General Public License as published by
                      8: the Free Software Foundation; either version 1, or (at your option)
                      9: any later version.
                     10: 
1.1       root       11: GNU CC is distributed in the hope that it will be useful,
1.1.1.9   root       12: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     14: GNU General Public License for more details.
                     15: 
                     16: You should have received a copy of the GNU General Public License
                     17: along with GNU CC; see the file COPYING.  If not, write to
                     18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
1.1       root       19: 
                     20: 
1.1.1.9   root       21: /* To whomever it may concern: I have heard that such a thing was once
                     22: written by AT&T, but I have never seen it.  */
1.1       root       23: 
1.1.1.10  root       24: %expect 8
1.1       root       25: 
1.1.1.11  root       26: /* These are the 8 conflicts you should get in parse.output;
1.1       root       27:    the state numbers may vary if minor changes in the grammar are made.
                     28: 
                     29: State 41 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
1.1.1.11  root       30: State 92 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
                     31: State 99 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
                     32: State 103 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
                     33: State 119 contains 1 shift/reduce conflict.  (See comment at component_decl.)
                     34: State 183 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
                     35: State 193 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
                     36: State 199 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
1.1       root       37: */
                     38: 
                     39: %{
                     40: #include "config.h"
                     41: #include "tree.h"
1.1.1.11  root       42: #include "input.h"
1.1.1.2   root       43: #include "c-parse.h"
1.1       root       44: #include "c-tree.h"
                     45: 
                     46: #include <stdio.h>
                     47: #include <errno.h>
                     48: 
                     49: #ifndef errno
                     50: extern int errno;
                     51: #endif
                     52: 
1.1.1.10  root       53: void yyerror ();
                     54: 
1.1       root       55: /* Cause the `yydebug' variable to be defined.  */
1.1.1.8   root       56: #define YYDEBUG 1
1.1       root       57: %}
                     58: 
                     59: %start program
                     60: 
1.1.1.9   root       61: %union {long itype; tree ttype; enum tree_code code; }
1.1       root       62: 
                     63: /* All identifiers that are not reserved words
                     64:    and are not declared typedefs in the current block */
                     65: %token IDENTIFIER
                     66: 
                     67: /* All identifiers that are declared typedefs in the current block.
                     68:    In some contexts, they are treated just like IDENTIFIER,
                     69:    but they can also serve as typespecs in declarations.  */
                     70: %token TYPENAME
                     71: 
                     72: /* Reserved words that specify storage class.
                     73:    yylval contains an IDENTIFIER_NODE which indicates which one.  */
                     74: %token SCSPEC
                     75: 
                     76: /* Reserved words that specify type.
                     77:    yylval contains an IDENTIFIER_NODE which indicates which one.  */
                     78: %token TYPESPEC
                     79: 
                     80: /* Reserved words that qualify type: "const" or "volatile".
                     81:    yylval contains an IDENTIFIER_NODE which indicates which one.  */
                     82: %token TYPE_QUAL
                     83: 
                     84: /* Character or numeric constants.
                     85:    yylval is the node for the constant.  */
                     86: %token CONSTANT
                     87: 
                     88: /* String constants in raw form.
                     89:    yylval is a STRING_CST node.  */
                     90: %token STRING
                     91: 
                     92: /* "...", used for functions with variable arglists.  */
                     93: %token ELLIPSIS
                     94: 
                     95: /* the reserved words */
                     96: %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
                     97: %token BREAK CONTINUE RETURN GOTO ASM TYPEOF ALIGNOF
1.1.1.11  root       98: %token ATTRIBUTE
1.1       root       99: 
1.1.1.10  root      100: /* Add precedence rules to solve dangling else s/r conflict */
                    101: %nonassoc IF
                    102: %nonassoc ELSE
                    103: 
1.1       root      104: /* Define the operator tokens and their precedences.
                    105:    The value is an integer because, if used, it is the tree code
                    106:    to use in the expression made from the operator.  */
                    107: 
                    108: %right <code> ASSIGN '='
                    109: %right <code> '?' ':'
                    110: %left <code> OROR
                    111: %left <code> ANDAND
                    112: %left <code> '|'
                    113: %left <code> '^'
                    114: %left <code> '&'
                    115: %left <code> EQCOMPARE
                    116: %left <code> ARITHCOMPARE
                    117: %left <code> LSHIFT RSHIFT
                    118: %left <code> '+' '-'
                    119: %left <code> '*' '/' '%'
                    120: %right <code> UNARY PLUSPLUS MINUSMINUS
                    121: %left HYPERUNARY
1.1.1.10  root      122: %left <code> POINTSAT '.' '(' '['
1.1       root      123: 
                    124: %type <code> unop
                    125: 
                    126: %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
1.1.1.8   root      127: %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
1.1       root      128: %type <ttype> typed_declspecs reserved_declspecs
                    129: %type <ttype> typed_typespecs reserved_typespecquals
                    130: %type <ttype> declmods typespec typespecqual_reserved
                    131: %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
                    132: %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
                    133: %type <ttype> init initlist maybeasm
1.1.1.3   root      134: %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
1.1.1.11  root      135: %type <ttype> maybe_attribute attribute_list attrib
                    136: 
                    137: %type <ttype> compstmt
1.1       root      138: 
                    139: %type <ttype> declarator
                    140: %type <ttype> notype_declarator after_type_declarator
                    141: %type <ttype> parm_declarator
                    142: 
                    143: %type <ttype> structsp component_decl_list component_decl components component_declarator
                    144: %type <ttype> enumlist enumerator
                    145: %type <ttype> typename absdcl absdcl1 type_quals
                    146: %type <ttype> xexpr parms parm identifiers
                    147: 
                    148: %type <ttype> parmlist parmlist_1 parmlist_2
                    149: %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
                    150: 
                    151: %type <itype> setspecs
                    152: 
                    153: %{
                    154: /* the declaration found for the last IDENTIFIER token read in.
                    155:    yylex must look this up to detect typedefs, which get token type TYPENAME,
                    156:    so it is left around in case the identifier is not a typedef but is
                    157:    used in a context which makes it a reference to a variable.  */
                    158: static tree lastiddecl;
                    159: 
                    160: static tree make_pointer_declarator ();
                    161: static tree combine_strings ();
                    162: static void reinit_parse_for_function ();
                    163: 
1.1.1.11  root      164: /* List of types and structure classes of the current declaration.  */
1.1       root      165: tree current_declspecs;
                    166: 
1.1.1.11  root      167: /* Stack of saved values of current_declspecs.  */
                    168: tree declspec_stack;
1.1       root      169: 
1.1.1.11  root      170: int undeclared_variable_notice;        /* 1 if we explained undeclared var errors.  */
1.1.1.8   root      171: 
1.1       root      172: static int yylex ();
                    173: %}
                    174: 
                    175: %%
                    176: program: /* empty */
                    177:        | extdefs
                    178:        ;
                    179: 
                    180: /* the reason for the strange actions in this rule
                    181:  is so that notype_initdecls when reached via datadef
                    182:  can find a valid list of type and sc specs in $0. */
                    183: 
                    184: extdefs:
                    185:        {$<ttype>$ = NULL_TREE; } extdef
                    186:        | extdefs {$<ttype>$ = NULL_TREE; } extdef
                    187:        ;
                    188: 
                    189: extdef:
                    190:        fndef
                    191:        | datadef
                    192:        | ASM '(' string ')' ';'
                    193:                { if (pedantic)
                    194:                    warning ("ANSI C forbids use of `asm' keyword");
                    195:                  if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
                    196:                  assemble_asm ($3); }
                    197:        ;
                    198: 
                    199: datadef:
                    200:          setspecs notype_initdecls ';'
                    201:                { if (pedantic)
                    202:                    error ("ANSI C forbids data definition lacking type or storage class");
1.1.1.3   root      203:                  else if (!flag_traditional)
1.1       root      204:                    warning ("data definition lacks type or storage class"); }
                    205:         | declmods setspecs notype_initdecls ';'
                    206:          {}
                    207:        | typed_declspecs setspecs initdecls ';'
                    208:          {}
                    209:         | declmods ';'
                    210:          { error ("empty declaration"); }
                    211:        | typed_declspecs ';'
                    212:          { shadow_tag ($1); }
                    213:        | error ';'
                    214:        | error '}'
                    215:        | ';'
1.1.1.11  root      216:                { if (pedantic)
                    217:                    warning ("ANSI C does not allow extra `;' outside of a function"); }
1.1       root      218:        ;
                    219: 
                    220: fndef:
                    221:          typed_declspecs setspecs declarator
                    222:                { if (! start_function ($1, $3))
1.1.1.4   root      223:                    YYERROR;
1.1       root      224:                  reinit_parse_for_function (); }
                    225:          xdecls
                    226:                { store_parm_decls (); }
                    227:          compstmt_or_error
1.1.1.11  root      228:                { finish_function (lineno); }
1.1       root      229:        | typed_declspecs setspecs declarator error
                    230:                { }
                    231:        | declmods setspecs notype_declarator
                    232:                { if (! start_function ($1, $3))
1.1.1.4   root      233:                    YYERROR;
1.1       root      234:                  reinit_parse_for_function (); }
                    235:          xdecls
                    236:                { store_parm_decls (); }
                    237:          compstmt_or_error
1.1.1.11  root      238:                { finish_function (lineno); }
1.1       root      239:        | declmods setspecs notype_declarator error
                    240:                { }
                    241:        | setspecs notype_declarator
                    242:                { if (! start_function (0, $2))
1.1.1.4   root      243:                    YYERROR;
1.1       root      244:                  reinit_parse_for_function (); }
                    245:          xdecls
                    246:                { store_parm_decls (); }
                    247:          compstmt_or_error
1.1.1.11  root      248:                { finish_function (lineno); }
1.1       root      249:        | setspecs notype_declarator error
                    250:                { }
                    251:        ;
                    252: 
                    253: identifier:
                    254:        IDENTIFIER
                    255:        | TYPENAME
                    256:        ;
                    257: 
                    258: unop:     '&'
                    259:                { $$ = ADDR_EXPR; }
                    260:        | '-'
                    261:                { $$ = NEGATE_EXPR; }
                    262:        | '+'
                    263:                { $$ = CONVERT_EXPR; }
                    264:        | PLUSPLUS
                    265:                { $$ = PREINCREMENT_EXPR; }
                    266:        | MINUSMINUS
                    267:                { $$ = PREDECREMENT_EXPR; }
                    268:        | '~'
                    269:                { $$ = BIT_NOT_EXPR; }
                    270:        | '!'
                    271:                { $$ = TRUTH_NOT_EXPR; }
                    272:        ;
                    273: 
                    274: expr:  nonnull_exprlist
                    275:                { $$ = build_compound_expr ($1); }
                    276:        ;
                    277: 
                    278: exprlist:
                    279:          /* empty */
                    280:                { $$ = NULL_TREE; }
                    281:        | nonnull_exprlist
                    282:        ;
                    283: 
                    284: nonnull_exprlist:
                    285:        expr_no_commas
                    286:                { $$ = build_tree_list (NULL_TREE, $1); }
                    287:        | nonnull_exprlist ',' expr_no_commas
                    288:                { chainon ($1, build_tree_list (NULL_TREE, $3)); }
                    289:        ;
                    290: 
1.1.1.8   root      291: unary_expr:
1.1       root      292:        primary
1.1.1.8   root      293:        | '*' cast_expr   %prec UNARY
1.1       root      294:                { $$ = build_indirect_ref ($2, "unary *"); }
1.1.1.8   root      295:        | unop cast_expr  %prec UNARY
1.1       root      296:                { $$ = build_unary_op ($1, $2, 0); }
1.1.1.8   root      297:        | SIZEOF unary_expr  %prec UNARY
                    298:                { if (TREE_CODE ($2) == COMPONENT_REF
                    299:                      && TREE_PACKED (TREE_OPERAND ($2, 1)))
                    300:                    error ("`sizeof' applied to a bit-field");
1.1.1.12! root      301:                  /* ANSI says arrays and functions are converted inside comma.
        !           302:                     But we can't really convert them in build_compound_expr
        !           303:                     because that would break commas in lvalues.
        !           304:                     So do the conversion here if operand was a comma.  */
        !           305:                  if (TREE_CODE ($2) == COMPOUND_EXPR
        !           306:                      && (TREE_CODE (TREE_TYPE ($2)) == ARRAY_TYPE
        !           307:                          || TREE_CODE (TREE_TYPE ($2)) == FUNCTION_TYPE))
        !           308:                    $2 = default_conversion ($2);
1.1.1.8   root      309:                  $$ = c_sizeof (TREE_TYPE ($2)); }
                    310:        | SIZEOF '(' typename ')'  %prec HYPERUNARY
                    311:                { $$ = c_sizeof (groktypename ($3)); }
                    312:        | ALIGNOF unary_expr  %prec UNARY
                    313:                { if (TREE_CODE ($2) == COMPONENT_REF
                    314:                      && TREE_PACKED (TREE_OPERAND ($2, 1)))
                    315:                    error ("`__alignof' applied to a bit-field");
1.1.1.11  root      316:                  if (TREE_CODE ($2) == INDIRECT_REF)
                    317:                    {
                    318:                      tree t = TREE_OPERAND ($2, 0);
                    319:                      tree best = t;
                    320:                      int bestalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
                    321:                      while (TREE_CODE (t) == NOP_EXPR
                    322:                             && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == POINTER_TYPE)
                    323:                        {
                    324:                          int thisalign;
                    325:                          t = TREE_OPERAND (t, 0);
                    326:                          thisalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
                    327:                          if (thisalign > bestalign)
                    328:                            best = t, bestalign = thisalign;
                    329:                        }
                    330:                      $$ = c_alignof (TREE_TYPE (TREE_TYPE (best)));
                    331:                    }
                    332:                  else
1.1.1.12! root      333:                    {
        !           334:                      /* ANSI says arrays and fns are converted inside comma.
        !           335:                         But we can't convert them in build_compound_expr
        !           336:                         because that would break commas in lvalues.
        !           337:                         So do the conversion here if operand was a comma.  */
        !           338:                      if (TREE_CODE ($2) == COMPOUND_EXPR
        !           339:                          && (TREE_CODE (TREE_TYPE ($2)) == ARRAY_TYPE
        !           340:                              || TREE_CODE (TREE_TYPE ($2)) == FUNCTION_TYPE))
        !           341:                        $2 = default_conversion ($2);
        !           342:                      $$ = c_alignof (TREE_TYPE ($2));
        !           343:                    }
        !           344:                }
1.1.1.8   root      345:        | ALIGNOF '(' typename ')'  %prec HYPERUNARY
                    346:                { $$ = c_alignof (groktypename ($3)); }
                    347:        ;
                    348: 
                    349: cast_expr:
                    350:        unary_expr
                    351:        | '(' typename ')' cast_expr  %prec UNARY
1.1       root      352:                { tree type = groktypename ($2);
                    353:                  $$ = build_c_cast (type, $4); }
                    354:        | '(' typename ')' '{' initlist maybecomma '}'  %prec UNARY
                    355:                { tree type = groktypename ($2);
                    356:                  if (pedantic)
1.1.1.8   root      357:                    warning ("ANSI C forbids constructor expressions");
1.1       root      358:                  $$ = digest_init (type, build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($5)), 0);
                    359:                  if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
                    360:                    {
                    361:                      int failure = complete_array_type (type, $$, 1);
                    362:                      if (failure)
                    363:                        abort ();
                    364:                    }
                    365:                }
1.1.1.8   root      366:        ;
                    367: 
                    368: expr_no_commas:
                    369:          cast_expr
1.1       root      370:        | expr_no_commas '+' expr_no_commas
                    371:                { $$ = build_binary_op ($2, $1, $3); }
                    372:        | expr_no_commas '-' expr_no_commas
                    373:                { $$ = build_binary_op ($2, $1, $3); }
                    374:        | expr_no_commas '*' expr_no_commas
                    375:                { $$ = build_binary_op ($2, $1, $3); }
                    376:        | expr_no_commas '/' expr_no_commas
                    377:                { $$ = build_binary_op ($2, $1, $3); }
                    378:        | expr_no_commas '%' expr_no_commas
                    379:                { $$ = build_binary_op ($2, $1, $3); }
                    380:        | expr_no_commas LSHIFT expr_no_commas
                    381:                { $$ = build_binary_op ($2, $1, $3); }
                    382:        | expr_no_commas RSHIFT expr_no_commas
                    383:                { $$ = build_binary_op ($2, $1, $3); }
                    384:        | expr_no_commas ARITHCOMPARE expr_no_commas
                    385:                { $$ = build_binary_op ($2, $1, $3); }
                    386:        | expr_no_commas EQCOMPARE expr_no_commas
                    387:                { $$ = build_binary_op ($2, $1, $3); }
                    388:        | expr_no_commas '&' expr_no_commas
                    389:                { $$ = build_binary_op ($2, $1, $3); }
                    390:        | expr_no_commas '|' expr_no_commas
                    391:                { $$ = build_binary_op ($2, $1, $3); }
                    392:        | expr_no_commas '^' expr_no_commas
                    393:                { $$ = build_binary_op ($2, $1, $3); }
                    394:        | expr_no_commas ANDAND expr_no_commas
                    395:                { $$ = build_binary_op (TRUTH_ANDIF_EXPR, $1, $3); }
                    396:        | expr_no_commas OROR expr_no_commas
                    397:                { $$ = build_binary_op (TRUTH_ORIF_EXPR, $1, $3); }
                    398:        | expr_no_commas '?' xexpr ':' expr_no_commas
                    399:                { $$ = build_conditional_expr ($1, $3, $5); }
                    400:        | expr_no_commas '=' expr_no_commas
                    401:                { $$ = build_modify_expr ($1, NOP_EXPR, $3); }
                    402:        | expr_no_commas ASSIGN expr_no_commas
                    403:                { $$ = build_modify_expr ($1, $2, $3); }
                    404:        ;
                    405: 
                    406: primary:
                    407:        IDENTIFIER
                    408:                { $$ = lastiddecl;
1.1.1.8   root      409:                  if (!$$ || $$ == error_mark_node)
1.1       root      410:                    {
                    411:                      if (yychar == YYEMPTY)
                    412:                        yychar = YYLEX;
                    413:                      if (yychar == '(')
1.1.1.7   root      414:                        {
                    415:                          $$ = implicitly_declare ($1);
                    416:                          assemble_external ($$);
                    417:                          TREE_USED ($$) = 1;
                    418:                        }
1.1.1.8   root      419:                      else if (current_function_decl == 0)
                    420:                        {
                    421:                          error ("`%s' undeclared, outside of functions",
                    422:                                 IDENTIFIER_POINTER ($1));
                    423:                          $$ = error_mark_node;
                    424:                        }
1.1       root      425:                      else
                    426:                        {
1.1.1.8   root      427:                          if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
                    428:                              || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
                    429:                            {
                    430:                              error ("`%s' undeclared (first use this function)",
                    431:                                     IDENTIFIER_POINTER ($1));
                    432: 
                    433:                              if (! undeclared_variable_notice)
                    434:                                {
                    435:                                  error ("(Each undeclared identifier is reported only once");
                    436:                                  error ("for each function it appears in.)");
                    437:                                  undeclared_variable_notice = 1;
                    438:                                }
                    439:                            }
1.1       root      440:                          $$ = error_mark_node;
                    441:                          /* Prevent repeated error messages.  */
                    442:                          IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
1.1.1.8   root      443:                          IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
1.1       root      444:                        }
                    445:                    }
1.1.1.7   root      446:                  else if (! TREE_USED ($$))
                    447:                    {
                    448:                      if (TREE_EXTERNAL ($$))
                    449:                        assemble_external ($$);
                    450:                      TREE_USED ($$) = 1;
                    451:                    }
1.1       root      452:                  if (TREE_CODE ($$) == CONST_DECL)
                    453:                    $$ = DECL_INITIAL ($$);
                    454:                }
                    455:        | CONSTANT
                    456:        | string
                    457:                { $$ = combine_strings ($1); }
                    458:        | '(' expr ')'
                    459:                { $$ = $2; }
                    460:        | '(' error ')'
                    461:                { $$ = error_mark_node; }
1.1.1.11  root      462:        | '('
1.1       root      463:                { if (current_function_decl == 0)
                    464:                    {
                    465:                      error ("braced-group within expression allowed only inside a function");
1.1.1.4   root      466:                      YYERROR;
1.1       root      467:                    }
1.1.1.11  root      468:                  keep_next_level ();
1.1.1.2   root      469:                  $<ttype>$ = expand_start_stmt_expr (); }
1.1       root      470:          compstmt ')'
1.1.1.11  root      471:                { tree rtl_exp;
                    472:                  if (pedantic)
1.1       root      473:                    warning ("ANSI C forbids braced-groups within expressions");
1.1.1.11  root      474:                  rtl_exp = expand_end_stmt_expr ($<ttype>2);
                    475:                  $$ = $3;
                    476:                  TREE_USED ($$) = 0;
                    477:                  /* Since the statements have side effects,
                    478:                     consider this volatile.  */
                    479:                  TREE_VOLATILE ($$) = 1;
                    480:                  TREE_TYPE ($$) = TREE_TYPE (rtl_exp);
                    481:                  STMT_BODY ($$) = rtl_exp; }
1.1       root      482:        | primary '(' exprlist ')'   %prec '.'
                    483:                { $$ = build_function_call ($1, $3); }
                    484:        | primary '[' expr ']'   %prec '.'
                    485:                { $$ = build_array_ref ($1, $3); }
                    486:        | primary '.' identifier
                    487:                { $$ = build_component_ref ($1, $3); }
                    488:        | primary POINTSAT identifier
                    489:                { $$ = build_component_ref (build_indirect_ref ($1, "->"), $3); }
                    490:        | primary PLUSPLUS
                    491:                { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
                    492:        | primary MINUSMINUS
                    493:                { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
                    494:        ;
                    495: 
                    496: /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it.  */
                    497: string:
                    498:          STRING
                    499:        | string STRING
                    500:                { $$ = chainon ($1, $2); }
                    501:        ;
                    502: 
                    503: xdecls:
                    504:        /* empty */
                    505:        | decls
                    506:        ;
                    507: 
                    508: decls:
                    509:        decl
                    510:        | errstmt
                    511:        | decls decl
                    512:        | decl errstmt
                    513:        ;
                    514: 
                    515: /* records the type and storage class specs to use for processing
1.1.1.11  root      516:    the declarators that follow.
                    517:    Maintains a stack of outer-level values of current_declspecs,
                    518:    for the sake of parm declarations nested in function declarators.  */
1.1       root      519: setspecs: /* empty */
1.1.1.11  root      520:                { $$ = suspend_momentary ();
                    521:                  declspec_stack = tree_cons (0, current_declspecs,
                    522:                                              declspec_stack);
                    523:                  current_declspecs = $<ttype>0; }
1.1       root      524:        ;
                    525: 
                    526: decl:
                    527:        typed_declspecs setspecs initdecls ';'
1.1.1.11  root      528:                { current_declspecs = TREE_VALUE (declspec_stack);
                    529:                  declspec_stack = TREE_CHAIN (declspec_stack);
                    530:                  resume_momentary ($2); }
1.1       root      531:        | declmods setspecs notype_initdecls ';'
1.1.1.11  root      532:                { current_declspecs = TREE_VALUE (declspec_stack);
                    533:                  declspec_stack = TREE_CHAIN (declspec_stack);
                    534:                  resume_momentary ($2); }
1.1       root      535:        | typed_declspecs ';'
                    536:                { shadow_tag ($1); }
                    537:        | declmods ';'
                    538:                { warning ("empty declaration"); }
                    539:        ;
                    540: 
                    541: /* Declspecs which contain at least one type specifier or typedef name.
                    542:    (Just `const' or `volatile' is not enough.)
                    543:    A typedef'd name following these is taken as a name to be declared.  */
                    544: 
                    545: typed_declspecs:
                    546:          typespec reserved_declspecs
                    547:                { $$ = tree_cons (NULL_TREE, $1, $2); }
                    548:        | declmods typespec reserved_declspecs
                    549:                { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
                    550:        ;
                    551: 
                    552: reserved_declspecs:  /* empty */
                    553:                { $$ = NULL_TREE; }
                    554:        | reserved_declspecs typespecqual_reserved
                    555:                { $$ = tree_cons (NULL_TREE, $2, $1); }
                    556:        | reserved_declspecs SCSPEC
                    557:                { $$ = tree_cons (NULL_TREE, $2, $1); }
                    558:        ;
                    559: 
                    560: /* List of just storage classes and type modifiers.
                    561:    A declaration can start with just this, but then it cannot be used
                    562:    to redeclare a typedef-name.  */
                    563: 
                    564: declmods:
                    565:          TYPE_QUAL
                    566:                { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
                    567:        | SCSPEC
                    568:                { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
                    569:        | declmods TYPE_QUAL
                    570:                { $$ = tree_cons (NULL_TREE, $2, $1); }
                    571:        | declmods SCSPEC
                    572:                { $$ = tree_cons (NULL_TREE, $2, $1); }
                    573:        ;
                    574: 
                    575: 
                    576: /* Used instead of declspecs where storage classes are not allowed
                    577:    (that is, for typenames and structure components).
                    578:    Don't accept a typedef-name if anything but a modifier precedes it.  */
                    579: 
                    580: typed_typespecs:
                    581:          typespec reserved_typespecquals
                    582:                { $$ = tree_cons (NULL_TREE, $1, $2); }
                    583:        | nonempty_type_quals typespec reserved_typespecquals
                    584:                { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
                    585:        ;
                    586: 
                    587: reserved_typespecquals:  /* empty */
                    588:                { $$ = NULL_TREE; }
                    589:        | reserved_typespecquals typespecqual_reserved
                    590:                { $$ = tree_cons (NULL_TREE, $2, $1); }
                    591:        ;
                    592: 
                    593: /* A typespec (but not a type qualifier).
                    594:    Once we have seen one of these in a declaration,
                    595:    if a typedef name appears then it is being redeclared.  */
                    596: 
                    597: typespec: TYPESPEC
                    598:        | structsp
                    599:        | TYPENAME
                    600:        | TYPEOF '(' expr ')'
                    601:                { $$ = TREE_TYPE ($3);
                    602:                  if (pedantic)
                    603:                    warning ("ANSI C forbids `typeof'"); }
                    604:        | TYPEOF '(' typename ')'
                    605:                { $$ = groktypename ($3);
                    606:                  if (pedantic)
                    607:                    warning ("ANSI C forbids `typeof'"); }
                    608:        ;
                    609: 
                    610: /* A typespec that is a reserved word, or a type qualifier.  */
                    611: 
                    612: typespecqual_reserved: TYPESPEC
                    613:        | TYPE_QUAL
                    614:        | structsp
                    615:        ;
                    616: 
                    617: initdecls:
                    618:        initdcl
                    619:        | initdecls ',' initdcl
                    620:        ;
                    621: 
                    622: notype_initdecls:
                    623:        notype_initdcl
                    624:        | notype_initdecls ',' initdcl
                    625:        ;
                    626: 
                    627: maybeasm:
                    628:          /* empty */
                    629:                { $$ = NULL_TREE; }
                    630:        | ASM '(' string ')'
                    631:                { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
                    632:                  $$ = $3;
                    633:                  if (pedantic)
                    634:                    warning ("ANSI C forbids use of `asm' keyword");
                    635:                }
                    636:        ;
                    637: 
                    638: initdcl:
1.1.1.11  root      639:          declarator maybeasm maybe_attribute '='
1.1       root      640:                { $<ttype>$ = start_decl ($1, current_declspecs, 1); }
                    641:          init
                    642: /* Note how the declaration of the variable is in effect while its init is parsed! */
1.1.1.11  root      643:                { finish_decl ($<ttype>5, $6, $2); }
                    644:        | declarator maybeasm maybe_attribute
1.1       root      645:                { tree d = start_decl ($1, current_declspecs, 0);
                    646:                  finish_decl (d, NULL_TREE, $2); }
                    647:        ;
                    648: 
                    649: notype_initdcl:
1.1.1.11  root      650:          notype_declarator maybeasm maybe_attribute '='
1.1       root      651:                { $<ttype>$ = start_decl ($1, current_declspecs, 1); }
                    652:          init
                    653: /* Note how the declaration of the variable is in effect while its init is parsed! */
1.1.1.11  root      654:                { finish_decl ($<ttype>5, $6, $2); }
                    655:        | notype_declarator maybeasm maybe_attribute
1.1       root      656:                { tree d = start_decl ($1, current_declspecs, 0);
                    657:                  finish_decl (d, NULL_TREE, $2); }
                    658:        ;
1.1.1.11  root      659: /* the * rules are dummies to accept the Apollo extended syntax
                    660:    so that the header files compile. */
                    661: maybe_attribute:
                    662:     /* empty */
1.1.1.12! root      663:        { $$ = NULL_TREE; }
1.1.1.11  root      664:     | ATTRIBUTE '(' '(' attribute_list ')' ')'
                    665:         { $$ = $4; }
                    666:     ;
                    667: 
                    668: attribute_list
                    669:     : attrib
                    670:     | attribute_list ',' attrib
                    671:     ;
                    672: 
                    673: attrib
                    674:     : IDENTIFIER
                    675:        { warning ("`%s' attribute directive ignored",
                    676:                   IDENTIFIER_POINTER ($1));
                    677:          $$ = $1; }
                    678:     | IDENTIFIER '(' CONSTANT ')'
                    679:        { /* if not "aligned(1)", then issue warning */
                    680:          if (strcmp (IDENTIFIER_POINTER ($1), "aligned") != 0
                    681:              || TREE_CODE ($3) != INTEGER_CST
                    682:              || TREE_INT_CST_LOW ($3) != 1)
                    683:            warning ("`%s' attribute directive ignored",
                    684:                     IDENTIFIER_POINTER ($1));
                    685:          $$ = $1; }
                    686:     | IDENTIFIER '(' identifiers ')'
                    687:        { warning ("`%s' attribute directive ignored",
                    688:                   IDENTIFIER_POINTER ($1));
                    689:          $$ = $1; }
                    690:     ;
1.1       root      691: 
                    692: init:
                    693:        expr_no_commas
1.1.1.2   root      694:        | '{' '}'
                    695:                { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
                    696:                  if (pedantic)
                    697:                    warning ("ANSI C forbids empty initializer braces"); }
1.1       root      698:        | '{' initlist '}'
                    699:                { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2)); }
                    700:        | '{' initlist ',' '}'
                    701:                { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2)); }
                    702:        | error
                    703:                { $$ = NULL_TREE; }
                    704:        ;
                    705: 
                    706: /* This chain is built in reverse order,
                    707:    and put in forward order where initlist is used.  */
                    708: initlist:
1.1.1.2   root      709:          init
1.1       root      710:                { $$ = build_tree_list (NULL_TREE, $1); }
                    711:        | initlist ',' init
                    712:                { $$ = tree_cons (NULL_TREE, $3, $1); }
                    713:        ;
                    714: 
                    715: /* Any kind of declarator (thus, all declarators allowed
                    716:    after an explicit typespec).  */
                    717: 
                    718: declarator:
                    719:          after_type_declarator
                    720:        | notype_declarator
                    721:        ;
                    722: 
                    723: /* A declarator that is allowed only after an explicit typespec.  */
                    724: 
                    725: after_type_declarator:
                    726:          '(' after_type_declarator ')'
                    727:                { $$ = $2; }
                    728:        | after_type_declarator '(' parmlist_or_identifiers  %prec '.'
                    729:                { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
                    730: /*     | after_type_declarator '(' error ')'  %prec '.'
                    731:                { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
                    732:                  poplevel (0, 0, 0); }  */
                    733:        | after_type_declarator '[' expr ']'  %prec '.'
                    734:                { $$ = build_nt (ARRAY_REF, $1, $3); }
                    735:        | after_type_declarator '[' ']'  %prec '.'
                    736:                { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
                    737:        | '*' type_quals after_type_declarator  %prec UNARY
                    738:                { $$ = make_pointer_declarator ($2, $3); }
                    739:        | TYPENAME
                    740:        ;
                    741: 
                    742: /* Kinds of declarator that can appear in a parameter list
                    743:    in addition to notype_declarator.  This is like after_type_declarator
                    744:    but does not allow a typedef name in parentheses as an identifier
                    745:    (because it would conflict with a function with that typedef as arg).  */
                    746: 
                    747: parm_declarator:
                    748:          parm_declarator '(' parmlist_or_identifiers  %prec '.'
                    749:                { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
                    750: /*     | parm_declarator '(' error ')'  %prec '.'
                    751:                { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
                    752:                  poplevel (0, 0, 0); }  */
                    753:        | parm_declarator '[' expr ']'  %prec '.'
                    754:                { $$ = build_nt (ARRAY_REF, $1, $3); }
                    755:        | parm_declarator '[' ']'  %prec '.'
                    756:                { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
                    757:        | '*' type_quals parm_declarator  %prec UNARY
                    758:                { $$ = make_pointer_declarator ($2, $3); }
                    759:        | TYPENAME
                    760:        ;
                    761: 
                    762: /* A declarator allowed whether or not there has been
                    763:    an explicit typespec.  These cannot redeclare a typedef-name.  */
                    764: 
                    765: notype_declarator:
                    766:          notype_declarator '(' parmlist_or_identifiers  %prec '.'
                    767:                { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
                    768: /*     | notype_declarator '(' error ')'  %prec '.'
                    769:                { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
                    770:                  poplevel (0, 0, 0); }  */
                    771:        | '(' notype_declarator ')'
                    772:                { $$ = $2; }
                    773:        | '*' type_quals notype_declarator  %prec UNARY
                    774:                { $$ = make_pointer_declarator ($2, $3); }
                    775:        | notype_declarator '[' expr ']'  %prec '.'
                    776:                { $$ = build_nt (ARRAY_REF, $1, $3); }
                    777:        | notype_declarator '[' ']'  %prec '.'
                    778:                { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
                    779:        | IDENTIFIER
                    780:        ;
                    781: 
                    782: structsp:
                    783:          STRUCT identifier '{'
                    784:                { $$ = start_struct (RECORD_TYPE, $2);
                    785:                  /* Start scope of tag before parsing components.  */
                    786:                }
                    787:          component_decl_list '}'
                    788:                { $$ = finish_struct ($<ttype>4, $5);
                    789:                  /* Really define the structure.  */
                    790:                }
                    791:        | STRUCT '{' component_decl_list '}'
                    792:                { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
                    793:                                      $3); }
                    794:        | STRUCT identifier
                    795:                { $$ = xref_tag (RECORD_TYPE, $2); }
                    796:        | UNION identifier '{'
                    797:                { $$ = start_struct (UNION_TYPE, $2); }
                    798:          component_decl_list '}'
                    799:                { $$ = finish_struct ($<ttype>4, $5); }
                    800:        | UNION '{' component_decl_list '}'
                    801:                { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
                    802:                                      $3); }
                    803:        | UNION identifier
                    804:                { $$ = xref_tag (UNION_TYPE, $2); }
                    805:        | ENUM identifier '{'
                    806:                { $<itype>3 = suspend_momentary ();
                    807:                  $$ = start_enum ($2); }
1.1.1.5   root      808:          enumlist maybecomma_warn '}'
1.1       root      809:                { $$ = finish_enum ($<ttype>4, nreverse ($5));
                    810:                  resume_momentary ($<itype>3); }
                    811:        | ENUM '{'
                    812:                { $<itype>2 = suspend_momentary ();
                    813:                  $$ = start_enum (NULL_TREE); }
1.1.1.5   root      814:          enumlist maybecomma_warn '}'
1.1       root      815:                { $$ = finish_enum ($<ttype>3, nreverse ($4));
                    816:                  resume_momentary ($<itype>2); }
                    817:        | ENUM identifier
                    818:                { $$ = xref_tag (ENUMERAL_TYPE, $2); }
                    819:        ;
                    820: 
                    821: maybecomma:
                    822:          /* empty */
                    823:        | ','
                    824:        ;
                    825: 
1.1.1.5   root      826: maybecomma_warn:
                    827:          /* empty */
                    828:        | ','
                    829:                { if (pedantic) warning ("comma at end of enumerator list"); }
                    830:        ;
                    831: 
1.1       root      832: component_decl_list:   /* empty */
                    833:                { $$ = NULL_TREE; }
                    834:        | component_decl_list component_decl ';'
                    835:                { $$ = chainon ($1, $2); }
                    836:        | component_decl_list ';'
1.1.1.11  root      837:                { if (pedantic)
1.1       root      838:                    warning ("extra semicolon in struct or union specified"); }
                    839:        ;
                    840: 
                    841: /* There is a shift-reduce conflict here, because `components' may
                    842:    start with a `typename'.  It happens that shifting (the default resolution)
                    843:    does the right thing, because it treats the `typename' as part of
                    844:    a `typed_typespecs'.
                    845: 
                    846:    It is possible that this same technique would allow the distinction
                    847:    between `notype_initdecls' and `initdecls' to be eliminated.
                    848:    But I am being cautious and not trying it.  */
                    849: 
                    850: component_decl:
                    851:        typed_typespecs setspecs components
                    852:                { $$ = $3;
1.1.1.11  root      853:                  current_declspecs = TREE_VALUE (declspec_stack);
                    854:                  declspec_stack = TREE_CHAIN (declspec_stack);
1.1       root      855:                  resume_momentary ($2); }
                    856:        | nonempty_type_quals setspecs components
                    857:                { $$ = $3;
1.1.1.11  root      858:                  current_declspecs = TREE_VALUE (declspec_stack);
                    859:                  declspec_stack = TREE_CHAIN (declspec_stack);
1.1       root      860:                  resume_momentary ($2); }
                    861:        | error
                    862:                { $$ = NULL_TREE; }
                    863:        ;
                    864: 
                    865: components:
                    866:          /* empty */
1.1.1.10  root      867:                { if (pedantic)
                    868:                    warning ("ANSI C forbids member declarations with no members");
                    869:                  $$ = NULL_TREE; }
1.1       root      870:        | component_declarator
                    871:        | components ',' component_declarator
                    872:                { $$ = chainon ($1, $3); }
                    873:        ;
                    874: 
                    875: component_declarator:
1.1.1.11  root      876:        declarator maybe_attribute
1.1       root      877:                { $$ = grokfield (input_filename, lineno, $1, current_declspecs, NULL_TREE); }
1.1.1.11  root      878:        | declarator ':' expr_no_commas maybe_attribute
1.1       root      879:                { $$ = grokfield (input_filename, lineno, $1, current_declspecs, $3); }
                    880:        | ':' expr_no_commas
                    881:                { $$ = grokfield (input_filename, lineno, NULL_TREE, current_declspecs, $2); }
                    882:        ;
                    883: 
                    884: /* We chain the enumerators in reverse order.
                    885:    They are put in forward order where enumlist is used.
                    886:    (The order used to be significant, but no longer is so.
                    887:    However, we still maintain the order, just to be clean.)  */
                    888: 
                    889: enumlist:
                    890:          enumerator
                    891:        | enumlist ',' enumerator
                    892:                { $$ = chainon ($3, $1); }
                    893:        ;
                    894: 
                    895: 
                    896: enumerator:
                    897:          identifier
                    898:                { $$ = build_enumerator ($1, NULL_TREE); }
                    899:        | identifier '=' expr_no_commas
                    900:                { $$ = build_enumerator ($1, $3); }
                    901:        ;
                    902: 
                    903: typename:
                    904:        typed_typespecs absdcl
                    905:                { $$ = build_tree_list ($1, $2); }
                    906:        | nonempty_type_quals absdcl
                    907:                { $$ = build_tree_list ($1, $2); }
                    908:        ;
1.1.1.11  root      909: 
1.1       root      910: absdcl:   /* an absolute declarator */
                    911:        /* empty */
                    912:                { $$ = NULL_TREE; }
                    913:        | absdcl1
                    914:        ;
                    915: 
                    916: nonempty_type_quals:
                    917:          TYPE_QUAL
                    918:                { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
                    919:        | nonempty_type_quals TYPE_QUAL
                    920:                { $$ = tree_cons (NULL_TREE, $2, $1); }
                    921:        ;
                    922: 
                    923: type_quals:
                    924:          /* empty */
                    925:                { $$ = NULL_TREE; }
                    926:        | type_quals TYPE_QUAL
                    927:                { $$ = tree_cons (NULL_TREE, $2, $1); }
                    928:        ;
                    929: 
                    930: absdcl1:  /* a nonempty absolute declarator */
                    931:          '(' absdcl1 ')'
                    932:                { $$ = $2; }
                    933:          /* `(typedef)1' is `int'.  */
                    934:        | '*' type_quals absdcl1  %prec UNARY
                    935:                { $$ = make_pointer_declarator ($2, $3); }
                    936:        | '*' type_quals  %prec UNARY
                    937:                { $$ = make_pointer_declarator ($2, NULL_TREE); }
                    938:        | absdcl1 '(' parmlist  %prec '.'
                    939:                { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
                    940:        | absdcl1 '[' expr ']'  %prec '.'
                    941:                { $$ = build_nt (ARRAY_REF, $1, $3); }
                    942:        | absdcl1 '[' ']'  %prec '.'
                    943:                { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
                    944:        | '(' parmlist  %prec '.'
                    945:                { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
                    946:        | '[' expr ']'  %prec '.'
                    947:                { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
                    948:        | '[' ']'  %prec '.'
                    949:                { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
                    950:        ;
                    951: 
                    952: /* at least one statement, the first of which parses without error.  */
                    953: /* stmts is used only after decls, so an invalid first statement
                    954:    is actually regarded as an invalid decl and part of the decls.  */
                    955: 
                    956: stmts:
                    957:        stmt
                    958:        | stmts stmt
                    959:        | stmts errstmt
                    960:        ;
                    961: 
                    962: xstmts:
                    963:        /* empty */
                    964:        | stmts
                    965:        ;
                    966: 
                    967: errstmt:  error ';'
                    968:        ;
                    969: 
                    970: pushlevel:  /* empty */
                    971:                { pushlevel (0);
                    972:                  clear_last_expr ();
                    973:                  push_momentary ();
                    974:                  expand_start_bindings (0); }
                    975:        ;
                    976: 
                    977: /* This is the body of a function definition.
                    978:    It causes syntax errors to ignore to the next openbrace.  */
                    979: compstmt_or_error:
                    980:          compstmt
1.1.1.11  root      981:                {}
1.1       root      982:        | error compstmt
                    983:        ;
                    984: 
                    985: compstmt: '{' '}'
1.1.1.11  root      986:                { $$ = 0; }
1.1       root      987:        | '{' pushlevel decls xstmts '}'
1.1.1.2   root      988:                { expand_end_bindings (getdecls (), 1, 0);
1.1.1.11  root      989:                  $$ = poplevel (1, 1, 0);
1.1       root      990:                  pop_momentary (); }
                    991:        | '{' pushlevel error '}'
1.1.1.12! root      992:                { expand_end_bindings (getdecls (), kept_level_p (), 0);
        !           993:                  $$ = poplevel (kept_level_p (), 0, 0);
1.1       root      994:                  pop_momentary (); }
                    995:        | '{' pushlevel stmts '}'
1.1.1.12! root      996:                { expand_end_bindings (getdecls (), kept_level_p (), 0);
        !           997:                  $$ = poplevel (kept_level_p (), 0, 0);
1.1       root      998:                  pop_momentary (); }
                    999:        ;
                   1000: 
                   1001: simple_if:
                   1002:          IF '(' expr ')'
1.1.1.6   root     1003:                { emit_line_note (input_filename, lineno);
1.1       root     1004:                  expand_start_cond (truthvalue_conversion ($3), 0); }
                   1005:          stmt
                   1006:        ;
                   1007: 
                   1008: stmt:
1.1.1.11  root     1009:          compstmt      {}
1.1       root     1010:        | expr ';'
1.1.1.6   root     1011:                { emit_line_note (input_filename, lineno);
1.1.1.11  root     1012:                  /* Do default conversion if safe and possibly important,
                   1013:                     in case within ({...}).  */
                   1014:                  if ((TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
                   1015:                       && lvalue_p ($1))
                   1016:                      || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
                   1017:                    $1 = default_conversion ($1);
1.1       root     1018:                  expand_expr_stmt ($1);
                   1019:                  clear_momentary (); }
                   1020:        | simple_if ELSE
                   1021:                { expand_start_else (); }
                   1022:          stmt
                   1023:                { expand_end_else (); }
1.1.1.10  root     1024:        | simple_if %prec IF
1.1       root     1025:                { expand_end_cond (); }
                   1026:        | WHILE
1.1.1.11  root     1027:                { emit_nop ();
                   1028:                  emit_line_note (input_filename, lineno);
1.1       root     1029:                  expand_start_loop (1); }
                   1030:          '(' expr ')'
1.1.1.6   root     1031:                { emit_line_note (input_filename, lineno);
1.1       root     1032:                  expand_exit_loop_if_false (truthvalue_conversion ($4)); }
                   1033:          stmt
                   1034:                { expand_end_loop (); }
                   1035:        | DO
1.1.1.11  root     1036:                { emit_nop ();
                   1037:                  emit_line_note (input_filename, lineno);
1.1       root     1038:                  expand_start_loop_continue_elsewhere (1); }
                   1039:          stmt WHILE
                   1040:                { expand_loop_continue_here (); }
                   1041:          '(' expr ')' ';'
1.1.1.6   root     1042:                { emit_line_note (input_filename, lineno);
1.1       root     1043:                  expand_exit_loop_if_false (truthvalue_conversion ($7));
                   1044:                  expand_end_loop ();
                   1045:                  clear_momentary (); }
1.1.1.11  root     1046:        | FOR
1.1       root     1047:          '(' xexpr ';'
1.1.1.11  root     1048:                { emit_nop ();
                   1049:                  emit_line_note (input_filename, lineno);
1.1       root     1050:                  if ($3) expand_expr_stmt ($3);
                   1051:                  expand_start_loop_continue_elsewhere (1); }
                   1052:          xexpr ';'
1.1.1.6   root     1053:                { emit_line_note (input_filename, lineno);
1.1       root     1054:                  if ($6)
                   1055:                    expand_exit_loop_if_false (truthvalue_conversion ($6)); }
                   1056:          xexpr ')'
                   1057:                /* Don't let the tree nodes for $9 be discarded
                   1058:                   by clear_momentary during the parsing of the next stmt.  */
                   1059:                { push_momentary ();
                   1060:                  $<itype>10 = lineno; }
                   1061:          stmt
1.1.1.6   root     1062:                { emit_line_note (input_filename, $<itype>10);
1.1       root     1063:                  expand_loop_continue_here ();
                   1064:                  if ($9)
                   1065:                    expand_expr_stmt ($9);
                   1066:                  pop_momentary ();
                   1067:                  expand_end_loop (); }
                   1068:        | SWITCH '(' expr ')'
1.1.1.6   root     1069:                { emit_line_note (input_filename, lineno);
1.1       root     1070:                  c_expand_start_case ($3);
                   1071:                  /* Don't let the tree nodes for $3 be discarded by
                   1072:                     clear_momentary during the parsing of the next stmt.  */
                   1073:                  push_momentary (); }
                   1074:          stmt
1.1.1.10  root     1075:                { expand_end_case ($3);
1.1       root     1076:                  pop_momentary (); }
                   1077:        | CASE expr ':'
                   1078:                { register tree value = fold ($2);
                   1079:                  register tree label
                   1080:                    = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
                   1081: 
1.1.1.9   root     1082:                  /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
                   1083:                     Strip such NOP_EXPRs.  */
                   1084:                  if (TREE_CODE (value) == NOP_EXPR
                   1085:                      && TREE_TYPE (value) == TREE_TYPE (TREE_OPERAND (value, 0)))
                   1086:                    value = TREE_OPERAND (value, 0);
                   1087: 
1.1       root     1088:                  if (TREE_CODE (value) != INTEGER_CST
                   1089:                      && value != error_mark_node)
                   1090:                    {
                   1091:                      error ("case label does not reduce to an integer constant");
                   1092:                      value = error_mark_node;
                   1093:                    }
                   1094:                  else
                   1095:                    /* Promote char or short to int.  */
                   1096:                    value = default_conversion (value);
                   1097:                  if (value != error_mark_node)
                   1098:                    {
                   1099:                      int success = pushcase (value, label);
                   1100:                      if (success == 1)
                   1101:                        error ("case label not within a switch statement");
                   1102:                      else if (success == 2)
                   1103:                        error ("duplicate case value");
                   1104:                      else if (success == 3)
                   1105:                        warning ("case value out of range");
                   1106:                    }
                   1107:                }
                   1108:          stmt
                   1109:        | DEFAULT ':'
                   1110:                {
                   1111:                  register tree label
                   1112:                    = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
                   1113:                  int success = pushcase (NULL_TREE, label);
                   1114:                  if (success == 1)
                   1115:                    error ("default label not within a switch statement");
                   1116:                  else if (success == 2)
                   1117:                    error ("multiple default labels in one switch");
                   1118:                }
                   1119:          stmt
                   1120:        | BREAK ';'
1.1.1.6   root     1121:                { emit_line_note (input_filename, lineno);
1.1       root     1122:                  if ( ! expand_exit_something ())
                   1123:                    error ("break statement not within loop or switch"); }
1.1.1.11  root     1124:        | CONTINUE ';'
1.1.1.6   root     1125:                { emit_line_note (input_filename, lineno);
1.1       root     1126:                  if (! expand_continue_loop ())
                   1127:                    error ("continue statement not within a loop"); }
                   1128:        | RETURN ';'
1.1.1.6   root     1129:                { emit_line_note (input_filename, lineno);
1.1       root     1130:                  c_expand_return (NULL_TREE); }
                   1131:        | RETURN expr ';'
1.1.1.6   root     1132:                { emit_line_note (input_filename, lineno);
1.1       root     1133:                  c_expand_return ($2); }
                   1134:        | ASM maybe_type_qual '(' string ')' ';'
1.1.1.6   root     1135:                { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
1.1.1.11  root     1136:                  emit_line_note (input_filename, lineno);
1.1       root     1137:                  expand_asm ($4); }
                   1138:        /* This is the case with just output operands.  */
                   1139:        | ASM maybe_type_qual '(' string ':' asm_operands ')' ';'
1.1.1.6   root     1140:                { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
1.1.1.11  root     1141:                  emit_line_note (input_filename, lineno);
1.1.1.3   root     1142:                  c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
1.1.1.7   root     1143:                                         $2 == ridpointers[(int)RID_VOLATILE],
                   1144:                                         input_filename, lineno); }
1.1       root     1145:        /* This is the case with input operands as well.  */
                   1146:        | ASM maybe_type_qual '(' string ':' asm_operands ':' asm_operands ')' ';'
1.1.1.6   root     1147:                { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
1.1.1.11  root     1148:                  emit_line_note (input_filename, lineno);
1.1.1.3   root     1149:                  c_expand_asm_operands ($4, $6, $8, NULL_TREE,
1.1.1.7   root     1150:                                         $2 == ridpointers[(int)RID_VOLATILE],
                   1151:                                         input_filename, lineno); }
1.1.1.3   root     1152:        /* This is the case with clobbered registers as well.  */
                   1153:        | ASM maybe_type_qual '(' string ':' asm_operands ':'
                   1154:          asm_operands ':' asm_clobbers ')' ';'
1.1.1.6   root     1155:                { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
1.1.1.11  root     1156:                  emit_line_note (input_filename, lineno);
1.1.1.3   root     1157:                  c_expand_asm_operands ($4, $6, $8, $10,
1.1.1.7   root     1158:                                         $2 == ridpointers[(int)RID_VOLATILE],
                   1159:                                         input_filename, lineno); }
1.1       root     1160:        | GOTO identifier ';'
                   1161:                { tree decl;
1.1.1.6   root     1162:                  emit_line_note (input_filename, lineno);
1.1       root     1163:                  decl = lookup_label ($2);
1.1.1.10  root     1164:                  TREE_USED (decl) = 1;
1.1       root     1165:                  expand_goto (decl); }
                   1166:        | identifier ':'
                   1167:                { tree label = define_label (input_filename, lineno, $1);
1.1.1.11  root     1168:                  emit_nop ();
1.1       root     1169:                  if (label)
                   1170:                    expand_label (label); }
                   1171:          stmt
                   1172:        | ';'
                   1173:        ;
                   1174: 
1.1.1.6   root     1175: /* Either a type-qualifier or nothing.  First thing in an `asm' statement.  */
                   1176: 
1.1       root     1177: maybe_type_qual:
                   1178:        /* empty */
1.1.1.6   root     1179:                { if (pedantic)
                   1180:                    warning ("ANSI C forbids use of `asm' keyword");
1.1.1.7   root     1181:                  emit_line_note (input_filename, lineno); }
1.1       root     1182:        | TYPE_QUAL
1.1.1.6   root     1183:                { if (pedantic)
                   1184:                    warning ("ANSI C forbids use of `asm' keyword");
1.1.1.7   root     1185:                  emit_line_note (input_filename, lineno); }
1.1       root     1186:        ;
                   1187: 
                   1188: xexpr:
                   1189:        /* empty */
                   1190:                { $$ = NULL_TREE; }
                   1191:        | expr
                   1192:        ;
                   1193: 
                   1194: /* These are the operands other than the first string and colon
                   1195:    in  asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x))  */
                   1196: asm_operands: /* empty */
                   1197:                { $$ = NULL_TREE; }
                   1198:        | nonnull_asm_operands
                   1199:        ;
                   1200: 
                   1201: nonnull_asm_operands:
                   1202:          asm_operand
                   1203:        | nonnull_asm_operands ',' asm_operand
                   1204:                { $$ = chainon ($1, $3); }
                   1205:        ;
                   1206: 
                   1207: asm_operand:
1.1.1.3   root     1208:          STRING '(' expr ')'
1.1       root     1209:                { $$ = build_tree_list ($1, $3); }
                   1210:        ;
                   1211: 
1.1.1.3   root     1212: asm_clobbers:
1.1.1.11  root     1213:          string
                   1214:                { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
                   1215:        | asm_clobbers ',' string
                   1216:                { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
1.1.1.3   root     1217:        ;
                   1218: 
1.1       root     1219: /* This is what appears inside the parens in a function declarator.
                   1220:    Its value is a list of ..._TYPE nodes.  */
                   1221: parmlist:
1.1.1.11  root     1222:                { pushlevel (0);
                   1223:                  declare_parm_level (); }
1.1       root     1224:          parmlist_1
1.1.1.9   root     1225:                { $$ = $2;
                   1226:                  parmlist_tags_warning ();
                   1227:                  poplevel (0, 0, 0); }
1.1       root     1228:        ;
                   1229: 
                   1230: /* This is referred to where either a parmlist or an identifier list is ok.
                   1231:    Its value is a list of ..._TYPE nodes or a list of identifiers.  */
                   1232: parmlist_or_identifiers:
1.1.1.11  root     1233:                { pushlevel (0);
                   1234:                  declare_parm_level (); }
1.1       root     1235:          parmlist_or_identifiers_1
1.1.1.9   root     1236:                { $$ = $2;
                   1237:                  parmlist_tags_warning ();
                   1238:                  poplevel (0, 0, 0); }
1.1       root     1239:        ;
                   1240: 
                   1241: parmlist_or_identifiers_1:
                   1242:          parmlist_2 ')'
                   1243:        | identifiers ')'
                   1244:                { $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
                   1245:        | error ')'
                   1246:                { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
                   1247:        ;
                   1248: 
                   1249: parmlist_1:
                   1250:          parmlist_2 ')'
                   1251:        | error ')'
                   1252:                { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
                   1253:        ;
                   1254: 
                   1255: /* This is what appears inside the parens in a function declarator.
                   1256:    Is value is represented in the format that grokdeclarator expects.  */
                   1257: parmlist_2:  /* empty */
                   1258:                { $$ = get_parm_info (0); }
                   1259:        | parms
                   1260:                { $$ = get_parm_info (1); }
                   1261:        | parms ',' ELLIPSIS
                   1262:                { $$ = get_parm_info (0); }
                   1263:        ;
                   1264: 
1.1.1.11  root     1265: parms:
1.1       root     1266:        parm
                   1267:                { push_parm_decl ($1); }
                   1268:        | parms ',' parm
                   1269:                { push_parm_decl ($3); }
                   1270:        ;
                   1271: 
                   1272: /* A single parameter declaration or parameter type name,
                   1273:    as found in a parmlist.  */
                   1274: parm:
                   1275:          typed_declspecs parm_declarator
                   1276:                { $$ = build_tree_list ($1, $2) ; }
                   1277:        | typed_declspecs notype_declarator
                   1278:                { $$ = build_tree_list ($1, $2) ; }
                   1279:        | typed_declspecs absdcl
                   1280:                { $$ = build_tree_list ($1, $2); }
                   1281:        | declmods notype_declarator
                   1282:                { $$ = build_tree_list ($1, $2) ; }
                   1283:        | declmods absdcl
                   1284:                { $$ = build_tree_list ($1, $2); }
                   1285:        ;
                   1286: 
                   1287: /* A nonempty list of identifiers.  */
1.1.1.11  root     1288: identifiers:
1.1       root     1289:        IDENTIFIER
                   1290:                { $$ = build_tree_list (NULL_TREE, $1); }
                   1291:        | identifiers ',' IDENTIFIER
                   1292:                { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
                   1293:        ;
                   1294: %%
                   1295: 
                   1296: /* Return something to represent absolute declarators containing a *.
                   1297:    TARGET is the absolute declarator that the * contains.
                   1298:    TYPE_QUALS is a list of modifiers such as const or volatile
                   1299:    to apply to the pointer type, represented as identifiers.
                   1300: 
                   1301:    We return an INDIRECT_REF whose "contents" are TARGET
                   1302:    and whose type is the modifier list.  */
1.1.1.11  root     1303: 
1.1       root     1304: static tree
                   1305: make_pointer_declarator (type_quals, target)
                   1306:      tree type_quals, target;
                   1307: {
                   1308:   return build (INDIRECT_REF, type_quals, target);
                   1309: }
                   1310: 
                   1311: /* Given a chain of STRING_CST nodes,
                   1312:    concatenate them into one STRING_CST
                   1313:    and give it a suitable array-of-chars data type.  */
                   1314: 
                   1315: static tree
                   1316: combine_strings (strings)
                   1317:      tree strings;
                   1318: {
                   1319:   register tree value, t;
                   1320:   register int length = 1;
                   1321:   int wide_length = 0;
                   1322:   int wide_flag = 0;
                   1323: 
                   1324:   if (TREE_CHAIN (strings))
                   1325:     {
                   1326:       /* More than one in the chain, so concatenate.  */
                   1327:       register char *p, *q;
                   1328: 
                   1329:       /* Don't include the \0 at the end of each substring,
                   1330:         except for the last one.
                   1331:         Count wide strings and ordinary strings separately.  */
                   1332:       for (t = strings; t; t = TREE_CHAIN (t))
                   1333:        {
                   1334:          if (TREE_TYPE (t) == int_array_type_node)
                   1335:            {
                   1336:              wide_length += (TREE_STRING_LENGTH (t) - 1);
                   1337:              wide_flag = 1;
                   1338:            }
                   1339:          else
                   1340:            length += (TREE_STRING_LENGTH (t) - 1);
                   1341:        }
                   1342: 
                   1343:       /* If anything is wide, the non-wides will be converted,
                   1344:         which makes them take more space.  */
                   1345:       if (wide_flag)
                   1346:        length = length * UNITS_PER_WORD + wide_length;
                   1347: 
1.1.1.11  root     1348:       p = (char *) savealloc (length);
1.1       root     1349: 
                   1350:       /* Copy the individual strings into the new combined string.
                   1351:         If the combined string is wide, convert the chars to ints
                   1352:         for any individual strings that are not wide.  */
                   1353: 
                   1354:       q = p;
                   1355:       for (t = strings; t; t = TREE_CHAIN (t))
                   1356:        {
                   1357:          int len = TREE_STRING_LENGTH (t) - 1;
                   1358:          if ((TREE_TYPE (t) == int_array_type_node) == wide_flag)
                   1359:            {
                   1360:              bcopy (TREE_STRING_POINTER (t), q, len);
                   1361:              q += len;
                   1362:            }
                   1363:          else
                   1364:            {
                   1365:              int i;
                   1366:              for (i = 0; i < len; i++)
                   1367:                ((int *) q)[i] = TREE_STRING_POINTER (t)[i];
                   1368:              q += len * UNITS_PER_WORD;
                   1369:            }
                   1370:        }
                   1371:       *q = 0;
                   1372: 
                   1373:       value = make_node (STRING_CST);
                   1374:       TREE_STRING_POINTER (value) = p;
                   1375:       TREE_STRING_LENGTH (value) = length;
                   1376:       TREE_LITERAL (value) = 1;
                   1377:     }
                   1378:   else
                   1379:     {
                   1380:       value = strings;
                   1381:       length = TREE_STRING_LENGTH (value);
                   1382:       if (TREE_TYPE (value) == int_array_type_node)
                   1383:        wide_flag = 1;
                   1384:     }
                   1385: 
1.1.1.3   root     1386:   /* Create the array type for the string constant.
                   1387:      -Wwrite-strings says make the string constant an array of const char
                   1388:      so that copying it to a non-const pointer will get a warning.  */
                   1389:   if (warn_write_strings)
                   1390:     {
                   1391:       tree elements
                   1392:        = build_type_variant (wide_flag ? integer_type_node : char_type_node,
                   1393:                              1, 0);
                   1394:       TREE_TYPE (value)
                   1395:        = build_array_type (elements,
                   1396:                            build_index_type (build_int_2 (length - 1, 0)));
                   1397:     }
                   1398:   else
                   1399:     TREE_TYPE (value)
                   1400:       = build_array_type (wide_flag ? integer_type_node : char_type_node,
                   1401:                          build_index_type (build_int_2 (length - 1, 0)));
1.1       root     1402:   TREE_LITERAL (value) = 1;
                   1403:   TREE_STATIC (value) = 1;
                   1404:   return value;
                   1405: }
                   1406: 
                   1407: int lineno;                    /* current line number in file being read */
                   1408: 
                   1409: FILE *finput;                  /* input file.
                   1410:                                   Normally a pipe from the preprocessor.  */
                   1411: 
                   1412: /* lexical analyzer */
                   1413: 
1.1.1.7   root     1414: static int maxtoken;           /* Current nominal length of token buffer.  */
1.1       root     1415: static char *token_buffer;     /* Pointer to token buffer.
                   1416:                                   Actual allocated length is maxtoken + 2.  */
1.1.1.7   root     1417: static int max_wide;           /* Current nominal length of wide_buffer.  */
                   1418: static int *wide_buffer;       /* Pointer to wide-string buffer.
                   1419:                                   Actual allocated length is max_wide + 1.  */
                   1420: 
                   1421: /* Nonzero if end-of-file has been seen on input.  */
1.1.1.5   root     1422: static int end_of_file;
1.1       root     1423: 
1.1.1.9   root     1424: /* Data type that represents the GNU C reserved words. */
                   1425: struct resword { char *name; short token; enum rid rid; };
1.1       root     1426: 
1.1.1.9   root     1427: #define MIN_WORD_LENGTH     2      /* minimum size for C keyword */
1.1.1.11  root     1428: #define MAX_WORD_LENGTH     13     /* maximum size for C keyword */
                   1429: #define MIN_HASH_VALUE      7      /* range of the hash keys values  */
                   1430: #define MAX_HASH_VALUE      91     /* for the perfect hash generator */
1.1       root     1431: #define NORID RID_UNUSED
                   1432: 
1.1.1.4   root     1433: /* This function performs the minimum-perfect hash mapping from input
1.1.1.11  root     1434:    string to reswords table index.  It only looks at the first and
                   1435:    last characters in the string, thus assuring the O(1) lookup time
1.1.1.4   root     1436:    (this keeps our constant down to an insignificant amount!).  Compiling
                   1437:    the following 2 functions as inline removes all overhead of the
                   1438:    function calls. */
                   1439: 
                   1440: #ifdef __GNUC__
1.1.1.11  root     1441: __inline
1.1.1.4   root     1442: #endif
1.1.1.11  root     1443: static int
1.1.1.4   root     1444: hash (str, len)
1.1.1.10  root     1445:      register char *str;
                   1446:      register int len;
1.1.1.4   root     1447: {
1.1.1.9   root     1448: /* This table is used to build the hash table index that recognizes
1.1.1.11  root     1449:    reserved words in 0(1) steps.  It is larger than strictly necessary,
                   1450:    but I'm trading off the space for the time-saving luxury of avoiding
                   1451:    subtraction of an offset.  All those ``91's'' (actually just a
                   1452:    short-hand for MAX_HASH_VALUE #defined above) are used to speed up
                   1453:    the search when the string found on the input stream doesn't have a
                   1454:    first or last character that is part of the set of alphabetic
                   1455:    characters that comprise the first or last characters in C
1.1.1.9   root     1456:    reserved words. */
1.1.1.4   root     1457: 
1.1.1.11  root     1458:   static int hash_table[] =
1.1.1.9   root     1459:     {
1.1.1.11  root     1460:      91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
                   1461:      91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
                   1462:      91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
                   1463:      91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
                   1464:      91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
                   1465:      91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
                   1466:      91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
                   1467:      91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
                   1468:      91, 91, 91, 91, 91, 91, 91, 91, 91, 91,
                   1469:      91, 91, 91, 91, 91,  1, 91,  2,  1, 32,
                   1470:       7,  5, 18, 20,  1, 17, 91,  1, 18,  1,
                   1471:      28,  1, 23, 91, 12, 20,  1, 41,  7, 15,
                   1472:      91, 91, 10, 91, 91, 91, 91, 91,
1.1.1.9   root     1473:     };
1.1.1.11  root     1474:   register int hval = len ;
1.1.1.9   root     1475: 
1.1.1.11  root     1476:   switch (hval)
                   1477:     {
                   1478:       default:
                   1479:       case 3:
                   1480:         hval += hash_table[str[2]];
                   1481:       case 2:
                   1482:       case 1:
                   1483:         return hval + hash_table[str[0]] + hash_table[str[len - 1]];
                   1484:     }
1.1.1.4   root     1485: }
                   1486: 
1.1.1.9   root     1487: /* This routine attempts to match the string found in the reswords table
1.1.1.11  root     1488:    with the one from the input stream.  If all the relevant details
1.1.1.9   root     1489:    match then an actual strcmp comparison is performed and the address of
1.1.1.11  root     1490:    correct struct resword entry is returned.  Otherwise, a NULL
1.1.1.9   root     1491:    pointer is returned. */
1.1.1.4   root     1492: 
                   1493: #ifdef __GNUC__
1.1.1.11  root     1494: __inline
1.1.1.4   root     1495: #endif
1.1.1.10  root     1496: struct resword *
1.1.1.9   root     1497: is_reserved_word (str, len)
1.1.1.10  root     1498:      register char *str;
                   1499:      register int len;
1.1.1.4   root     1500: {
1.1.1.10  root     1501:   /* This is the hash table of keywords.
                   1502:      The order of keywords has been chosen for perfect hashing.
                   1503:      Therefore, this table cannot be updated by hand.
1.1.1.11  root     1504:      Use the program ``gperf,'' available with the latest libg++
                   1505:      distribution, to generate an updated table.  A file called
                   1506:      c-parse.gperf, distributed with GNU C, contains the keyword file.  */
1.1.1.9   root     1507: 
1.1.1.11  root     1508:   static struct resword reswords[] =
1.1.1.9   root     1509:     {
1.1.1.11  root     1510:       { "", }, { "", }, { "", }, { "", }, { "", }, { "", }, { "", }, 
                   1511:       {"asm",  ASM, NORID },
                   1512:       {"auto",  SCSPEC, RID_AUTO },
                   1513:       {"__asm",  ASM, NORID },
                   1514:       {"do",  DO, NORID },
                   1515:       {"__asm__",  ASM, NORID },
                   1516:       {"break",  BREAK, NORID },
                   1517:       {"__typeof__",  TYPEOF, NORID },
                   1518:       { "", }, 
                   1519:       {"__alignof__",  ALIGNOF, NORID },
                   1520:       { "", }, 
                   1521:       {"__attribute__",  ATTRIBUTE, NORID },
                   1522:       { "", }, 
                   1523:       {"__attribute",  ATTRIBUTE, NORID },
                   1524:       { "", }, 
                   1525:       {"__volatile__",  TYPE_QUAL, RID_VOLATILE },
                   1526:       {"int",  TYPESPEC, RID_INT },
                   1527:       {"__volatile",  TYPE_QUAL, RID_VOLATILE },
                   1528:       { "", }, 
                   1529:       {"float",  TYPESPEC, RID_FLOAT },
                   1530:       {"goto",  GOTO, NORID },
                   1531:       {"short",  TYPESPEC, RID_SHORT },
                   1532:       {"__typeof",  TYPEOF, NORID },
                   1533:       {"__inline__",  SCSPEC, RID_INLINE },
                   1534:       {"__alignof",  ALIGNOF, NORID },
                   1535:       {"__inline",  SCSPEC, RID_INLINE },
                   1536:       {"__signed__",  TYPESPEC, RID_SIGNED },
                   1537:       {"default",  DEFAULT, NORID },
                   1538:       {"else",  ELSE, NORID },
                   1539:       {"void",  TYPESPEC, RID_VOID },
                   1540:       {"__signed",  TYPESPEC, RID_SIGNED },
                   1541:       {"if",  IF, NORID },
                   1542:       {"volatile",  TYPE_QUAL, RID_VOLATILE },
                   1543:       {"struct",  STRUCT, NORID },
                   1544:       {"extern",  SCSPEC, RID_EXTERN },
                   1545:       {"__const",  TYPE_QUAL, RID_CONST },
                   1546:       {"while",  WHILE, NORID },
                   1547:       {"__const__",  TYPE_QUAL, RID_CONST },
                   1548:       {"switch",  SWITCH, NORID },
                   1549:       {"for",  FOR, NORID },
                   1550:       {"inline",  SCSPEC, RID_INLINE },
                   1551:       {"return",  RETURN, NORID },
                   1552:       {"typeof",  TYPEOF, NORID },
                   1553:       {"typedef",  SCSPEC, RID_TYPEDEF },
                   1554:       {"char",  TYPESPEC, RID_CHAR },
                   1555:       {"enum",  ENUM, NORID },
                   1556:       {"register",  SCSPEC, RID_REGISTER },
                   1557:       {"signed",  TYPESPEC, RID_SIGNED },
                   1558:       {"sizeof",  SIZEOF, NORID },
                   1559:       { "", }, { "", }, { "", }, { "", }, 
                   1560:       {"double",  TYPESPEC, RID_DOUBLE },
                   1561:       {"static",  SCSPEC, RID_STATIC },
                   1562:       {"case",  CASE, NORID },
                   1563:       { "", }, { "", }, { "", }, { "", }, 
                   1564:       {"const",  TYPE_QUAL, RID_CONST },
                   1565:       { "", }, { "", }, { "", }, 
                   1566:       {"long",  TYPESPEC, RID_LONG },
                   1567:       { "", }, { "", }, 
                   1568:       {"continue",  CONTINUE, NORID },
                   1569:       { "", }, { "", }, 
                   1570:       {"unsigned",  TYPESPEC, RID_UNSIGNED },
                   1571:       { "", }, { "", }, { "", }, { "", }, { "", }, { "", }, { "", }, { "", }, { "", }, 
                   1572:       { "", }, { "", }, { "", }, { "", }, { "", }, 
                   1573:       {"union",  UNION, NORID },
1.1.1.9   root     1574:     };
                   1575: 
1.1.1.11  root     1576:   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
1.1.1.4   root     1577:     {
                   1578:       register int key = hash (str, len);
                   1579: 
1.1.1.11  root     1580:       if (key <= MAX_HASH_VALUE)
1.1.1.9   root     1581:         {
                   1582:           register char *s = reswords[key].name;
                   1583: 
1.1.1.11  root     1584:           if (*s == *str && !strcmp (str + 1, s + 1))
1.1.1.9   root     1585:             return &reswords[key];
                   1586:         }
1.1.1.4   root     1587:     }
1.1.1.9   root     1588:   return 0;
1.1.1.4   root     1589: }
1.1       root     1590: 
1.1.1.9   root     1591: /* The elements of `ridpointers' are identifier nodes
                   1592:    for the reserved type names and storage classes.
                   1593:    It is indexed by a RID_... value.  */
                   1594: 
                   1595: tree ridpointers[(int) RID_MAX];
                   1596: 
                   1597: int check_newline ();
                   1598: 
1.1       root     1599: void
                   1600: init_lex ()
                   1601: {
                   1602:   /* Start it at 0, because check_newline is called at the very beginning
                   1603:      and will increment it to 1.  */
                   1604:   lineno = 0;
                   1605: 
                   1606:   maxtoken = 40;
1.1.1.7   root     1607:   token_buffer = (char *) xmalloc (maxtoken + 2);
                   1608:   max_wide = 40;
                   1609:   wide_buffer = (int *) xmalloc (max_wide + 1);
                   1610: 
1.1       root     1611:   ridpointers[(int) RID_INT] = get_identifier ("int");
                   1612:   ridpointers[(int) RID_CHAR] = get_identifier ("char");
                   1613:   ridpointers[(int) RID_VOID] = get_identifier ("void");
                   1614:   ridpointers[(int) RID_FLOAT] = get_identifier ("float");
                   1615:   ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
                   1616:   ridpointers[(int) RID_SHORT] = get_identifier ("short");
                   1617:   ridpointers[(int) RID_LONG] = get_identifier ("long");
                   1618:   ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
                   1619:   ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
                   1620:   ridpointers[(int) RID_INLINE] = get_identifier ("inline");
                   1621:   ridpointers[(int) RID_CONST] = get_identifier ("const");
                   1622:   ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
                   1623:   ridpointers[(int) RID_AUTO] = get_identifier ("auto");
                   1624:   ridpointers[(int) RID_STATIC] = get_identifier ("static");
                   1625:   ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
                   1626:   ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
                   1627:   ridpointers[(int) RID_REGISTER] = get_identifier ("register");
                   1628: }
                   1629: 
                   1630: static void
                   1631: reinit_parse_for_function ()
                   1632: {
                   1633: }
                   1634: 
                   1635: /* If C is not whitespace, return C.
                   1636:    Otherwise skip whitespace and return first nonwhite char read.  */
                   1637: 
                   1638: static int
                   1639: skip_white_space (c)
                   1640:      register int c;
                   1641: {
1.1.1.7   root     1642: #if 0
1.1       root     1643:   register int inside;
1.1.1.7   root     1644: #endif
1.1       root     1645: 
                   1646:   for (;;)
                   1647:     {
                   1648:       switch (c)
                   1649:        {
1.1.1.6   root     1650:          /* Don't recognize comments in cc1: all comments are removed by cpp,
                   1651:             and cpp output can include / and * consecutively as operators.  */
                   1652: #if 0
1.1       root     1653:        case '/':
                   1654:          c = getc (finput);
                   1655:          if (c != '*')
                   1656:            {
                   1657:              ungetc (c, finput);
                   1658:              return '/';
                   1659:            }
                   1660: 
                   1661:          c = getc (finput);
                   1662: 
                   1663:          inside = 1;
                   1664:          while (inside)
                   1665:            {
                   1666:              if (c == '*')
                   1667:                {
                   1668:                  while (c == '*')
                   1669:                    c = getc (finput);
                   1670: 
                   1671:                  if (c == '/')
                   1672:                    {
                   1673:                      inside = 0;
                   1674:                      c = getc (finput);
                   1675:                    }
                   1676:                }
                   1677:              else if (c == '\n')
                   1678:                {
                   1679:                  lineno++;
                   1680:                  c = getc (finput);
                   1681:                }
                   1682:              else if (c == EOF)
                   1683:                {
                   1684:                  error ("unterminated comment");
                   1685:                  break;
                   1686:                }
                   1687:              else
                   1688:                c = getc (finput);
                   1689:            }
                   1690: 
                   1691:          break;
1.1.1.6   root     1692: #endif
1.1       root     1693: 
                   1694:        case '\n':
                   1695:          c = check_newline ();
                   1696:          break;
                   1697: 
                   1698:        case ' ':
                   1699:        case '\t':
                   1700:        case '\f':
                   1701:        case '\r':
1.1.1.11  root     1702:        case '\v':
1.1       root     1703:        case '\b':
                   1704:          c = getc (finput);
                   1705:          break;
                   1706: 
                   1707:        case '\\':
                   1708:          c = getc (finput);
                   1709:          if (c == '\n')
                   1710:            lineno++;
                   1711:          else
                   1712:            error ("stray '\\' in program");
                   1713:          c = getc (finput);
                   1714:          break;
                   1715: 
                   1716:        default:
                   1717:          return (c);
                   1718:        }
                   1719:     }
                   1720: }
                   1721: 
                   1722: 
                   1723: 
                   1724: /* Make the token buffer longer, preserving the data in it.
                   1725:    P should point to just beyond the last valid character in the old buffer.
                   1726:    The value we return is a pointer to the new buffer
                   1727:    at a place corresponding to P.  */
                   1728: 
                   1729: static char *
                   1730: extend_token_buffer (p)
                   1731:      char *p;
                   1732: {
                   1733:   int offset = p - token_buffer;
                   1734: 
                   1735:   maxtoken = maxtoken * 2 + 10;
1.1.1.7   root     1736:   token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
1.1       root     1737: 
                   1738:   return token_buffer + offset;
                   1739: }
                   1740: 
                   1741: /* At the beginning of a line, increment the line number
1.1.1.8   root     1742:    and process any #-directive on this line.
                   1743:    If the line is a #-directive, read the entire line and return a newline.
                   1744:    Otherwise, return the line's first non-whitespace character.  */
1.1       root     1745: 
                   1746: int
                   1747: check_newline ()
                   1748: {
                   1749:   register int c;
                   1750:   register int token;
                   1751: 
1.1.1.8   root     1752:   lineno++;
1.1       root     1753: 
1.1.1.8   root     1754:   /* Read first nonwhite char on the line.  */
1.1       root     1755: 
1.1.1.8   root     1756:   c = getc (finput);
                   1757:   while (c == ' ' || c == '\t')
                   1758:     c = getc (finput);
1.1       root     1759: 
1.1.1.8   root     1760:   if (c != '#')
                   1761:     {
                   1762:       /* If not #, return it so caller will use it.  */
                   1763:       return c;
                   1764:     }
1.1       root     1765: 
1.1.1.8   root     1766:   /* Read first nonwhite char after the `#'.  */
1.1       root     1767: 
1.1.1.8   root     1768:   c = getc (finput);
                   1769:   while (c == ' ' || c == '\t')
                   1770:     c = getc (finput);
1.1       root     1771: 
1.1.1.8   root     1772:   /* If a letter follows, then if the word here is `line', skip
                   1773:      it and ignore it; otherwise, ignore the line, with an error
                   1774:      if the word isn't `pragma'.  */
1.1       root     1775: 
1.1.1.8   root     1776:   if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
                   1777:     {
                   1778:       if (c == 'p')
1.1       root     1779:        {
1.1.1.8   root     1780:          if (getc (finput) == 'r'
                   1781:              && getc (finput) == 'a'
                   1782:              && getc (finput) == 'g'
                   1783:              && getc (finput) == 'm'
                   1784:              && getc (finput) == 'a'
1.1.1.10  root     1785:              && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
1.1.1.8   root     1786:            goto skipline;
                   1787:        }
1.1       root     1788: 
1.1.1.8   root     1789:       else if (c == 'l')
                   1790:        {
                   1791:          if (getc (finput) == 'i'
                   1792:              && getc (finput) == 'n'
                   1793:              && getc (finput) == 'e'
                   1794:              && ((c = getc (finput)) == ' ' || c == '\t'))
                   1795:            goto linenum;
                   1796:        }
                   1797:       else if (c == 'i')
                   1798:        {
                   1799:          if (getc (finput) == 'd'
                   1800:              && getc (finput) == 'e'
                   1801:              && getc (finput) == 'n'
                   1802:              && getc (finput) == 't'
                   1803:              && ((c = getc (finput)) == ' ' || c == '\t'))
1.1       root     1804:            {
1.1.1.8   root     1805:              extern FILE *asm_out_file;
1.1       root     1806: 
1.1.1.8   root     1807:              if (pedantic)
                   1808:                error ("ANSI C does not allow #ident");
1.1       root     1809: 
1.1.1.8   root     1810:              /* Here we have just seen `#ident '.
                   1811:                 A string constant should follow.  */
1.1       root     1812: 
1.1.1.8   root     1813:              while (c == ' ' || c == '\t')
                   1814:                c = getc (finput);
1.1       root     1815: 
1.1.1.8   root     1816:              /* If no argument, ignore the line.  */
                   1817:              if (c == '\n')
                   1818:                return c;
                   1819: 
                   1820:              ungetc (c, finput);
                   1821:              token = yylex ();
                   1822:              if (token != STRING
                   1823:                  || TREE_CODE (yylval.ttype) != STRING_CST)
                   1824:                {
                   1825:                  error ("invalid #ident");
                   1826:                  goto skipline;
                   1827:                }
1.1       root     1828: 
1.1.1.5   root     1829: #ifdef ASM_OUTPUT_IDENT
1.1.1.8   root     1830:              ASM_OUTPUT_IDENT (asm_out_file, TREE_STRING_POINTER (yylval.ttype));
1.1.1.5   root     1831: #endif
1.1       root     1832: 
1.1.1.8   root     1833:              /* Skip the rest of this line.  */
                   1834:              goto skipline;
1.1       root     1835:            }
1.1.1.8   root     1836:        }
1.1       root     1837: 
1.1.1.8   root     1838:       error ("undefined or invalid # directive");
                   1839:       goto skipline;
                   1840:     }
1.1       root     1841: 
1.1.1.8   root     1842: linenum:
                   1843:   /* Here we have either `#line' or `# <nonletter>'.
                   1844:      In either case, it should be a line number; a digit should follow.  */
1.1       root     1845: 
1.1.1.8   root     1846:   while (c == ' ' || c == '\t')
                   1847:     c = getc (finput);
1.1       root     1848: 
1.1.1.8   root     1849:   /* If the # is the only nonwhite char on the line,
                   1850:      just ignore it.  Check the new newline.  */
                   1851:   if (c == '\n')
                   1852:     return c;
1.1       root     1853: 
1.1.1.8   root     1854:   /* Something follows the #; read a token.  */
1.1       root     1855: 
1.1.1.8   root     1856:   ungetc (c, finput);
                   1857:   token = yylex ();
1.1       root     1858: 
1.1.1.8   root     1859:   if (token == CONSTANT
                   1860:       && TREE_CODE (yylval.ttype) == INTEGER_CST)
                   1861:     {
1.1.1.11  root     1862:       int old_lineno = lineno;
1.1.1.8   root     1863:       /* subtract one, because it is the following line that
                   1864:         gets the specified number */
1.1       root     1865: 
1.1.1.8   root     1866:       int l = TREE_INT_CST_LOW (yylval.ttype) - 1;
1.1       root     1867: 
1.1.1.8   root     1868:       /* Is this the last nonwhite stuff on the line?  */
                   1869:       c = getc (finput);
                   1870:       while (c == ' ' || c == '\t')
                   1871:        c = getc (finput);
                   1872:       if (c == '\n')
1.1       root     1873:        {
1.1.1.8   root     1874:          /* No more: store the line number and check following line.  */
1.1       root     1875:          lineno = l;
1.1.1.8   root     1876:          return c;
                   1877:        }
                   1878:       ungetc (c, finput);
                   1879: 
                   1880:       /* More follows: it must be a string constant (filename).  */
1.1       root     1881: 
1.1.1.8   root     1882:       token = yylex ();
                   1883:       if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
                   1884:        {
                   1885:          error ("invalid #line");
                   1886:          goto skipline;
1.1       root     1887:        }
                   1888: 
1.1.1.8   root     1889:       input_filename
                   1890:        = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
                   1891:       strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
                   1892:       lineno = l;
                   1893: 
                   1894:       if (main_input_filename == 0)
                   1895:        main_input_filename = input_filename;
1.1.1.11  root     1896: 
                   1897:       /* Is this the last nonwhite stuff on the line?  */
                   1898:       c = getc (finput);
                   1899:       while (c == ' ' || c == '\t')
                   1900:        c = getc (finput);
                   1901:       if (c == '\n')
                   1902:        return c;
                   1903:       ungetc (c, finput);
                   1904: 
                   1905:       token = yylex ();
                   1906: 
                   1907:       /* `1' after file name means entering new file.
                   1908:         `2' after file name means just left a file.  */
                   1909: 
                   1910:       if (token == CONSTANT
                   1911:          && TREE_CODE (yylval.ttype) == INTEGER_CST)
                   1912:        {
                   1913:          if (TREE_INT_CST_LOW (yylval.ttype) == 1)
                   1914:            {
                   1915:              struct file_stack *p
                   1916:                = (struct file_stack *) xmalloc (sizeof (struct file_stack));
                   1917:              input_file_stack->line = old_lineno;
                   1918:              p->next = input_file_stack;
                   1919:              p->name = input_filename;
                   1920:              input_file_stack = p;
                   1921:              input_file_stack_tick++;
                   1922:            }
                   1923:          else if (input_file_stack->next)
                   1924:            {
                   1925:              struct file_stack *p = input_file_stack;
                   1926:              input_file_stack = p->next;
                   1927:              free (p);
                   1928:              input_file_stack_tick++;
                   1929:            }
                   1930:          else
                   1931:            error ("#-lines for entering and leaving files don't match");
                   1932:        }
1.1       root     1933:     }
1.1.1.8   root     1934:   else
1.1.1.11  root     1935:     error ("invalid #-line");
1.1.1.8   root     1936: 
                   1937:   /* skip the rest of this line.  */
                   1938:  skipline:
1.1.1.10  root     1939:   if (c == '\n')
                   1940:     return c;
1.1.1.9   root     1941:   while ((c = getc (finput)) != EOF && c != '\n');
1.1.1.8   root     1942:   return c;
1.1       root     1943: }
                   1944: 
                   1945: #define isalnum(char) ((char >= 'a' && char <= 'z') || (char >= 'A' && char <= 'Z') || (char >= '0' && char <= '9'))
                   1946: #define isdigit(char) (char >= '0' && char <= '9')
                   1947: #define ENDFILE -1  /* token that represents end-of-file */
                   1948: 
                   1949: 
                   1950: static int
                   1951: readescape ()
                   1952: {
                   1953:   register int c = getc (finput);
                   1954:   register int count, code;
1.1.1.7   root     1955:   int firstdig;
1.1       root     1956: 
                   1957:   switch (c)
                   1958:     {
                   1959:     case 'x':
                   1960:       code = 0;
                   1961:       count = 0;
                   1962:       while (1)
                   1963:        {
                   1964:          c = getc (finput);
                   1965:          if (!(c >= 'a' && c <= 'f')
                   1966:              && !(c >= 'A' && c <= 'F')
                   1967:              && !(c >= '0' && c <= '9'))
                   1968:            {
                   1969:              ungetc (c, finput);
                   1970:              break;
                   1971:            }
                   1972:          code *= 16;
                   1973:          if (c >= 'a' && c <= 'f')
                   1974:            code += c - 'a' + 10;
                   1975:          if (c >= 'A' && c <= 'F')
                   1976:            code += c - 'A' + 10;
                   1977:          if (c >= '0' && c <= '9')
                   1978:            code += c - '0';
1.1.1.7   root     1979:          if (count == 0)
                   1980:            firstdig = code;
1.1       root     1981:          count++;
                   1982:        }
                   1983:       if (count == 0)
                   1984:        error ("\\x used with no following hex digits");
1.1.1.11  root     1985:       else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
                   1986:               || ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4))
                   1987:                   <= firstdig))
1.1.1.7   root     1988:        warning ("hex escape out of range");
1.1       root     1989:       return code;
                   1990: 
                   1991:     case '0':  case '1':  case '2':  case '3':  case '4':
                   1992:     case '5':  case '6':  case '7':
                   1993:       code = 0;
                   1994:       count = 0;
                   1995:       while ((c <= '7') && (c >= '0') && (count++ < 3))
                   1996:        {
                   1997:          code = (code * 8) + (c - '0');
                   1998:          c = getc (finput);
                   1999:        }
                   2000:       ungetc (c, finput);
                   2001:       return code;
                   2002: 
                   2003:     case '\\': case '\'': case '"':
                   2004:       return c;
                   2005: 
                   2006:     case '\n':
                   2007:       lineno++;
                   2008:       return -1;
                   2009: 
                   2010:     case 'n':
                   2011:       return TARGET_NEWLINE;
                   2012: 
                   2013:     case 't':
                   2014:       return TARGET_TAB;
                   2015: 
                   2016:     case 'r':
                   2017:       return TARGET_CR;
                   2018: 
                   2019:     case 'f':
                   2020:       return TARGET_FF;
                   2021: 
                   2022:     case 'b':
                   2023:       return TARGET_BS;
                   2024: 
                   2025:     case 'a':
                   2026:       return TARGET_BELL;
                   2027: 
                   2028:     case 'v':
                   2029:       return TARGET_VT;
                   2030: 
                   2031:     case 'E':
                   2032:       return 033;
                   2033: 
                   2034:     case '?':
1.1.1.3   root     2035:       /* `\(', etc, are used at beginning of line to avoid confusing Emacs.  */
1.1.1.2   root     2036:     case '(':
1.1.1.3   root     2037:     case '{':
                   2038:     case '[':
1.1       root     2039:       return c;
                   2040:     }
                   2041:   if (c >= 040 && c <= 0177)
                   2042:     warning ("unknown escape sequence `\\%c'", c);
                   2043:   else
                   2044:     warning ("unknown escape sequence: `\\' followed by char code 0x%x", c);
                   2045:   return c;
                   2046: }
                   2047: 
                   2048: void
                   2049: yyerror (string)
                   2050:      char *string;
                   2051: {
                   2052:   char buf[200];
                   2053: 
                   2054:   strcpy (buf, string);
                   2055: 
                   2056:   /* We can't print string and character constants well
                   2057:      because the token_buffer contains the result of processing escapes.  */
1.1.1.5   root     2058:   if (end_of_file)
1.1       root     2059:     strcat (buf, " at end of input");
1.1.1.5   root     2060:   else if (token_buffer[0] == 0)
                   2061:     strcat (buf, " at null character");
1.1       root     2062:   else if (token_buffer[0] == '"')
                   2063:     strcat (buf, " before string constant");
                   2064:   else if (token_buffer[0] == '\'')
                   2065:     strcat (buf, " before character constant");
1.1.1.7   root     2066:   else if (token_buffer[0] < 040 || token_buffer[0] >= 0177)
                   2067:     sprintf (buf + strlen (buf), " before character 0%o", token_buffer[0]);
1.1       root     2068:   else
                   2069:     strcat (buf, " before `%s'");
                   2070: 
                   2071:   error (buf, token_buffer);
                   2072: }
                   2073: 
                   2074: static int nextchar = -1;
                   2075: 
                   2076: static int
                   2077: yylex ()
                   2078: {
                   2079:   register int c;
                   2080:   register char *p;
                   2081:   register int value;
                   2082:   int wide_flag = 0;
                   2083: 
                   2084:   if (nextchar >= 0)
                   2085:     c = nextchar, nextchar = -1;
                   2086:   else
                   2087:     c = getc (finput);
                   2088: 
                   2089:   /* Effectively do c = skip_white_space (c)
                   2090:      but do it faster in the usual cases.  */
                   2091:   while (1)
                   2092:     switch (c)
                   2093:       {
                   2094:       case ' ':
                   2095:       case '\t':
                   2096:       case '\f':
                   2097:       case '\r':
1.1.1.11  root     2098:       case '\v':
1.1       root     2099:       case '\b':
                   2100:        c = getc (finput);
                   2101:        break;
                   2102: 
                   2103:       case '\n':
                   2104:       case '/':
                   2105:       case '\\':
                   2106:        c = skip_white_space (c);
                   2107:       default:
                   2108:        goto found_nonwhite;
                   2109:       }
                   2110:  found_nonwhite:
                   2111: 
                   2112:   token_buffer[0] = c;
                   2113:   token_buffer[1] = 0;
                   2114: 
                   2115: /*  yylloc.first_line = lineno; */
                   2116: 
                   2117:   switch (c)
                   2118:     {
                   2119:     case EOF:
1.1.1.5   root     2120:       end_of_file = 1;
1.1       root     2121:       token_buffer[0] = 0;
                   2122:       value = ENDFILE;
                   2123:       break;
                   2124: 
                   2125:     case '$':
                   2126:       if (dollars_in_ident)
                   2127:        goto letter;
                   2128:       return '$';
                   2129: 
                   2130:     case 'L':
                   2131:       /* Capital L may start a wide-string or wide-character constant.  */
                   2132:       {
                   2133:        register int c = getc (finput);
                   2134:        if (c == '\'')
                   2135:          {
                   2136:            wide_flag = 1;
                   2137:            goto char_constant;
                   2138:          }
                   2139:        if (c == '"')
                   2140:          {
                   2141:            wide_flag = 1;
                   2142:            goto string_constant;
                   2143:          }
                   2144:        ungetc (c, finput);
                   2145:       }
                   2146: 
                   2147:     case 'A':  case 'B':  case 'C':  case 'D':  case 'E':
                   2148:     case 'F':  case 'G':  case 'H':  case 'I':  case 'J':
                   2149:     case 'K':            case 'M':  case 'N':  case 'O':
                   2150:     case 'P':  case 'Q':  case 'R':  case 'S':  case 'T':
                   2151:     case 'U':  case 'V':  case 'W':  case 'X':  case 'Y':
                   2152:     case 'Z':
                   2153:     case 'a':  case 'b':  case 'c':  case 'd':  case 'e':
                   2154:     case 'f':  case 'g':  case 'h':  case 'i':  case 'j':
                   2155:     case 'k':  case 'l':  case 'm':  case 'n':  case 'o':
                   2156:     case 'p':  case 'q':  case 'r':  case 's':  case 't':
                   2157:     case 'u':  case 'v':  case 'w':  case 'x':  case 'y':
                   2158:     case 'z':
                   2159:     case '_':
                   2160:     letter:
                   2161:       p = token_buffer;
                   2162:       while (isalnum (c) || c == '_' || c == '$')
                   2163:        {
                   2164:          if (p >= token_buffer + maxtoken)
                   2165:            p = extend_token_buffer (p);
                   2166:          if (c == '$' && ! dollars_in_ident)
                   2167:            break;
                   2168: 
                   2169:          *p++ = c;
                   2170:          c = getc (finput);
                   2171:        }
                   2172: 
                   2173:       *p = 0;
                   2174:       nextchar = c;
                   2175: 
                   2176:       value = IDENTIFIER;
                   2177:       yylval.itype = 0;
                   2178: 
1.1.1.4   root     2179:       /* Try to recognize a keyword.  Uses minimum-perfect hash function */
1.1.1.11  root     2180: 
1.1.1.4   root     2181:       {
                   2182:        register struct resword *ptr;
1.1       root     2183: 
1.1.1.4   root     2184:        if (ptr = is_reserved_word (token_buffer, p - token_buffer))
                   2185:          {
                   2186:            if (ptr->rid)
                   2187:              yylval.ttype = ridpointers[(int) ptr->rid];
                   2188:            if ((! flag_no_asm
                   2189:                 /* -fno-asm means don't recognize the non-ANSI keywords.  */
                   2190:                 || ((int) ptr->token != ASM
                   2191:                     && (int) ptr->token != TYPEOF
1.1.1.10  root     2192:                     && ptr->rid != RID_INLINE)
                   2193:                 /* Recognize __asm and __inline despite -fno-asm.  */
                   2194:                 || token_buffer[0] == '_')
1.1.1.4   root     2195:                /* -ftraditional means don't recognize nontraditional keywords
                   2196:                   typeof, const, volatile, signed or inline.  */
                   2197:                && (! flag_traditional
                   2198:                    || ((int) ptr->token != TYPE_QUAL
                   2199:                        && (int) ptr->token != TYPEOF
                   2200:                        && ptr->rid != RID_SIGNED
1.1.1.10  root     2201:                        && ptr->rid != RID_INLINE)
                   2202:                    /* Recognize __inline, etc. despite -ftraditional.  */
                   2203:                    || token_buffer[0] == '_'))
1.1.1.4   root     2204:              value = (int) ptr->token;
                   2205:          }
                   2206:       }
1.1       root     2207: 
                   2208:       /* If we did not find a keyword, look for an identifier
                   2209:         (or a typename).  */
                   2210: 
                   2211:       if (value == IDENTIFIER)
                   2212:        {
                   2213:           yylval.ttype = get_identifier (token_buffer);
                   2214:          lastiddecl = lookup_name (yylval.ttype);
                   2215: 
                   2216:          if (lastiddecl != 0 && TREE_CODE (lastiddecl) == TYPE_DECL)
                   2217:            value = TYPENAME;
                   2218:        }
                   2219: 
                   2220:       break;
                   2221: 
                   2222:     case '0':  case '1':  case '2':  case '3':  case '4':
                   2223:     case '5':  case '6':  case '7':  case '8':  case '9':
                   2224:     case '.':
                   2225:       {
                   2226:        int base = 10;
                   2227:        int count = 0;
                   2228:        int largest_digit = 0;
                   2229:        int numdigits = 0;
                   2230:        /* for multi-precision arithmetic,
                   2231:           we store only 8 live bits in each short,
                   2232:           giving us 64 bits of reliable precision */
                   2233:        short shorts[8];
1.1.1.11  root     2234:        int overflow = 0;
1.1.1.3   root     2235: 
1.1.1.5   root     2236:        enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag
1.1.1.3   root     2237:          = NOT_FLOAT;
1.1       root     2238: 
                   2239:        for (count = 0; count < 8; count++)
                   2240:          shorts[count] = 0;
                   2241: 
                   2242:        p = token_buffer;
                   2243:        *p++ = c;
                   2244: 
                   2245:        if (c == '0')
                   2246:          {
                   2247:            *p++ = (c = getc (finput));
                   2248:            if ((c == 'x') || (c == 'X'))
                   2249:              {
                   2250:                base = 16;
                   2251:                *p++ = (c = getc (finput));
                   2252:              }
                   2253:            else
                   2254:              {
                   2255:                base = 8;
                   2256:                numdigits++;
                   2257:              }
                   2258:          }
                   2259: 
                   2260:        /* Read all the digits-and-decimal-points.  */
                   2261: 
                   2262:        while (c == '.'
                   2263:               || (isalnum (c) && (c != 'l') && (c != 'L')
                   2264:                   && (c != 'u') && (c != 'U')
1.1.1.3   root     2265:                   && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
1.1       root     2266:          {
                   2267:            if (c == '.')
                   2268:              {
                   2269:                if (base == 16)
                   2270:                  error ("floating constant may not be in radix 16");
1.1.1.3   root     2271:                if (floatflag == AFTER_POINT)
                   2272:                  {
                   2273:                    error ("malformed floating constant");
                   2274:                    floatflag = TOO_MANY_POINTS;
                   2275:                  }
                   2276:                else
                   2277:                  floatflag = AFTER_POINT;
                   2278: 
1.1       root     2279:                base = 10;
                   2280:                *p++ = c = getc (finput);
                   2281:                /* Accept '.' as the start of a floating-point number
                   2282:                   only when it is followed by a digit.
                   2283:                   Otherwise, unread the following non-digit
                   2284:                   and use the '.' as a structural token.  */
                   2285:                if (p == token_buffer + 2 && !isdigit (c))
                   2286:                  {
                   2287:                    if (c == '.')
                   2288:                      {
                   2289:                        c = getc (finput);
                   2290:                        if (c == '.')
                   2291:                          {
                   2292:                            *p++ = c;
                   2293:                            *p = 0;
                   2294:                            return ELLIPSIS;
                   2295:                          }
                   2296:                        error ("parse error at `..'");
                   2297:                      }
                   2298:                    ungetc (c, finput);
                   2299:                    token_buffer[1] = 0;
                   2300:                    value = '.';
                   2301:                    goto done;
                   2302:                  }
                   2303:              }
                   2304:            else
                   2305:              {
                   2306:                /* It is not a decimal point.
                   2307:                   It should be a digit (perhaps a hex digit).  */
                   2308: 
                   2309:                if (isdigit (c))
                   2310:                  {
                   2311:                    c = c - '0';
                   2312:                  }
                   2313:                else if (base <= 10)
                   2314:                  {
                   2315:                    if ((c&~040) == 'E')
                   2316:                      {
                   2317:                        base = 10;
1.1.1.3   root     2318:                        floatflag = AFTER_POINT;
1.1       root     2319:                        break;   /* start of exponent */
                   2320:                      }
                   2321:                    error ("nondigits in number and not hexadecimal");
                   2322:                    c = 0;
                   2323:                  }
                   2324:                else if (c >= 'a')
                   2325:                  {
                   2326:                    c = c - 'a' + 10;
                   2327:                  }
                   2328:                else
                   2329:                  {
                   2330:                    c = c - 'A' + 10;
                   2331:                  }
                   2332:                if (c >= largest_digit)
                   2333:                  largest_digit = c;
                   2334:                numdigits++;
1.1.1.11  root     2335: 
1.1       root     2336:                for (count = 0; count < 8; count++)
                   2337:                  {
1.1.1.11  root     2338:                    shorts[count] *= base;
1.1       root     2339:                    if (count)
                   2340:                      {
                   2341:                        shorts[count] += (shorts[count-1] >> 8);
                   2342:                        shorts[count-1] &= (1<<8)-1;
                   2343:                      }
                   2344:                    else shorts[0] += c;
                   2345:                  }
1.1.1.11  root     2346: 
                   2347:                if (shorts[7] >= 1<<8
                   2348:                    || shorts[7] < - (1 << 8))
                   2349:                  overflow = TRUE;
                   2350: 
1.1       root     2351:                if (p >= token_buffer + maxtoken - 3)
                   2352:                  p = extend_token_buffer (p);
                   2353:                *p++ = (c = getc (finput));
                   2354:              }
                   2355:          }
                   2356: 
                   2357:        if (numdigits == 0)
                   2358:          error ("numeric constant with no digits");
                   2359: 
                   2360:        if (largest_digit >= base)
                   2361:          error ("numeric constant contains digits beyond the radix");
                   2362: 
                   2363:        /* Remove terminating char from the token buffer and delimit the string */
                   2364:        *--p = 0;
                   2365: 
1.1.1.3   root     2366:        if (floatflag != NOT_FLOAT)
1.1       root     2367:          {
                   2368:            tree type = double_type_node;
                   2369:            char f_seen = 0;
                   2370:            char l_seen = 0;
1.1.1.8   root     2371:            REAL_VALUE_TYPE value;
1.1       root     2372: 
                   2373:            /* Read explicit exponent if any, and put it in tokenbuf.  */
                   2374: 
                   2375:            if ((c == 'e') || (c == 'E'))
                   2376:              {
                   2377:                if (p >= token_buffer + maxtoken - 3)
                   2378:                  p = extend_token_buffer (p);
                   2379:                *p++ = c;
                   2380:                c = getc (finput);
                   2381:                if ((c == '+') || (c == '-'))
                   2382:                  {
                   2383:                    *p++ = c;
                   2384:                    c = getc (finput);
                   2385:                  }
                   2386:                if (! isdigit (c))
                   2387:                  error ("floating constant exponent has no digits");
                   2388:                while (isdigit (c))
                   2389:                  {
                   2390:                    if (p >= token_buffer + maxtoken - 3)
                   2391:                      p = extend_token_buffer (p);
                   2392:                    *p++ = c;
                   2393:                    c = getc (finput);
                   2394:                  }
                   2395:              }
                   2396: 
                   2397:            *p = 0;
                   2398:            errno = 0;
1.1.1.8   root     2399:            value = REAL_VALUE_ATOF (token_buffer);
1.1       root     2400: #ifdef ERANGE
                   2401:            if (errno == ERANGE && !flag_traditional)
1.1.1.5   root     2402:              {
                   2403:                char *p1 = token_buffer;
                   2404:                /* Check for "0.0" and variants;
                   2405:                   Sunos 4 spuriously returns ERANGE for them.  */
                   2406:                while (*p1 == '0') p1++;
1.1.1.11  root     2407:                if (*p1 == '.')
                   2408:                  {
                   2409:                    p1++;
                   2410:                    while (*p1 == '0') p1++;
                   2411:                  }
                   2412:                if (*p1 == 'e' || *p1 == 'E')
                   2413:                  {
                   2414:                    /* with significand==0, ignore the exponent */
                   2415:                    p1++;
                   2416:                    while (*p1 != 0) p1++;
                   2417:                  }
1.1.1.12! root     2418:                /* ERANGE is also reported for underflow,
        !          2419:                   so test the value to distinguish overflow from that.  */
        !          2420:                if (*p1 != 0 && (value > 1.0 || value < 1.0))
1.1.1.5   root     2421:                  warning ("floating point number exceeds range of `double'");
                   2422:              }
1.1       root     2423: #endif
                   2424: 
                   2425:            /* Read the suffixes to choose a data type.  */
                   2426:            while (1)
                   2427:              {
                   2428:                if (c == 'f' || c == 'F')
                   2429:                  {
1.1.1.11  root     2430:                    float floater;
1.1       root     2431:                    if (f_seen)
                   2432:                      error ("two `f's in floating constant");
                   2433:                    f_seen = 1;
                   2434:                    type = float_type_node;
1.1.1.11  root     2435:                    floater = value;
                   2436:                    value = floater;
1.1       root     2437:                  }
                   2438:                else if (c == 'l' || c == 'L')
                   2439:                  {
                   2440:                    if (l_seen)
                   2441:                      error ("two `l's in floating constant");
                   2442:                    l_seen = 1;
                   2443:                    type = long_double_type_node;
                   2444:                  }
                   2445:                else
                   2446:                  {
                   2447:                    if (isalnum (c))
                   2448:                      {
                   2449:                        error ("garbage at end of number");
                   2450:                        while (isalnum (c))
                   2451:                          {
                   2452:                            if (p >= token_buffer + maxtoken - 3)
                   2453:                              p = extend_token_buffer (p);
                   2454:                            *p++ = c;
                   2455:                            c = getc (finput);
                   2456:                          }
                   2457:                      }
                   2458:                    break;
                   2459:                  }
                   2460:                if (p >= token_buffer + maxtoken - 3)
                   2461:                  p = extend_token_buffer (p);
                   2462:                *p++ = c;
                   2463:                c = getc (finput);
                   2464:              }
                   2465: 
                   2466:            /* Create a node with determined type and value.  */
                   2467:            yylval.ttype = build_real (type, value);
                   2468: 
                   2469:            ungetc (c, finput);
                   2470:            *p = 0;
                   2471:          }
                   2472:        else
                   2473:          {
                   2474:            tree type;
                   2475:            int spec_unsigned = 0;
                   2476:            int spec_long = 0;
1.1.1.11  root     2477:            int spec_long_long = 0;
1.1       root     2478: 
                   2479:            while (1)
                   2480:              {
                   2481:                if (c == 'u' || c == 'U')
                   2482:                  {
                   2483:                    if (spec_unsigned)
                   2484:                      error ("two `u's in integer constant");
                   2485:                    spec_unsigned = 1;
                   2486:                  }
                   2487:                else if (c == 'l' || c == 'L')
                   2488:                  {
                   2489:                    if (spec_long)
1.1.1.11  root     2490:                      {
                   2491:                        if (spec_long_long)
                   2492:                          error ("three `l's in integer constant");
                   2493:                        else if (pedantic)
                   2494:                          warning ("ANSI C forbids long long integer constants");
                   2495:                        spec_long_long = 1;
                   2496:                      }
1.1       root     2497:                    spec_long = 1;
                   2498:                  }
                   2499:                else
                   2500:                  {
                   2501:                    if (isalnum (c))
                   2502:                      {
                   2503:                        error ("garbage at end of number");
                   2504:                        while (isalnum (c))
                   2505:                          {
                   2506:                            if (p >= token_buffer + maxtoken - 3)
                   2507:                              p = extend_token_buffer (p);
                   2508:                            *p++ = c;
                   2509:                            c = getc (finput);
                   2510:                          }
                   2511:                      }
                   2512:                    break;
                   2513:                  }
                   2514:                if (p >= token_buffer + maxtoken - 3)
                   2515:                  p = extend_token_buffer (p);
                   2516:                *p++ = c;
                   2517:                c = getc (finput);
                   2518:              }
                   2519: 
                   2520:            ungetc (c, finput);
                   2521: 
1.1.1.11  root     2522:            if ((overflow || shorts[7] || shorts[6] || shorts[5] || shorts[4])
                   2523:                && !spec_long_long)
1.1       root     2524:              warning ("integer constant out of range");
                   2525: 
1.1.1.11  root     2526:            /* If it won't fit in a signed long long, make it unsigned.
                   2527:               We can't distinguish based on the tree node because
                   2528:               any integer constant fits any long long type.  */
                   2529:            if (shorts[7] >= (1<<8))
                   2530:              spec_unsigned = 1;
                   2531: 
1.1       root     2532:            /* This is simplified by the fact that our constant
                   2533:               is always positive.  */
                   2534:            yylval.ttype
1.1.1.11  root     2535:              = (build_int_2
                   2536:                 ((shorts[3]<<24) + (shorts[2]<<16) + (shorts[1]<<8) + shorts[0],
                   2537:                  (spec_long_long
                   2538:                   ? (shorts[7]<<24) + (shorts[6]<<16) + (shorts[5]<<8) + shorts[4]
                   2539:                   : 0)));
                   2540: 
1.1       root     2541:            if (!spec_long && !spec_unsigned
                   2542:                && int_fits_type_p (yylval.ttype, integer_type_node))
                   2543:              type = integer_type_node;
                   2544: 
                   2545:            else if (!spec_long && base != 10
1.1.1.11  root     2546:                     && int_fits_type_p (yylval.ttype, unsigned_type_node))
1.1       root     2547:              type = unsigned_type_node;
                   2548: 
1.1.1.11  root     2549:            else if (!spec_unsigned && !spec_long_long
                   2550:                     && int_fits_type_p (yylval.ttype, long_integer_type_node))
1.1       root     2551:              type = long_integer_type_node;
                   2552: 
1.1.1.11  root     2553:            else if (! spec_long_long
                   2554:                     && int_fits_type_p (yylval.ttype,
                   2555:                                         long_unsigned_type_node))
                   2556:              type = long_unsigned_type_node;
                   2557: 
                   2558:            else if (! spec_unsigned
                   2559:                     && int_fits_type_p (yylval.ttype,
                   2560:                                         long_long_integer_type_node))
                   2561:              type = long_long_integer_type_node;
                   2562: 
                   2563:            else if (int_fits_type_p (yylval.ttype,
                   2564:                                      long_long_unsigned_type_node))
                   2565:              type = long_long_unsigned_type_node;
                   2566: 
1.1       root     2567:            else
                   2568:              {
1.1.1.11  root     2569:                type = long_long_integer_type_node;
                   2570:                warning ("integer constant out of range");
1.1       root     2571:              }
1.1.1.11  root     2572: 
1.1       root     2573:            TREE_TYPE (yylval.ttype) = type;
                   2574:          }
                   2575: 
                   2576:        value = CONSTANT; break;
                   2577:       }
                   2578: 
                   2579:     case '\'':
                   2580:     char_constant:
                   2581:       {
1.1.1.11  root     2582:        register int result = 0;
                   2583:        register num_chars = 0;
                   2584:        int width = TYPE_PRECISION (char_type_node);
                   2585:        int max_chars;
1.1       root     2586: 
1.1.1.11  root     2587:        if (wide_flag) width = TYPE_PRECISION (integer_type_node);
1.1       root     2588: 
1.1.1.11  root     2589:        max_chars = TYPE_PRECISION (integer_type_node) / width;
                   2590: 
                   2591:        while (1)
1.1       root     2592:          {
1.1.1.11  root     2593:          tryagain:
                   2594: 
                   2595:            c = getc (finput);
                   2596: 
                   2597:            if (c == '\'' || c == EOF)
                   2598:              break;
                   2599: 
                   2600:            if (c == '\\')
                   2601:              {
                   2602:                c = readescape ();
                   2603:                if (c < 0)
                   2604:                  goto tryagain;
                   2605:                if (width < HOST_BITS_PER_INT
                   2606:                    && (unsigned) c >= (1 << width))
                   2607:                  warning ("escape sequence out of range for character");
                   2608:              }
                   2609:            else if (c == '\n')
                   2610:              {
                   2611:                if (pedantic)
                   2612:                  warning ("ANSI C forbids newline in character constant");
                   2613:                lineno++;
                   2614:              }
                   2615: 
                   2616:            num_chars++;
                   2617:            if (num_chars > maxtoken - 4)
                   2618:              extend_token_buffer (token_buffer);
                   2619: 
                   2620:            token_buffer[num_chars] = c;
                   2621: 
                   2622:            /* Merge character into result; ignore excess chars.  */
                   2623:            if (num_chars < max_chars + 1)
                   2624:              {
                   2625:                if (width < HOST_BITS_PER_INT)
                   2626:                  result = (result << width) | (c & ((1 << width) - 1));
                   2627:                else
                   2628:                  result = c;
                   2629:              }
1.1       root     2630:          }
                   2631: 
1.1.1.11  root     2632:        token_buffer[num_chars + 1] = '\'';
                   2633:        token_buffer[num_chars + 2] = 0;
1.1       root     2634: 
                   2635:        if (c != '\'')
                   2636:          error ("malformatted character constant");
1.1.1.11  root     2637:        else if (num_chars == 0)
                   2638:          error ("empty character constant");
                   2639:        else if (num_chars > max_chars)
                   2640:          {
                   2641:            num_chars = max_chars;
                   2642:            error ("character constant too long");
                   2643:          }
                   2644:        else if (num_chars != 1 && ! flag_traditional)
                   2645:          warning ("multi-character character constant");
1.1       root     2646: 
                   2647:        /* If char type is signed, sign-extend the constant.  */
1.1.1.7   root     2648:        if (! wide_flag)
                   2649:          {
1.1.1.11  root     2650:            int num_bits = num_chars * width;
1.1.1.7   root     2651:            if (TREE_UNSIGNED (char_type_node)
1.1.1.11  root     2652:                || ((result >> (num_bits - 1)) & 1) == 0)
                   2653:              yylval.ttype
                   2654:                = build_int_2 (result & ((unsigned) ~0
                   2655:                                         >> (HOST_BITS_PER_INT - num_bits)),
                   2656:                               0);
1.1.1.7   root     2657:            else
1.1.1.11  root     2658:              yylval.ttype
                   2659:                = build_int_2 (result | ~((unsigned) ~0
                   2660:                                          >> (HOST_BITS_PER_INT - num_bits)),
                   2661:                               -1);
1.1.1.7   root     2662:          }
1.1       root     2663:        else
1.1.1.11  root     2664:          yylval.ttype = build_int_2 (result, 0);
1.1       root     2665: 
                   2666:        TREE_TYPE (yylval.ttype) = integer_type_node;
                   2667:        value = CONSTANT; break;
                   2668:       }
                   2669: 
                   2670:     case '"':
                   2671:     string_constant:
                   2672:       {
1.1.1.7   root     2673:        int *widep;
                   2674: 
1.1       root     2675:        c = getc (finput);
                   2676:        p = token_buffer + 1;
                   2677: 
1.1.1.7   root     2678:        if (wide_flag)
                   2679:          widep = wide_buffer;
                   2680: 
1.1.1.9   root     2681:        while (c != '"' && c >= 0)
1.1       root     2682:          {
                   2683:            if (c == '\\')
                   2684:              {
                   2685:                c = readescape ();
                   2686:                if (c < 0)
                   2687:                  goto skipnewline;
1.1.1.11  root     2688:                if (!wide_flag && c >= (1 << TYPE_PRECISION (char_type_node)))
1.1.1.7   root     2689:                  warning ("escape sequence out of range for character");
1.1       root     2690:              }
                   2691:            else if (c == '\n')
                   2692:              {
                   2693:                if (pedantic)
                   2694:                  warning ("ANSI C forbids newline in string constant");
                   2695:                lineno++;
                   2696:              }
                   2697: 
1.1.1.7   root     2698:            /* Store the char in C into the appropriate buffer.  */
                   2699: 
                   2700:            if (wide_flag)
                   2701:              {
                   2702:                if (widep == wide_buffer + max_wide)
                   2703:                  {
                   2704:                    int n = widep - wide_buffer;
                   2705:                    max_wide *= 2;
                   2706:                    wide_buffer = (int *) xrealloc (wide_buffer, max_wide + 1);
                   2707:                    widep = wide_buffer + n;
                   2708:                  }
                   2709:                *widep++ = c;
                   2710:              }
                   2711:            else
                   2712:              {
                   2713:                if (p == token_buffer + maxtoken)
                   2714:                  p = extend_token_buffer (p);
                   2715:                *p++ = c;
                   2716:              }
1.1       root     2717: 
                   2718:          skipnewline:
                   2719:            c = getc (finput);
                   2720:          }
                   2721: 
1.1.1.7   root     2722:        /* We have read the entire constant.
                   2723:           Construct a STRING_CST for the result.  */
1.1       root     2724: 
                   2725:        if (wide_flag)
                   2726:          {
1.1.1.7   root     2727:            /* If this is a L"..." wide-string, make a vector
                   2728:               of the ints in wide_buffer.  */
                   2729:            *widep = 0;
                   2730:            /* We have not implemented the case where `int'
                   2731:               on the target and on the execution machine differ in size.  */
                   2732:            if (TYPE_PRECISION (integer_type_node)
                   2733:                != sizeof (int) * BITS_PER_UNIT)
                   2734:              abort ();
1.1.1.12! root     2735:            yylval.ttype
        !          2736:              = build_string ((widep - wide_buffer + 1) * sizeof (int),
        !          2737:                              wide_buffer);
1.1       root     2738:            TREE_TYPE (yylval.ttype) = int_array_type_node;
                   2739:          }
                   2740:        else
                   2741:          {
1.1.1.7   root     2742:            *p = 0;
1.1       root     2743:            yylval.ttype = build_string (p - token_buffer, token_buffer + 1);
                   2744:            TREE_TYPE (yylval.ttype) = char_array_type_node;
                   2745:          }
                   2746: 
                   2747:        *p++ = '"';
                   2748:        *p = 0;
                   2749: 
                   2750:        value = STRING; break;
                   2751:       }
1.1.1.11  root     2752: 
1.1       root     2753:     case '+':
                   2754:     case '-':
                   2755:     case '&':
                   2756:     case '|':
                   2757:     case '<':
                   2758:     case '>':
                   2759:     case '*':
                   2760:     case '/':
                   2761:     case '%':
                   2762:     case '^':
                   2763:     case '!':
                   2764:     case '=':
                   2765:       {
                   2766:        register int c1;
                   2767: 
                   2768:       combine:
                   2769: 
                   2770:        switch (c)
                   2771:          {
                   2772:          case '+':
                   2773:            yylval.code = PLUS_EXPR; break;
                   2774:          case '-':
                   2775:            yylval.code = MINUS_EXPR; break;
                   2776:          case '&':
                   2777:            yylval.code = BIT_AND_EXPR; break;
                   2778:          case '|':
                   2779:            yylval.code = BIT_IOR_EXPR; break;
                   2780:          case '*':
                   2781:            yylval.code = MULT_EXPR; break;
                   2782:          case '/':
                   2783:            yylval.code = TRUNC_DIV_EXPR; break;
                   2784:          case '%':
                   2785:            yylval.code = TRUNC_MOD_EXPR; break;
                   2786:          case '^':
                   2787:            yylval.code = BIT_XOR_EXPR; break;
                   2788:          case LSHIFT:
                   2789:            yylval.code = LSHIFT_EXPR; break;
                   2790:          case RSHIFT:
                   2791:            yylval.code = RSHIFT_EXPR; break;
                   2792:          case '<':
                   2793:            yylval.code = LT_EXPR; break;
                   2794:          case '>':
                   2795:            yylval.code = GT_EXPR; break;
1.1.1.11  root     2796:          }
1.1       root     2797: 
                   2798:        token_buffer[1] = c1 = getc (finput);
                   2799:        token_buffer[2] = 0;
                   2800: 
                   2801:        if (c1 == '=')
                   2802:          {
                   2803:            switch (c)
                   2804:              {
                   2805:              case '<':
                   2806:                value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
                   2807:              case '>':
                   2808:                value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
                   2809:              case '!':
                   2810:                value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
                   2811:              case '=':
                   2812:                value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
1.1.1.11  root     2813:              }
1.1       root     2814:            value = ASSIGN; goto done;
                   2815:          }
                   2816:        else if (c == c1)
                   2817:          switch (c)
                   2818:            {
                   2819:            case '+':
                   2820:              value = PLUSPLUS; goto done;
                   2821:            case '-':
                   2822:              value = MINUSMINUS; goto done;
                   2823:            case '&':
                   2824:              value = ANDAND; goto done;
                   2825:            case '|':
                   2826:              value = OROR; goto done;
                   2827:            case '<':
                   2828:              c = LSHIFT;
                   2829:              goto combine;
                   2830:            case '>':
                   2831:              c = RSHIFT;
                   2832:              goto combine;
                   2833:            }
                   2834:        else if ((c == '-') && (c1 == '>'))
                   2835:          { value = POINTSAT; goto done; }
                   2836:        ungetc (c1, finput);
                   2837:        token_buffer[1] = 0;
                   2838: 
                   2839:        if ((c == '<') || (c == '>'))
                   2840:          value = ARITHCOMPARE;
                   2841:        else value = c;
                   2842:        goto done;
                   2843:       }
                   2844: 
1.1.1.5   root     2845:     case 0:
                   2846:       /* Don't make yyparse think this is eof.  */
                   2847:       value = 1;
                   2848:       break;
                   2849: 
1.1       root     2850:     default:
                   2851:       value = c;
                   2852:     }
                   2853: 
                   2854: done:
                   2855: /*  yylloc.last_line = lineno; */
                   2856: 
                   2857:   return value;
                   2858: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.