Annotation of coherent/b/bin/c/n0/etc.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * C compiler.
                      3:  * Small things that don't seem
                      4:  * to go anywhere else.
                      5:  */
                      6: #ifdef   vax
                      7: #include "INC$LIB:cc0.h"
                      8: #else
                      9: #include "cc0.h"
                     10: #endif
                     11: 
                     12: /*
                     13:  * Allocate some space.
                     14:  * If no space, abort with a message.
                     15:  */
                     16: char    *
                     17: new(n)
                     18: {
                     19:        register char *p;
                     20: 
                     21:        if ((p=malloc(n)) == NULL)
                     22:                cnomem("new");
                     23:        return (p);
                     24: }
                     25: 
                     26: /*
                     27:  * Check if the symbol in the window 's' is token 't'.
                     28:  * If it is, skip over it; if it is not, print an error.
                     29:  */
                     30: mustbe(t)
                     31: {
                     32:        register char *p;
                     33: 
                     34:        if (s == t) {
                     35:                lex();
                     36:                return;
                     37:        }
                     38:        if (s == RPAREN) {
                     39:                cerror("missing '('");
                     40:                return;
                     41:        }
                     42:        switch (t) {
                     43: 
                     44:        case RBRACK:
                     45:                p = "]";
                     46:                break;
                     47: 
                     48:        case WHILE:
                     49:                p = "while";
                     50:                break;
                     51: 
                     52:        case LPAREN:
                     53:                p = "(";
                     54:                break;
                     55: 
                     56:        case RPAREN:
                     57:                p = ")";
                     58:                break;
                     59: 
                     60:        case SEMI:
                     61:                p = ";";
                     62:                break;
                     63: 
                     64:        case RBRACE:
                     65:                p = "}";
                     66:                break;
                     67: 
                     68:        case LBRACE:
                     69:                p = "{";
                     70:                break;
                     71: 
                     72:        case COLON:
                     73:                p = ":";
                     74:                break;
                     75: 
                     76:        case COMMA:
                     77:                p = ",";
                     78:                break;
                     79: 
                     80:        default:
                     81:                p = "{Something}";
                     82:                break;
                     83:        }
                     84:        cerror((p[1]=='\0') ? "missing '%s'" : "missing \"%s\"", p);
                     85: }
                     86: 
                     87: /*
                     88:  * Put out a local label.
                     89:  */
                     90: label(n)
                     91: {
                     92:        bput(LLABEL);
                     93:        iput((ival_t) n);
                     94: }
                     95: 
                     96: /*
                     97:  * Put out a local jump.
                     98:  */
                     99: jump(n)
                    100: {
                    101:        bput(JUMP);
                    102:        iput((ival_t) n);
                    103: }
                    104: 
                    105: /*
                    106:  * Put a label at the current
                    107:  * location.
                    108:  * Return the label number.
                    109:  */
                    110: here()
                    111: {
                    112:        register int    n;
                    113: 
                    114:        n = newlab();
                    115:        label(n);
                    116:        return (n);
                    117: }
                    118: 
                    119: /*
                    120:  * Complain about things not in the
                    121:  * bible (K and R).
                    122:  */
                    123: notbook()
                    124: {
                    125:        if (isvariant(VSBOOK))
                    126:                cstrict("construction not in Kernighan and Ritchie");
                    127: }

unix.superglobalmegacorp.com

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