Annotation of 43BSDReno/pgrm/yacc/error.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1989 The Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * This code is derived from software contributed to Berkeley by
        !             6:  * Robert Paul Corbett.
        !             7:  *
        !             8:  * Redistribution and use in source and binary forms are permitted provided
        !             9:  * that: (1) source distributions retain this entire copyright notice and
        !            10:  * comment, and (2) distributions including binaries display the following
        !            11:  * acknowledgement:  ``This product includes software developed by the
        !            12:  * University of California, Berkeley and its contributors'' in the
        !            13:  * documentation or other materials provided with the distribution and in
        !            14:  * all advertising materials mentioning features or use of this software.
        !            15:  * Neither the name of the University nor the names of its contributors may
        !            16:  * be used to endorse or promote products derived from this software without
        !            17:  * specific prior written permission.
        !            18:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            19:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            20:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            21:  */
        !            22: 
        !            23: #ifndef lint
        !            24: static char sccsid[] = "@(#)error.c    5.3 (Berkeley) 6/1/90";
        !            25: #endif /* not lint */
        !            26: 
        !            27: /* routines for printing error messages  */
        !            28: 
        !            29: #include "defs.h"
        !            30: 
        !            31: 
        !            32: fatal(msg)
        !            33: char *msg;
        !            34: {
        !            35:     fprintf(stderr, "%s: f - %s\n", myname, msg);
        !            36:     done(2);
        !            37: }
        !            38: 
        !            39: 
        !            40: no_space()
        !            41: {
        !            42:     fprintf(stderr, "%s: f - out of space\n", myname);
        !            43:     done(2);
        !            44: }
        !            45: 
        !            46: 
        !            47: open_error(filename)
        !            48: char *filename;
        !            49: {
        !            50:     fprintf(stderr, "%s: f - cannot open \"%s\"\n", myname, filename);
        !            51:     done(2);
        !            52: }
        !            53: 
        !            54: 
        !            55: unexpected_EOF()
        !            56: {
        !            57:     fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
        !            58:            myname, lineno, input_file_name);
        !            59:     done(1);
        !            60: }
        !            61: 
        !            62: 
        !            63: print_pos(st_line, st_cptr)
        !            64: char *st_line;
        !            65: char *st_cptr;
        !            66: {
        !            67:     register char *s;
        !            68: 
        !            69:     if (st_line == 0) return;
        !            70:     for (s = st_line; *s != '\n'; ++s)
        !            71:     {
        !            72:        if (isprint(*s) || *s == '\t')
        !            73:            putc(*s, stderr);
        !            74:        else
        !            75:            putc('?', stderr);
        !            76:     }
        !            77:     putc('\n', stderr);
        !            78:     for (s = st_line; s < st_cptr; ++s)
        !            79:     {
        !            80:        if (*s == '\t')
        !            81:            putc('\t', stderr);
        !            82:        else
        !            83:            putc(' ', stderr);
        !            84:     }
        !            85:     putc('^', stderr);
        !            86:     putc('\n', stderr);
        !            87: }
        !            88: 
        !            89: 
        !            90: syntax_error(st_lineno, st_line, st_cptr)
        !            91: int st_lineno;
        !            92: char *st_line;
        !            93: char *st_cptr;
        !            94: {
        !            95:     fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n",
        !            96:            myname, st_lineno, input_file_name);
        !            97:     print_pos(st_line, st_cptr);
        !            98:     done(1);
        !            99: }
        !           100: 
        !           101: 
        !           102: unterminated_comment(c_lineno, c_line, c_cptr)
        !           103: int c_lineno;
        !           104: char *c_line;
        !           105: char *c_cptr;
        !           106: {
        !           107:     fprintf(stderr, "%s: e - line %d of \"%s\", unmatched /*\n",
        !           108:            myname, c_lineno, input_file_name);
        !           109:     print_pos(c_line, c_cptr);
        !           110:     done(1);
        !           111: }
        !           112: 
        !           113: 
        !           114: unterminated_string(s_lineno, s_line, s_cptr)
        !           115: int s_lineno;
        !           116: char *s_line;
        !           117: char *s_cptr;
        !           118: {
        !           119:     fprintf(stderr, "%s: e - line %d of \"%s\", unterminated string\n",
        !           120:            myname, s_lineno, input_file_name);
        !           121:     print_pos(s_line, s_cptr);
        !           122:     done(1);
        !           123: }
        !           124: 
        !           125: 
        !           126: unterminated_text(t_lineno, t_line, t_cptr)
        !           127: int t_lineno;
        !           128: char *t_line;
        !           129: char *t_cptr;
        !           130: {
        !           131:     fprintf(stderr, "%s: e - line %d of \"%s\", unmatched %%{\n",
        !           132:            myname, t_lineno, input_file_name);
        !           133:     print_pos(t_line, t_cptr);
        !           134:     done(1);
        !           135: }
        !           136: 
        !           137: 
        !           138: unterminated_union(u_lineno, u_line, u_cptr)
        !           139: int u_lineno;
        !           140: char *u_line;
        !           141: char *u_cptr;
        !           142: {
        !           143:     fprintf(stderr, "%s: e - line %d of \"%s\", unterminated %%union \
        !           144: declaration\n", myname, u_lineno, input_file_name);
        !           145:     print_pos(u_line, u_cptr);
        !           146:     done(1);
        !           147: }
        !           148: 
        !           149: 
        !           150: over_unionized(u_cptr)
        !           151: char *u_cptr;
        !           152: {
        !           153:     fprintf(stderr, "%s: e - line %d of \"%s\", too many %%union \
        !           154: declarations\n", myname, lineno, input_file_name);
        !           155:     print_pos(line, u_cptr);
        !           156:     done(1);
        !           157: }
        !           158: 
        !           159: 
        !           160: illegal_tag(t_lineno, t_line, t_cptr)
        !           161: int t_lineno;
        !           162: char *t_line;
        !           163: char *t_cptr;
        !           164: {
        !           165:     fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n",
        !           166:            myname, t_lineno, input_file_name);
        !           167:     print_pos(t_line, t_cptr);
        !           168:     done(1);
        !           169: }
        !           170: 
        !           171: 
        !           172: illegal_character(c_cptr)
        !           173: char *c_cptr;
        !           174: {
        !           175:     fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n",
        !           176:            myname, lineno, input_file_name);
        !           177:     print_pos(line, c_cptr);
        !           178:     done(1);
        !           179: }
        !           180: 
        !           181: 
        !           182: used_reserved(s)
        !           183: char *s;
        !           184: {
        !           185:     fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \
        !           186: %s\n", myname, lineno, input_file_name, s);
        !           187:     done(1);
        !           188: }
        !           189: 
        !           190: 
        !           191: tokenized_start(s)
        !           192: char *s;
        !           193: {
        !           194:      fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \
        !           195: declared to be a token\n", myname, lineno, input_file_name, s);
        !           196:      done(1);
        !           197: }
        !           198: 
        !           199: 
        !           200: retyped_warning(s)
        !           201: char *s;
        !           202: {
        !           203:     fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
        !           204: redeclared\n", myname, lineno, input_file_name, s);
        !           205: }
        !           206: 
        !           207: 
        !           208: reprec_warning(s)
        !           209: char *s;
        !           210: {
        !           211:     fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \
        !           212: redeclared\n", myname, lineno, input_file_name, s);
        !           213: }
        !           214: 
        !           215: 
        !           216: revalued_warning(s)
        !           217: char *s;
        !           218: {
        !           219:     fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
        !           220: redeclared\n", myname, lineno, input_file_name, s);
        !           221: }
        !           222: 
        !           223: 
        !           224: terminal_start(s)
        !           225: char *s;
        !           226: {
        !           227:     fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
        !           228: token\n", myname, lineno, input_file_name, s);
        !           229:     done(1);
        !           230: }
        !           231: 
        !           232: 
        !           233: restarted_warning()
        !           234: {
        !           235:     fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
        !           236: redeclared\n", myname, lineno, input_file_name);
        !           237: }
        !           238: 
        !           239: 
        !           240: no_grammar()
        !           241: {
        !           242:     fprintf(stderr, "%s: e - line %d of \"%s\", no grammar has been \
        !           243: specified\n", myname, lineno, input_file_name);
        !           244:     done(1);
        !           245: }
        !           246: 
        !           247: 
        !           248: terminal_lhs(s_lineno)
        !           249: int s_lineno;
        !           250: {
        !           251:     fprintf(stderr, "%s: e - line %d of \"%s\", a token appears on the lhs \
        !           252: of a production\n", myname, s_lineno, input_file_name);
        !           253:     done(1);
        !           254: }
        !           255: 
        !           256: 
        !           257: prec_redeclared()
        !           258: {
        !           259:     fprintf(stderr, "%s: w - line %d of  \"%s\", conflicting %%prec \
        !           260: specifiers\n", myname, lineno, input_file_name);
        !           261: }
        !           262: 
        !           263: 
        !           264: unterminated_action(a_lineno, a_line, a_cptr)
        !           265: int a_lineno;
        !           266: char *a_line;
        !           267: char *a_cptr;
        !           268: {
        !           269:     fprintf(stderr, "%s: e - line %d of \"%s\", unterminated action\n",
        !           270:            myname, a_lineno, input_file_name);
        !           271:     print_pos(a_line, a_cptr);
        !           272:     done(1);
        !           273: }
        !           274: 
        !           275: 
        !           276: dollar_warning(a_lineno, i)
        !           277: int a_lineno;
        !           278: int i;
        !           279: {
        !           280:     fprintf(stderr, "%s: w - line %d of \"%s\", $%d references beyond the \
        !           281: end of the current rule\n", myname, a_lineno, input_file_name, i);
        !           282: }
        !           283: 
        !           284: 
        !           285: dollar_error(a_lineno, a_line, a_cptr)
        !           286: int a_lineno;
        !           287: char *a_line;
        !           288: char *a_cptr;
        !           289: {
        !           290:     fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n",
        !           291:            myname, a_lineno, input_file_name);
        !           292:     print_pos(a_line, a_cptr);
        !           293:     done(1);
        !           294: }
        !           295: 
        !           296: 
        !           297: untyped_lhs()
        !           298: {
        !           299:     fprintf(stderr, "%s: e - line %d of \"%s\", $$ is untyped\n",
        !           300:            myname, lineno, input_file_name);
        !           301:     done(1);
        !           302: }
        !           303: 
        !           304: 
        !           305: untyped_rhs(i, s)
        !           306: int i;
        !           307: char *s;
        !           308: {
        !           309:     fprintf(stderr, "%s: e - line %d of \"%s\", $%d (%s) is untyped\n",
        !           310:            myname, lineno, input_file_name, i, s);
        !           311:     done(1);
        !           312: }
        !           313: 
        !           314: 
        !           315: unknown_rhs(i)
        !           316: int i;
        !           317: {
        !           318:     fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
        !           319:            myname, lineno, input_file_name, i);
        !           320:     done(1);
        !           321: }
        !           322: 
        !           323: 
        !           324: default_action_warning()
        !           325: {
        !           326:     fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \
        !           327: undefined value to $$\n", myname, lineno, input_file_name);
        !           328: }
        !           329: 
        !           330: 
        !           331: undefined_goal(s)
        !           332: char *s;
        !           333: {
        !           334:     fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
        !           335:     done(1);
        !           336: }
        !           337: 
        !           338: 
        !           339: undefined_symbol_warning(s)
        !           340: char *s;
        !           341: {
        !           342:     fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);
        !           343: }

unix.superglobalmegacorp.com

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