X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/037ca2f14c3e23460211a9dce5cfc0ee5878d800..e3f1699f5554776a9211b410f3ebdaa6120e62df:/src/reader.c diff --git a/src/reader.c b/src/reader.c index 80ed485a..03c0d311 100644 --- a/src/reader.c +++ b/src/reader.c @@ -724,7 +724,6 @@ token_buffer); } prev = t; - } } @@ -852,7 +851,7 @@ parse_thong_decl (void) token_t token; struct bucket *symbol; char *typename = 0; - int usrtoknum = 0; + int usrtoknum = SUNDEF; token = lex (); /* fetch typename or first token */ if (token == tok_typename) @@ -963,16 +962,13 @@ parse_skel_decl (void) static void read_declarations (void) { - int c; - int tok; - for (;;) { - c = skip_white_space (); + int c = skip_white_space (); if (c == '%') { - tok = parse_percent_token (); + token_t tok = parse_percent_token (); switch (tok) { @@ -1034,6 +1030,13 @@ read_declarations (void) case tok_noop: break; + case tok_stropt: + case tok_intopt: + case tok_obsolete: + case tok_illegal: + abort (); + break; + default: complain (_("unrecognized: %s"), token_buffer); skip_to_char ('%'); @@ -1724,6 +1727,9 @@ token_translations_init (void) /* A token string alias? */ if (bp->user_token_number == SALIAS) continue; + + assert (bp->user_token_number != SUNDEF); + /* A token which translation has already been set? */ if (token_translations[bp->user_token_number] != 2) complain (_("tokens %s and %s both assigned number %d"), @@ -1810,7 +1816,7 @@ packsymbols (void) if (bp->class == token_sym) { - if (bp->user_token_number == 0) + if (bp->user_token_number == SUNDEF) bp->user_token_number = ++last_user_token_number; if (bp->user_token_number > max_user_token_number) max_user_token_number = bp->user_token_number; @@ -1826,6 +1832,22 @@ packsymbols (void) error_token_number = errtoken->value; + if (startval->class == unknown_sym) + fatal (_("the start symbol %s is undefined"), startval->tag); + else if (startval->class == token_sym) + fatal (_("the start symbol %s is a token"), startval->tag); + + start_symbol = startval->value; +} + + +/*-----------------------------------. +| Output definition of token names. | +`-----------------------------------*/ + +static void +symbols_output (void) +{ { struct obstack tokendefs; obstack_init (&tokendefs); @@ -1840,13 +1862,6 @@ packsymbols (void) output_token_defines (&table_obstack); #endif - if (startval->class == unknown_sym) - fatal (_("the start symbol %s is undefined"), startval->tag); - else if (startval->class == token_sym) - fatal (_("the start symbol %s is a token"), startval->tag); - - start_symbol = startval->value; - if (defines_flag) { output_token_defines (&defines_obstack); @@ -2014,6 +2029,7 @@ reader (void) /* Assign the symbols their symbol numbers. Write #defines for the token symbols into FDEFINES if requested. */ packsymbols (); + symbols_output (); /* Convert the grammar into the format described in gram.h. */ packgram (); }