Re: Pattern Matching

Ich habe eine bessere Lösung für den Automatengenerierer

void automatgen () {

    if ((statechar [xi] >= 'a') \&amp;\&amp; (statechar [xi] <= 'z')) {
        realstates1 [xreal] = xreal+1;
        realstates2 [xreal] = xreal+1;
        realstateschar [xreal] = statechar [xi];
        xreal++;
        xi++;
        printf ("Folge von Buchstaben: %in", xreal);
        automatgen ();
    }
    else if (statechar [xi] == IF_BEGIN) {
        int xreal1;
        int xreal2;
        int xreal3;

        xreal1 = xreal;
        xreal++;
        printf ("IF-BEGIN: %in", xreal);
        xi++;
        automatgen ();
        xreal2 = xreal;
        automatgen ();
        xreal3 = xreal;
        xreal++;
        automatgen ();


        realstates1 [xreal1] = xreal1+1;
        realstates2 [xreal1] = xreal2;
        realstateschar [xreal1] = CONTROLSTATE;
        realstates1 [xreal2-1] = xreal3;
        realstates2 [xreal2-1] = xreal3;
        realstates1 [xreal3] = xreal3+1;
        realstates2 [xreal3] = xreal3+1;
        realstateschar [xreal3] = CONTROLSTATE;


        printf ("realstates1 [xreal1]: %in", realstates1 [xreal1]);
        printf ("realstates2 [xreal1]: %in", realstates2 [xreal1]);
        printf ("realstateschar [xreal1]: %in", realstateschar [xreal1]);
    }
    else if (statechar [xi] == IF_ELSE) {
        printf ("IF-ELSE: %in", xreal);
        xi++;
        return;
    }
    else if (statechar [xi] == IF_END) {
        printf ("IF-END: %in", xreal);
        xi++;
        return;
    }
    else if (statechar [xi] == REALEND) {
       realstateschar [xreal] = CONTROLSTATE;
       realstates1 [xreal] = REALEND;
       realstates2 [xreal] = REALEND;
    }

}