Annotation of researchv10no/cmd/pico/loops.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include "pico.h"
        !             3: 
        !             4: int uniq = 0;
        !             5: 
        !             6: Node *
        !             7: newhile(lcondi, lbody)
        !             8:        Node *lcondi, *lbody;
        !             9: {
        !            10:        Node *n = new(OCOMMA, lbody, new(GOTO, Z, Z, uniq), Z);
        !            11: 
        !            12:        return new(LABL, new(CONDI, n, Z, lcondi), Z, uniq++);
        !            13: }
        !            14: 
        !            15: Node *
        !            16: newuntil(lbody, lcondi)
        !            17:        Node *lbody, *lcondi;
        !            18: {
        !            19:        Node *n;
        !            20: 
        !            21:        n = new(GOTO, Z, Z, uniq);
        !            22:        n = new(OCOMMA, lbody, new(CONDI, n, Z, lcondi), Z);
        !            23: 
        !            24:        return new(LABL, n, Z, uniq++);
        !            25: }
        !            26: 
        !            27: Node *
        !            28: newloop(linit, lcondi, lincr, lbody)
        !            29:        Node *linit, *lcondi, *lincr, *lbody;
        !            30: {
        !            31:        Node *n;
        !            32: 
        !            33:        n = new(OCOMMA, new(OCOMMA, lbody, lincr, Z), new(GOTO, Z, Z, uniq), Z);
        !            34:        n = new(LABL, new(CONDI, n, Z, lcondi), Z, uniq++);
        !            35: 
        !            36:        return new(OCOMMA, linit, n, Z);
        !            37: }
        !            38: 
        !            39: commacount(n)
        !            40:        Node *n;
        !            41: {
        !            42:        if (n == Z)
        !            43:                return 0;
        !            44:        if (n->type != OCOMMA && n->type != ACOMMA)
        !            45:                return 1;
        !            46:        return commacount(n->right) + commacount(n->left);
        !            47: }
        !            48: 
        !            49: argcount(nrp, n, s)
        !            50:        long nrp;
        !            51:        Node *n;
        !            52:        char *s;
        !            53: {
        !            54:        int pcnt;
        !            55: 
        !            56:        if ((pcnt=commacount(n)) != (int) nrp)
        !            57:        if (strcmp(s, "println") != 0 && strcmp(s, "printf") != 0)
        !            58:        {       fprintf(stderr, "function %s takes %d ", s, nrp);
        !            59:                fprintf(stderr, "argumen%s, ", (nrp==1)?"t":"ts");
        !            60:                yyerror("found %d", pcnt);
        !            61:        }
        !            62: }

unix.superglobalmegacorp.com

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